[英]penalty in multitrip vrp if different vehicle visits a destination in 2nd trip ORTOOLS
I have implemented multitrip (Allow vehicles to visit a destination more than once) VRP using ortools.我已经使用 ortools 实施了 multitrip(允许车辆多次访问目的地)VRP。 This has been done by duplicating nodes for destinations and introducing virtual depots with negative loads.
这是通过为目的地复制节点并引入具有负负载的虚拟仓库来完成的。
I want same vehicle to visit destinations in 2nd trip which visited that destination in 1st trip.我希望同一辆车在第二次旅行中访问目的地,而在第一次旅行中访问该目的地。 This is a soft constraint and a penalty should be added in the objective function if not followed.
这是一个软约束,如果不遵守,应该在目标 function 中添加惩罚。 How can we implement this?
我们如何实施呢?
/// Adds a soft constraint to force a set of variable indices to be on the
/// same vehicle. If all nodes are not on the same vehicle, each extra vehicle
/// used adds 'cost' to the cost function.
void AddSoftSameVehicleConstraint(const std::vector<int64_t>& indices,
int64_t cost);
Using this, I think you can model your requirement.使用这个,我想你可以 model 你的要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.