feat(shifts): add shift time from first job param#12
Conversation
1934418 to
6057f9e
Compare
adamdickinson
left a comment
There was a problem hiding this comment.
Let's pair through this. And maybe get Evan onto it. You could say my rust is a little... rusty.
6057f9e to
c71fca4
Compare
| let target_departure = floor - travel; | ||
| if target_departure > start_departure { | ||
| route_ctx.route_mut().tour.get_mut(0).unwrap().schedule.departure = target_departure; | ||
| } |
There was a problem hiding this comment.
This is the scheduler change. Given a floor (shift start) and the depot > first-job travel time, set depot departure so arrival lands exactly on the floor.
Runs every time the route's schedule is recomputed.
| let start_time = if allow_out_of_hours_depot_travel { | ||
| TimeInterval { earliest: None, latest: None } | ||
| } else { | ||
| TimeInterval { earliest: Some(shift_start_earliest), latest: shift_start_latest } | ||
| }; |
There was a problem hiding this comment.
This removes the depots time window if we allow_out_of_hours_travel as the solver no longer enforces the shift window at the depo stop.
The insertions and departure calculation handle this instead now
| if arrival > start_latest { | ||
| return ConstraintViolation::skip(self.duration_code); | ||
| } |
There was a problem hiding this comment.
This ensures we can't insert jobs that would cause us to start too late
| let effective_start = if allow_out_of_hours_depot_travel && tour.stops.len() > 2 { | ||
| parse_time(&tour.stops[1].schedule().arrival) | ||
| } else { | ||
| parse_time(&start.schedule().departure) | ||
| }; |
There was a problem hiding this comment.
This validates the solution after we have solved. Check effective start on either the 1st or 2nd stop depending on if the flag is enabled
kraklo
left a comment
There was a problem hiding this comment.
Logic looks sound to me. No heinous crimes or anything blocking. Only sketch thing is the toolchain pin (which is probably a good idea to do anyway) on nightly.
Other musing is do we want a test that still tests the start of shift time is still enforced. i.e. even moving the departure earlier, we still violate the arrival <= start_latest constraint
Adds a boolean `allow_out_of_hours_depot_travel` flag on `VehicleLimits`. When enabled, the shift's start window applies to the first job's arrival rather than to depot departure, allowing the truck to leave the depot before the shift starts so it arrives on-site at the shift start. The end side is unchanged: `shift.end.latest` still bounds depot return. Pins the rust toolchain to nightly-2026-02-10 for build stability. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c71fca4 to
ae3137c
Compare
|
has_tour_travel_limits didn't include allow_out_of_hours_depot_travel, so when a vehicle used the flag without also setting max_duration or max_distance, the tour_limit feature wasn't added to the goal context. That meant the new shift.start.latest enforcement in tour_limits.rs:120-133 was silently dead code in that configuration. Now fixed. New test: allow_out_of_hours_depot_travel_still_enforces_shift_start_latest covers the constraint direction: even with the flag on, a job whose travel time from the depot pushes first-job arrival past start.latest must remain unassigned. |
adamdickinson
left a comment
There was a problem hiding this comment.
I vaguely get it, but I certainly am no rustacean.
As long as everyone is confident of operation, let's go!
Summary
Adds a shift_time_from_first_job: Option flag to VehicleLimits. When true, the shift's start window applies to the first job's arrival instead of
depot departure — so the vehicle can leave early and arrive on-site at shift start, rather than idling at the depot.
The shift end side is unchanged: shift.end.latest still bounds the depot return.
Implementation
What this does not do
via shift.start.earliest instead.
Test plan