Skip to main content
APIs 5 min read

Dynamically re-optimize fleets with HERE Tour Planning

Tour Planning

More gift-givers are shopping online, that means there are more packages to ship. With hundreds of millions of packages being delivered between Black Friday and Christmas Eve, let's look into how this madness transfers to the last mile of deliveries. In this blog post, we will talk about dynamic replanning of the delivery routes with HERE Tour Planning.

HERE Tour Planning is a multi-vehicle route optimization tool, that optimizes tours for your fleet taking into consideration constraints such as time windows, job requirements, vehicle capacity, multiple warehouse pickups, driver shifts, driving range and traffic information. One of the major benefits of tour planning is that it allows drivers to adjust rest of the planned tour when any unpredicted obstacles occur during the tour such as - changes in traffic conditions, new deliver/pickup job being added, job cancellation, vehicle breakdown or driver running late. HERE Tour Planning optimizes reminder of the tour in such instances, and the driver is able to continue with the delivery or pickup of packages.

We will work through an example of delivering packages to 5 locations in Los Angeles, starting from a warehouse in Culver City.

Tour Planning Delivery Locations

The Problem: 

Copied
        { 
    "plan": { 
        "jobs": [ 
            {   // Job 1 Details 
                "id": "fc9933ec-d642-41de-9e72-bb9cf2375a91", 
                "priority": 1, 
                "tasks": { 
                    "deliveries": [ 
                        { 
                            "places": [ 
                                { 
                                   "duration": 300, 
                                    "location": { 
                                        "lat": 34.0009, 
                                        "lng": -118.42696 
                                    } 
                                } 
                            ], 
                            "demand": [ 1 ] 
                        } 
                    ] 
                } 
            }, 
            {  // Job 2 Details 
            }, 
            {  // Job 3 Details 
            }, 
            {  // Job 4 details 
            }, 
            {  // Job 5 details 
            } 
    ] }, 

    "fleet": { 
        "types": [ 
            { 
                "profile": "vehicle", 
                "amount": 1, 
                "capacity": [ 10 ], 
                "costs": { 
                    "distance": 0.0005, 
                    "time": 0.002, 
                    "fixed": 22 
                }, 
                "id": "vehicle_1", 
                "shifts": [ 
                    { 
                        "start": { 
                            "location": { 
                                "lat": 34.02104, 
                                "lng": -118.39982 
                            }, 
                            "time": "2022-11-30T08:00:00-08:00" 
                        }, 
                        "end": { 
                            "location": { 
                                "lat": 34.02104, 
                                "lng": -118.39982 
                            }, 
                            "time": "2022-11-30T12:00:00-08:00" 
                        } 
                    } 
                ] 
            } 
        ], 
        "profiles": [ 
            { 
                "name": "vehicle", 
                "type": "car" 
            } 
        ] 
    } 
} 
  

On passing this problem to Tour Planning API, it generates the solution, i.e., the optimal sequence for these deliveries and pickups. In our case, the sequence generated by the API is shown below, where Job 1 and Job 2 are High Priority deliveries.

The Solution - API Response: 

Copied
        {
    "statistic": {
        "cost": 46.27,
        "distance": 30374,
        "duration": 4672,
        "times": {
            "driving": 3172,
            "serving": 1500,
            "waiting": 0,
            "break": 0
        }
    },
    "tours": [
        {
            "vehicleId": "vehicle_1_1",
            "typeId": "vehicle_1",
            "stops": [
                { // Depart from warehouse
                },
                { // First delivery stop
                    "location": {
                        "lat": 34.02605,
                        "lng": -118.40994
                    },
                    "time": {
                        "arrival": "2022-11-30T16:04:12Z",
                        "departure": "2022-11-30T16:09:12Z"
                    },
                    "load": [
                        4
                    ],
                    "activities": [
                        {
                            "jobId": "695646ad-9130-4862-b97d-a868804f31bb",
                            "type": "delivery"
                        }
                    ]
                },
                { // Second delivery stop
                },
                { // Third delivery stop
                },
                { // Fourth delivery stop
                },
                { // Fifth delivery stop
                },
                { // Arrive at warehouse
                }
            ],
            "statistic": {
                "cost": 46.27,
                "distance": 30374,
                "duration": 4672,
                "times": {
                    "driving": 3172,
                    "serving": 1500,
                    "waiting": 0,
                    "break": 0
                }
            },
            "shiftIndex": 0
        }
    ]
}
  

 

HERE Tour Planning Route

 

As the driver starts the deliveries, Job 1 and Job 4 get executed as planned. Then, a new pickup (Job 6) close to the airport, gets added to the tour. The remaining tour is replanned to accommodate this. When re-calculating the job sequence at this time, Job 1 and Job 4 are not considered because they are already completed. The start location for these calculations is changed to the location of Job 4 or the driver’s current location. New plan looks like:

Tour Planning - Replan

Job 5 is completed as planned. At Job 3, the customer is not available, so the driver spends some additional time trying to check customer availability. Considering this unplanned delay, the driver needs to recalculate the tour with the new constraints, to make sure the High Priority Job 2 can still be completed in time. Now the start location for re-calculation is Job 3.  The resulting sequence stays same this time. The vehicle returns to the warehouse location in Culver City after completing all assigned jobs.

Tour Planning - Replan

Conclusion

Refer to the previous blog post to understand the parameters in the Tour Planning Problem and Solution. Continue learning more about dynamic replanning on the go API reference. HERE Tour Planning is included with the platform base plan. You can contact us to request either an evaluation or a usage license. Try this out and leave a comment or reach us on Twitter at @heredev. We are excited to see your work!

 

Mohini Todkari

Mohini Todkari

Sr. Developer Evangelist

Have your say

Sign up for our newsletter

Why sign up:

  • Latest offers and discounts
  • Tailored content delivered weekly
  • Exclusive events
  • One click to unsubscribe