Optimize a route
In this guide we will
- send entities sites, operations, trucks
- send a route optimization
- display the result on the map
Follow common setup steps
If not done already, follow common Introduction page.
Send the entities
First, build an entities
message with sites, operations and trucks.
Entities payload
{
"sites": [
{
"id": "MOULINS",
"coordinates": {
"longitude": 3.327869,
"latitude": 46.559176
},
"isDepot": false,
"entityType": "SITE"
},
{
"id": "AXIOROUTE",
"coordinates": {
"longitude": -0.561642,
"latitude": 47.462544
},
"isDepot": false,
"entityType": "SITE"
},
{
"id": "CJM",
"coordinates": {
"longitude": -0.345602,
"latitude": 48.597481
},
"isDepot": false,
"entityType": "SITE"
},
{
"id": "COFISOFT",
"coordinates": {
"longitude": 1.697037,
"latitude": 46.816713
},
"isDepot": false,
"entityType": "SITE"
},
{
"id": "GPI",
"coordinates": {
"longitude": 4.740329,
"latitude": 45.752201
},
"isDepot": false,
"entityType": "SITE"
},
{
"id": "SINARI",
"coordinates": {
"longitude": -1.604869,
"latitude": 48.113197
},
"isDepot": true,
"entityType": "SITE"
},
{
"id": "XYRIC",
"coordinates": {
"longitude": 5.09304,
"latitude": 47.310967
},
"isDepot": false,
"entityType": "SITE"
}
],
"trucks": [
{
"id": "VEHICLE_01",
"availablePeriods": [
{
"id": "PERIOD_01",
"timeWindow": {
"start": "2022-11-01T04:30:00.000+01:00",
"end": "2022-11-02T12:00:00.000+01:00"
},
"departureSite": "SINARI",
"arrivalSite": "SINARI"
}
],
"entityType": "TRUCK"
}
],
"operations": [
{
"id": "OPERATION_07",
"type": "DELIVERY",
"idSiteDestination": "MOULINS",
"splittable": false,
"fixedProduct": true,
"entityType": "OPERATION",
"isAffected": false,
"isRejected": false
},
{
"id": "OPERATION_01",
"type": "DELIVERY",
"idSiteDestination": "AXIOROUTE",
"splittable": false,
"fixedProduct": true,
"entityType": "OPERATION",
"isAffected": false,
"isRejected": false
},
{
"id": "OPERATION_02",
"type": "DELIVERY",
"idSiteDestination": "COFISOFT",
"splittable": false,
"fixedProduct": true,
"entityType": "OPERATION",
"isAffected": false,
"isRejected": false
},
{
"id": "OPERATION_03",
"type": "DELIVERY",
"idSiteDestination": "CJM",
"splittable": false,
"fixedProduct": true,
"entityType": "OPERATION",
"isAffected": false,
"isRejected": false
},
{
"id": "OPERATION_04",
"type": "DELIVERY",
"idSiteDestination": "GPI",
"splittable": false,
"fixedProduct": true,
"entityType": "OPERATION",
"isAffected": false,
"isRejected": false
},
{
"id": "OPERATION_05",
"type": "DELIVERY",
"idSiteDestination": "XYRIC",
"splittable": false,
"fixedProduct": true,
"entityType": "OPERATION",
"isAffected": false,
"isRejected": false
}
]
}
Map display
Compute routes
Send a Route optimization message.
Payload for RUN_MPT message
{
"type": "COMPUTE_ROUTES"
}
Map display
Once the optimization is finished, it is displayed on the map.