[英]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
我正在使用 Google 的 OR 工具来解决问题
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.
google OR 工具上的文档显示了如何解决具有时间窗口约束的车辆路线问题,但没有提及我如何向该问题添加更多约束。
I've been following this tutorial till now.到目前为止,我一直在关注本教程。 https://developers.google.com/optimization/routing/vrptw
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.
对于 N*N 时间矩阵(其中 N 是问题中的节点数)和 1*N 停留时间矩阵,必须将停留时间矩阵添加到时间矩阵的每一行以获得包含两者的矩阵时间矩阵和停留时间矩阵。 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)
即
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.如果您的服务时间取决于车辆,您可以为每种车辆类型注册一个公交回调,然后使用
AddDimension()
重载,它采用公交回调索引数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.