Skip to content

Commit

Permalink
Fix issue with initial solution and relad (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed Aug 17, 2023
1 parent 58cd341 commit 6d8f371
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Fixed

* reload is removed from the solution passed as initial (#126)


## [v1.22.0]- 2023-08-08

Expand Down
15 changes: 11 additions & 4 deletions vrp-pragmatic/src/construction/features/reloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl<T: Send + Sync> FixedMultiTrip<T> {
}

fn promote_multi_trips_when_needed(&self, solution_ctx: &mut SolutionContext) {
let jobs = solution_ctx
let candidate_jobs = solution_ctx
.routes
.iter()
.filter(|route_ctx| self.is_multi_trip_needed(route_ctx))
Expand All @@ -269,9 +269,16 @@ impl<T: Send + Sync> FixedMultiTrip<T> {
})
.collect::<HashSet<_>>();

solution_ctx.ignored.retain(|job| !jobs.contains(job));
solution_ctx.locked.extend(jobs.iter().cloned());
solution_ctx.required.extend(jobs.into_iter());
// NOTE: get already assigned jobs to guarantee locking them
let assigned_job = solution_ctx
.routes
.iter()
.flat_map(|route_ctx| route_ctx.route().tour.jobs())
.filter(|job| self.is_marker_job(job));

solution_ctx.ignored.retain(|job| !candidate_jobs.contains(job));
solution_ctx.locked.extend(candidate_jobs.iter().cloned().chain(assigned_job));
solution_ctx.required.extend(candidate_jobs.into_iter());
}
}

Expand Down

0 comments on commit 6d8f371

Please sign in to comment.