Multiple routing profiles
This example demonstrates how to use multiple routing profiles: car
and truck
.
List of problem locations
[
{
"lat": 52.52599,
"lng": 13.45413
},
{
"lat": 52.5225,
"lng": 13.4095
},
{
"lat": 52.5316,
"lng": 13.3884
}
]
Routing matrix for car
{
"profile": "normal_car",
"travelTimes": [
0,
681,
905,
750,
0,
546,
891,
502,
0
],
"distances": [
0,
3840,
5283,
4696,
0,
2668,
5112,
2470,
0
]
}
Routing matrix for truck
{
"profile": "normal_truck",
"travelTimes": [
0,
906,
1218,
970,
0,
750,
1152,
644,
0
],
"distances": [
0,
3840,
5283,
4482,
0,
2768,
5112,
2357,
0
]
}
Problem
{
"plan": {
"jobs": [
{
"id": "job1",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.52599,
"lng": 13.45413
},
"duration": 240.0
}
],
"demand": [
1
]
}
]
},
{
"id": "job2",
"deliveries": [
{
"places": [
{
"location": {
"lat": 52.5225,
"lng": 13.4095
},
"duration": 600.0
}
],
"demand": [
10
]
}
]
}
]
},
"fleet": {
"vehicles": [
{
"typeId": "my_car",
"vehicleIds": [
"my_car_1"
],
"profile": {
"matrix": "normal_car"
},
"costs": {
"fixed": 22.0,
"distance": 0.0002,
"time": 0.004806
},
"shifts": [
{
"start": {
"earliest": "2019-07-04T09:00:00Z",
"location": {
"lat": 52.5316,
"lng": 13.3884
}
},
"end": {
"latest": "2019-07-04T18:00:00Z",
"location": {
"lat": 52.5316,
"lng": 13.3884
}
}
}
],
"capacity": [
1
]
},
{
"typeId": "my_truck",
"vehicleIds": [
"my_truck_1"
],
"profile": {
"matrix": "normal_truck"
},
"costs": {
"fixed": 44.0,
"distance": 0.0003,
"time": 0.005
},
"shifts": [
{
"start": {
"earliest": "2019-07-04T09:00:00Z",
"location": {
"lat": 52.5316,
"lng": 13.3884
}
},
"end": {
"latest": "2019-07-04T18:00:00Z",
"location": {
"lat": 52.5316,
"lng": 13.3884
}
}
}
],
"capacity": [
10
]
}
],
"profiles": [
{
"name": "normal_car"
},
{
"name": "normal_truck"
}
]
}
}
Solution
{
"statistic": {
"cost": 89.371516,
"distance": 15520,
"duration": 4030,
"times": {
"driving": 3190,
"serving": 840,
"waiting": 0,
"break": 0
}
},
"tours": [
{
"vehicleId": "my_car_1",
"typeId": "my_car",
"shiftIndex": 0,
"stops": [
{
"location": {
"lat": 52.5316,
"lng": 13.3884
},
"time": {
"arrival": "2019-07-04T09:00:00Z",
"departure": "2019-07-04T09:00:00Z"
},
"distance": 0,
"load": [
1
],
"activities": [
{
"jobId": "departure",
"type": "departure"
}
]
},
{
"location": {
"lat": 52.52599,
"lng": 13.45413
},
"time": {
"arrival": "2019-07-04T09:14:51Z",
"departure": "2019-07-04T09:18:51Z"
},
"distance": 5112,
"load": [
0
],
"activities": [
{
"jobId": "job1",
"type": "delivery"
}
]
},
{
"location": {
"lat": 52.5316,
"lng": 13.3884
},
"time": {
"arrival": "2019-07-04T09:33:56Z",
"departure": "2019-07-04T09:33:56Z"
},
"distance": 10395,
"load": [
0
],
"activities": [
{
"jobId": "arrival",
"type": "arrival"
}
]
}
],
"statistic": {
"cost": 33.864016,
"distance": 10395,
"duration": 2036,
"times": {
"driving": 1796,
"serving": 240,
"waiting": 0,
"break": 0
}
}
},
{
"vehicleId": "my_truck_1",
"typeId": "my_truck",
"shiftIndex": 0,
"stops": [
{
"location": {
"lat": 52.5316,
"lng": 13.3884
},
"time": {
"arrival": "2019-07-04T09:00:00Z",
"departure": "2019-07-04T09:00:00Z"
},
"distance": 0,
"load": [
10
],
"activities": [
{
"jobId": "departure",
"type": "departure"
}
]
},
{
"location": {
"lat": 52.5225,
"lng": 13.4095
},
"time": {
"arrival": "2019-07-04T09:10:44Z",
"departure": "2019-07-04T09:20:44Z"
},
"distance": 2357,
"load": [
0
],
"activities": [
{
"jobId": "job2",
"type": "delivery"
}
]
},
{
"location": {
"lat": 52.5316,
"lng": 13.3884
},
"time": {
"arrival": "2019-07-04T09:33:14Z",
"departure": "2019-07-04T09:33:14Z"
},
"distance": 5125,
"load": [
0
],
"activities": [
{
"jobId": "arrival",
"type": "arrival"
}
]
}
],
"statistic": {
"cost": 55.5075,
"distance": 5125,
"duration": 1994,
"times": {
"driving": 1394,
"serving": 600,
"waiting": 0,
"break": 0
}
}
}
],
"unassigned": []
}
Usage with cli
vrp-cli solve pragmatic profiles.basic.problem.json -m profiles.basic.matrix.car.json -m profiles.basic.matrix.truck -o profiles.basic.solution.json