feat(objectives): add minimize-depot-travel-time objective#13
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Prefer assigning each job to the vehicle whose depot (shift start) is
closest to it by travel duration. Two modes via an optional `cap`:
- soft (cap omitted): a per-assigned-job penalty intended for use inside a
weighted-sum tier; degenerate if used standalone (assigning nothing wins).
- capped "depot radius" (cap set): leaving a job unassigned costs `cap`, so
the objective assigns jobs within the radius (nearest first) and drops the
rest. Safe as a dominant tier — the empty solution costs N*cap, never wins.
Exposed in the pragmatic format as
{"type":"minimize-depot-travel-time","cap"?:<seconds>}. Objective-only (no
constraint/state).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vrp-core unit tests covering soft and capped ("depot radius") modes, plus a
vrp-pragmatic round-trip + goal-build test for the
{"type":"minimize-depot-travel-time","cap"?:<seconds>} format.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6b461ce to
824ea05
Compare
kraklo
approved these changes
Jun 23, 2026
kraklo
left a comment
There was a problem hiding this comment.
tbh I don't think I know enough of the vrp internals to check it off with full confidence, but nothing is jumping out at me and the unit tests seem to give us good confidence
adamdickinson
approved these changes
Jun 23, 2026
adamdickinson
left a comment
Collaborator
There was a problem hiding this comment.
Approving, not really because I can read the code, but because I'm keen to get it shipped 😄.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Workforce wants a scheduling recipe that keeps each technician working in their local patch — assigning jobs to the vehicle whose depot (shift start) is closest to the job. The existing
minimize-cost/minimize-distanceobjectives minimise total route travel (not per-job depot proximity), andCompactTourclusters a tour's jobs near each other (not near the depot). This adds a dedicated objective for that.This is the
uptick/vrphalf of a two-repo change; the Workforce side adds anear-depotrecipe that uses it (and bumps thevrp-clidependency once this releases).Changes
vrp-core/.../features/depot_proximity.rs— aFeatureObjectivescoring each job by the travel duration from its route's depot (route.actor.detail.start) to the nearest of the job's candidate locations (handlesSingleandMulti). Objective-only; no constraint or state. TheDepotPenaltyFntype alias is the seam for a future non-linear penalty (linear/identity today).cap:cap = None) — a per-assigned-job penalty, intended as a member of aweighted-sumtier. Degenerate if used standalone (assigning nothing has zero travel).cap = Some(c)) — leaving a job unassigned costsc, while assigning it costs its depot→job travel. Minimising this assigns every job withincof a depot (nearest first) and drops the rest — proximity-gated assignment, safe as a dominant lexicographic tier (the empty solution costsN*c, never wins). Mirrorsminimize_unassigned's handling of unassigned/ignored jobs.Objective::MinimizeDepotTravelTime { cap: Option<Float> }→{"type":"minimize-depot-travel-time"}or{"type":"minimize-depot-travel-time","cap":1200.0}. Wired throughgoal_reader.rs.1.25.3(+ rosomaxa0.9.3, lockstep) and CHANGELOG updated, so Workforce can depend on the published build.Verification
cargo test -p vrp-core depot_proximity— 11 unit tests (estimate at route vs activity context, nearest-of-multiple-places, Multi jobs, no-location → 0, capped reward/penalty, capped fitness penalises unassigned).cargo test -p vrp-pragmatic minimize_depot_travel_time— round-trip parse (with/withoutcap) + goal-build.cargo fmt/clippyclean on the changed files; full workspacecargo checkpasses.🤖 Generated with Claude Code