Subscribe to Planned, planning education for real-world stuff.
By Radovan Synek
August 4, 2023
The vehicle routing problem (VRP) is a popular academic optimization problem with numerous variants.
While you can map the vehicle routing problem to real-world tasks like planning deliveries or optimizing itineraries for field service technicians, very often you have to deal with at least one additional constraint: customers' availabilities.
Let’s start by defining the problem. Same as the vanilla VRP, the task is to plan routes of N vehicles to visit M customers to minimize the driving time. The additional complexity comes from customers' availability in limited time windows. If the vehicle arrives at the destination too early, it has to wait, which is suboptimal. If it arrives too late, it’s even worse as the planned visit has to be rescheduled to some other day and all the mileage driven comes in vain.
The domain model takes advantage of the @PlanningListVariable: the Vehicle is the @PlanningEntity with a list of Customer instances to visit. The @PlanningListVariable enables the use of a few build-in shadow variables:
@InverseRelationShadowVariable that points from the Customer to the assigned Vehicle.
@PreviousElementShadowVariable and @NextElementShadowVariable that point to the previous and the next customer in the list respectively.
To calculate the arrival time at each customer, the model relies on the arrivalTimeshadow variable that is updated by the ArrivalTimeUpdatingVariableListener every time the previousCustomer or the vehicle changes.
Providing the service to the customer also takes time, expressed by the serviceDuration. Of course, the service duration counts towards the customer’s availability. This is a hard constraint.
Wait a second, where do we make sure we don’t arrive too early? The serviceFinishedAfterDueTime constraint does it for us, just indirectly. The more time vehicles spend waiting, the fewer customers they can visit without arriving too late.
The vehicle routing with time windows is a more practical variation of VRP, which we might translate to domains like field service technician or last mile delivery. You can solve all these using Timefold Solver.
Continue reading
Blog
The only constant is change: How PlanningAI keeps schedules alive in real-time
Plans rarely survive reality, no matter how perfect they are. Employee sick calls, broken trucks, or no-show customers can wreck your carefully built schedule before lunchtime. That’s why our PlanningAI optimization algorithms replan in real-time. In this post, Tom Cools will enlighten you on how this works.
Blog
Is PlanningAI a blessing for Operations Research?
Operations Research is, and has always been, about solving one of the world’s toughest challenges: planning problems. Finding the best way to allocate resources, schedule shifts, or route deliveries under an abundance of real-world constraints. It is widely accepted that optimizing those problems will make the world a better place. The value has never been in question. But the road to real-world adoption? That’s been another story. With PlanningAI, we can alter the narrative.
Blog
Why PlanningAI encompasses scheduling, routing, and strategic decision-making
PlanningAI intentionally captures scheduling, routing, and strategy because businesses naturally function across multiple timeframes and complexities. Find out more about the etymology of PlanningAI in this blog post.