Limit the number of visited sites per route
It is possible to limit the number of logistics sites through which a vehicle passes. This constraint is defined per vehicle, so it is valid regardless of the vehicle's availability period.
This limitation concerns sites on which collections or deliveries are done. Park sites, trailer drop-off sites and depot sites are not affected by this constraint.
1 - Vehicle Type Definition​
To define a constraint on a vehicle, define a Vehicle Type (this makes it easy to share constraints with a set of vehicles). Let's define a vehicle type for which we choose to limit the maximum number of sites to 1:
{
"id": "VEHICLE_TYPE_1",
"maxSitesPerRoute": 1
}
2 - Additional Data​
It remains to define a vehicle and its availability period related to the above type:
{
"id": "TRUCK_1",
"idVehicleType": "VEHICLE_TYPE_1",
"availablePeriods": [
{
"id": "PERIOD_1",
"timeWindow": {
"start": "2020-12-11T16:31:27.973+01:00",
"end": "2020-12-12T16:31:27.973+01:00"
}
}
]
}
Finally, let's define two operations to be delivered to two different sites:
"operations": [
{
"id": "OPERATION_1",
"type": "DELIVERY",
"idSiteOrigin": "DEPOT_1",
"idSiteDestination": "SITE_1"
},
{
"id": "OPERATION_2",
"type": "DELIVERY",
"idSiteOrigin": "DEPOT_1",
"idSiteDestination": "SITE_2"
}
]
The Solution​
The two operations were planned on two different routes as the vehicle can only pass through one customer site per route:
"routes": [
{
"id": "NewRoute_1_1"
{
"id": "NewRoute_1_2"
Full Problem
{
"sites": [
{
"id": "SITE_1",
"coordinates": {
"latitude": 47.46257,
"longitude": -0.56151
}
},
{
"id": "SITE_2",
"coordinates": {
"latitude": 48.11415,
"longitude": -1.60611
}
},
{
"id": "DEPOT_1",
"coordinates": {
"latitude": 47.20586,
"longitude": -1.56435
}
}
],
"trucks": [
{
"id": "TRUCK_1",
"idVehicleType": "VEHICLE_TYPE_1",
"availablePeriods": [
{
"id": "PERIOD_1",
"timeWindow": {
"start": "2020-12-11T16:31:27.973+01:00",
"end": "2020-12-12T16:31:27.973+01:00"
}
}
]
}
],
"vehicleTypes": [
{
"id": "VEHICLE_TYPE_1",
"maxSitesPerRoute": 1
}
],
"operations": [
{
"id": "OPERATION_1",
"type": "DELIVERY",
"idSiteOrigin": "DEPOT_1",
"idSiteDestination": "SITE_1"
},
{
"id": "OPERATION_2",
"type": "DELIVERY",
"idSiteOrigin": "DEPOT_1",
"idSiteDestination": "SITE_2"
}
]
}
Full Solution
{
"vehicleRoutes": [
{
"truck": "TRUCK_1",
"period": "PERIOD_1",
"routes": [
{
"id": "NewRoute_1_1",
"activities": [
{
"activity": "ROUTE_START",
"timeWindow": {
"start": "2020-12-11T15:31:27Z",
"end": "2020-12-11T15:31:27Z"
},
"site": "DEPOT_1"
},
{
"activity": "LOADING",
"timeWindow": {
"start": "2020-12-11T15:31:27Z",
"end": "2020-12-11T15:31:27Z"
},
"site": "DEPOT_1",
"fixedTimeSite": 0,
"operations": [
{
"id": "OPERATION_1"
}
]
},
{
"activity": "DRIVING",
"timeWindow": {
"start": "2020-12-11T15:31:27Z",
"end": "2020-12-11T16:31:40Z"
},
"departureSite": "DEPOT_1",
"arrivalSite": "SITE_1",
"distance": 92784,
"nominalDuration": 3613
},
{
"activity": "DELIVERY",
"timeWindow": {
"start": "2020-12-11T16:31:40Z",
"end": "2020-12-11T16:31:40Z"
},
"site": "SITE_1",
"fixedTimeSite": 0,
"operations": [
{
"id": "OPERATION_1"
}
]
},
{
"activity": "DRIVING",
"timeWindow": {
"start": "2020-12-11T16:31:40Z",
"end": "2020-12-11T17:32:58Z"
},
"departureSite": "SITE_1",
"arrivalSite": "DEPOT_1",
"distance": 89964,
"nominalDuration": 3678
},
{
"activity": "ROUTE_END",
"timeWindow": {
"start": "2020-12-11T17:32:58Z",
"end": "2020-12-11T17:32:58Z"
},
"site": "DEPOT_1"
}
]
},
{
"id": "NewRoute_1_2",
"activities": [
{
"activity": "ROUTE_START",
"timeWindow": {
"start": "2020-12-11T17:33:58Z",
"end": "2020-12-11T17:33:58Z"
},
"site": "DEPOT_1"
},
{
"activity": "LOADING",
"timeWindow": {
"start": "2020-12-11T17:33:58Z",
"end": "2020-12-11T17:33:58Z"
},
"site": "DEPOT_1",
"fixedTimeSite": 0,
"operations": [
{
"id": "OPERATION_2"
}
]
},
{
"activity": "DRIVING",
"timeWindow": {
"start": "2020-12-11T17:33:58Z",
"end": "2020-12-11T18:51:25Z"
},
"departureSite": "DEPOT_1",
"arrivalSite": "SITE_2",
"distance": 111763,
"nominalDuration": 4647
},
{
"activity": "DELIVERY",
"timeWindow": {
"start": "2020-12-11T18:51:25Z",
"end": "2020-12-11T18:51:25Z"
},
"site": "SITE_2",
"fixedTimeSite": 0,
"operations": [
{
"id": "OPERATION_2"
}
]
},
{
"activity": "ROUTE_END",
"timeWindow": {
"start": "2020-12-11T18:51:25Z",
"end": "2020-12-11T18:51:25Z"
},
"site": "SITE_2"
}
]
}
]
}
],
"rejectOperations": [],
"modifiedData": []
}