How would I make the optimal solution visit say two locations per week?
Thus I need to
- generate a route of locations
- have time windows where one cannot visit places (I think list of time windows would work which is supported)
- restrict the solution only so many locations per week (say 2) …
- have a custom start and end location also …
This is a simplified example from the “Service Visits” tutorial with 3 locations and 1 vehicle:
{
“service_orders”: [
{
“id”: “order-1”,
“location”: {
“lat”: 36.185851,
“lng”: -115.2064059
},
“service_duration”: 300,
“time_windows”: [{“earliest”: 0, “latest”: 86400}, {“earliest”: 172800, “latest”: 604800}],
“optional”: true
},
{
“id”: “order-2”,
“location”: {
“lat”: 36.190831,
“lng”: -115.137368
},
“service_duration”: 300,
“time_windows”: [{“earliest”: 0, “latest”: 86400}, {“earliest”: 172800, “latest”: 604800}],
“optional”: true
},
{
“id”: “order-3”,
“location”: {
“lat”: 36.1692548,
“lng”: -115.1312463
},
“service_duration”: 300,
“time_windows”: [{“earliest”: 0, “latest”: 86400}, {“earliest”: 172800, “latest”: 604800}],
“optional”: true
}
],
“vehicles”: [
{
“id”: “vehicle-1”,
“start”: {
“lat”: 36.159548,
“lng”: -115.3172336
},
“end”: {
“lat”: 36.159548,
“lng”: -115.3172336
},
“max_orders”: 2
}
]
}
If you assume to work during the week, we have an interval from 0 to 604800 (7 days in seconds, for example from Sunday midnight).
Let’s say you can’t visit places on Tuesday. Then you can specify 2 time windows: before Tuesday and after Tuesday:
“time_windows”: [{“earliest”: 0, “latest”: 86400}, {“earliest”: 172800, “latest”: 604800}]
Notice the “max_orders” property, which limits the maximum number of locations(orders) for a vehicle. You can also set the property “optional” to “true” on the order. Then 2 orders will be assigned to the vehicle, and the rest (unassigned) will be returned in the “unassigned_orders” property. Otherwise, we will get “No Solution”, because we need to serve 3 orders, but the car is limited to only 2.
Start and End are set by the “Start” and “End” properties of vehicle.