Time windows and route segment
Time Windows¶
Time Windows restrict the time which the Driver is allowed to visit a given Job.
This is often used for:
- Service Levels agreed with the customer
- Appointments agreed with the customer
- Deliver windows promised to the customer
- Opening hours of the customer
- Restricting access to a customer at a certain time of day (e.g. because of traffic, school zones, lunch, vehicle restrictions etc)
You can set Time Windows using the arrive_after and leave_by
attributes on each Job.
You can set both values, one of the values, or neither.
If it is not possible to serve a Job within its Time Window, the Job will be unserved.
Multi-shift
In a multi-shift request these two fields
become recurring service hours: the same clock times on every
Planning Day. They cannot cross midnight. To restrict a Job to
particular days, or to an overnight window, use
job.multi_shift.serve_within instead.
Note
arrive_after constrains the ETA (Estimated Time of Arrival) of a Job
leave_by constrains the ETD (Estimated Time of Departure) of a Job.
So, if you want to force a job to be served at an exact time, you should set
Examples
{
"uid": "uid1",
"duration": 2,
"leave_by": 14,
"location": {"lat": -33.849489, "lon": 151.127482}
}
{
"uid": "uid1",
"duration": 2,
"arrive_after": 9,
"leave_by": 10,
"location": {"lat": -33.849489, "lon": 151.127482}
}
{
"uid": "uid1",
"duration": 2,
"arrive_after": 18,
"location": {"lat": -33.849489, "lon": 151.127482}
}
{
"uid": "uid1",
"duration": 2,
"arrive_after": 9,
"leave_by": 15,
"location": {"lat": -33.849489, "lon": 151.127482}
}
Route Segment¶
route_segment restricts where a Job may appear within a Driver's route. It is useful when you need to fix important Jobs to the beginning or end of a route.
Allowed values are:
null(default): the Job may be served anywhere in the route."start": the Job must be served in the initial contiguous segment of the route."end": the Job must be served in the final contiguous segment of the route.
The intended route shape is:
Multiple "start" Jobs may be served consecutively at the beginning of the same route. Likewise, multiple "end" Jobs may be served consecutively at the end of the same route.
Fixing the first Job in a route¶
To force a Job to be served first, set:
If it is the only "start" Job assigned to that Driver's route, it will be the first Job in that route.
If multiple Jobs with "route_segment": "start" are assigned to the same route, they may be served consecutively at the beginning of the route in any optimiser-chosen order.
Note
route_segment = "start" does not mean the Job must be the single first Job in a route when multiple start-segment Jobs are present. It means the Job must be part of the route's initial block of start-segment Jobs.
route_segment = "end" does not mean the Job must be the single last Job in a route when multiple end-segment Jobs are present. It means the Job must be part of the route's final block of end-segment Jobs.
route_segment is a placement constraint. It does not make a Job mandatory and does not change Job priority or unserved penalties.
In a multi-shift request, reset applies
route_segment inside each Shift independently. continue applies
it across the Driver's whole journey.
Example
{
"drivers": [
{
"uid": "driver_1",
"shift_start": 8,
"shift_end": 17,
"start": {"lat": -33.867798, "lon": 151.166256},
"end": "start"
}
],
"jobs": [
{
"uid": "job_start_1",
"duration": 10,
"route_segment": "start",
"location": {"lat": -33.849489, "lon": 151.127482}
},
{
"uid": "job_any_1",
"duration": 10,
"route_segment": null,
"location": {"lat": -33.880661, "lon": 151.183096}
},
{
"uid": "job_end_1",
"duration": 10,
"route_segment": "end",
"location": {"lat": -33.913168, "lon": 151.262267}
}
],
"settings": {}
}