Planning

Example 1 – Operations with a single vehicle

Description of the problem

In this example, we have a request for the Planning API to solve a logistics problem involving 1 vehicle and 2 operations, starting from the distribution center.

Request

The full request can be seen below:

{
    "optimizationProfile": "BRAZIL46",
    "tripsProfile": "MAPLINK",
    "startDate": 1513750219000,
    "legislationProfiles": [
        {
            "name": "DEFAULT"
        }
    ],
    "logisticConstraints": [
        {
            "name": "P1Pickup",
            "siteLoadingFixedTime": 900
        },
        {
            "name": "P1Delivery",
            "siteUnloadingFixedTime": 600
        }
    ],
    "products": [
        {
            "name": "DEFAULT"
        }
    ],
    "sites": [
        {
            "name": "Cliente1",
            "coordinates": {
                "latitude": -23.507608,
                "longitude": -46.587145
            },
            "logisticConstraints": "P1Delivery"
        },
        {
            "name": "Cliente2",
            "coordinates": {
                "latitude": -23.621059,
                "longitude": -46.756193
            },
            "logisticConstraints": "P1Delivery"
        }
    ],
    "depots": [
        {
            "name": "CD",
            "coordinates": {
                "latitude": -23.503939,
                "longitude": -46.498419
            },
            "logisticConstraints": "P1Pickup"
        }
    ],
    "vehicleTypes": [
        {
            "name": "VUC",
            "maxVolume": 20,
            "maxWeight": 1200,
            "size": 1
        }
    ],
    "vehicles": [
        {
            "name": "VUC_1",
            "vehicleType": "VUC",
            "legislationProfile": "DEFAULT",
            "availablePeriods": [
                {
                    "departureSite": "CD",
                    "arrivalSite": "CD",
                    "timeWindow": {
                        "start": 1513753200000,
                        "end": 1513796400000
                    }
                }
            ]
        }
    ],
    "operations": [
        {
            "id": "P1",
            "weight": 100,
            "volume": 2,
            "product": "DEFAULT",
            "type": "DELIVERY",
            "depotSite": "CD",
            "customerSite": "Cliente1",
            "customerTimeWindows": [
                {
                    "start": 1513756800000,
                    "end": 1513771200000
                }
            ]
        },
        {
            "id": "P2",
            "weight": 250,
            "volume": 5,
            "product": "DEFAULT",
            "type": "DELIVERY",
            "depotSite": "CD",
            "customerSite": "Cliente2",
            "customerTimeWindows": [
                {
                    "start": 1513756800000,
                    "end": 1513771200000
                }
            ]
        }
    ]
}

Solution of the logistic problem

The API response will be returned in json format with the best sequencing of delivery operations for each vehicle.

The following global indicators are returned, as well as the time sequence of the activities carried out by the vehicle:

IndicatorResults
Total service time:00:35:00
Total delivery time:00:20:00
Total daytime working time:02:25:13
Total time worked at night:00:00:00
Total unloading time:00:00:00
Total working time:02:25:13
Total collection time:00:00:00
Number of time windows:1
Total driving time:01:50:13
Total charging time:00:15:00
Total time:02:25:13
Total distance:74.21 km
Average occupancy rate in Volume:35
Average occupancy rate in Peso:29.17
Number of rejections:0
Total waiting time:00:00:00
Total rest time:00:00:00
Number of routes:1
Global route indicators

Response

The full response can be found below:

{
    "id": "60942de8d7cb173bfb2b78c7",
    "clientId": "0wfdGfgEOFpME1RcsrBj4U5yAAJjeqFG",
    "vehicleRoutes": [
        {
            "routes": [
                {
                    "id": "NewRoute_1_1",
                    "activities": [
                        {
                            "activity": "ROUTE_START",
                            "timeWindow": {
                                "start": 1513754558000,
                                "end": 1513754558000
                            },
                            "type": "SITE",
                            "site": "CD",
                            "operations": []
                        },
                        {
                            "activity": "LOADING",
                            "timeWindow": {
                                "start": 1513754558000,
                                "end": 1513755458000
                            },
                            "type": "SITE",
                            "site": "CD",
                            "fixedTimeSite": 900,
                            "operations": [
                                "P2",
                                "P1"
                            ]
                        },
                        {
                            "activity": "DRIVING",
                            "timeWindow": {
                                "start": 1513755458000,
                                "end": 1513756800000
                            },
                            "type": "DRIVING",
                            "operations": [],
                            "arrivalSite": "Cliente1",
                            "departureSite": "CD",
                            "distance": 13245,
                            "nominalDuration": 1342
                        },
                        {
                            "activity": "DELIVERY",
                            "timeWindow": {
                                "start": 1513756800000,
                                "end": 1513757400000
                            },
                            "type": "SITE",
                            "site": "Cliente1",
                            "fixedTimeSite": 600,
                            "operations": [
                                "P1"
                            ]
                        },
                        {
                            "activity": "DRIVING",
                            "timeWindow": {
                                "start": 1513757400000,
                                "end": 1513759758000
                            },
                            "type": "DRIVING",
                            "operations": [],
                            "arrivalSite": "Cliente2",
                            "departureSite": "Cliente1",
                            "distance": 27131,
                            "nominalDuration": 2358
                        },
                        {
                            "activity": "DELIVERY",
                            "timeWindow": {
                                "start": 1513759758000,
                                "end": 1513760358000
                            },
                            "type": "SITE",
                            "site": "Cliente2",
                            "fixedTimeSite": 600,
                            "operations": [
                                "P2"
                            ]
                        },
                        {
                            "activity": "DRIVING",
                            "timeWindow": {
                                "start": 1513760358000,
                                "end": 1513763263000
                            },
                            "type": "DRIVING",
                            "operations": [],
                            "arrivalSite": "CD",
                            "departureSite": "Cliente2",
                            "distance": 34920,
                            "nominalDuration": 2905
                        },
                        {
                            "activity": "ROUTE_END",
                            "timeWindow": {
                                "start": 1513763263000,
                                "end": 1513763263000
                            },
                            "type": "SITE",
                            "site": "CD",
                            "operations": []
                        }
                    ],
                    "status": null,
                    "violationConstraints": null,
                    "compartmentConfiguration": null
                }
            ],
            "vehicle": "VUC_1",
            "period": {
                "timeWindow": {
                    "start": 1513753200000,
                    "end": 1513796400000
                },
                "departureSite": "CD",
                "arrivalSite": "CD",
                "maxRoutesNumber": null,
                "maxWorkingTime": null,
                "maxDrivingTime": null
            }
        }
    ],
    "rejectOperations": [],
    "indicators": {
        "totalServiceTime": 2100,
        "totalDeliveringTime": 1200,
        "dayWorkingTotalTime": 8705,
        "nightWorkingTotalTime": 0,
        "totalUnloadingTime": 0,
        "totalWorkingTime": 8705,
        "totalCollectingTime": 0,
        "timeWindowNumber": 1,
        "totalDrivingTime": 6605,
        "totalLoadingTime": 900,
        "totalTime": 8705,
        "totalDistance": 75296,
        "averageOccupancyRateVolume": 35.0,
        "averageOccupancyRateWeight": 29.17,
        "rejectOperationsNumber": 0,
        "totalWaitingTime": 0,
        "totalRestTime": 0,
        "routesNumber": 1
    }
}