简体   繁体   中英

How to add a servicing time constraint to a vehicle routing problem with time window constraints

I'm building a tour planner. This tour planner will be given travel time matrix for the itinerary of all places, opening and closing times of all locations and the stay/processing time at each location. I am using Google's OR tools to solve the problem

I've been successful in adding the time window constraints, but am not able to add the stay/processing time constraint to the solver. The documentation on google OR tools shows how to solve a vehicle routing problem with time window constraints, but there is no mention of how i could add more constraints to the problem.

I've been following this tutorial till now. https://developers.google.com/optimization/routing/vrptw

The expected output for the planner should consider all the three time constraints mentioned above ie opening time, closing time and stay/processing time

This is actually really simple. Since the stay time/processing time will depend only on the destination node, this can be directly added to the time matrix that will be used to solve the problem. For a N*N time matrix where N is the number of nodes in the problem, and a 1*N matrix of stay time, the stay time matrix has to be added to each row of the time matrix to get a matrix that includes both the time matrix and the stay time matrix. Leaving this here for anyone who may face the same problem.

Your transit callback should return the sum of the service time and the travel time. ie transit(i, j) == service_time(i) + travel_time(i, j)

If your service time depends on the vehicle you can register a transit callback per vehicle type then use the AddDimension() overload which take a transit callback index array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM