I am solving a Prize Collecting VRPTW. In my problem, each node represents a visit that needs to be made within a certain time window, and the "prize" for each node is the time spent at the visit. Some visits require more than one vehicle. Therefore, I have pairs of nodes that represent the same visit. I want to add a synchronization constraint such that if one node in a pair is visited, then the other node must also be visited (not the same vehicle). Currently, my model includes time windows for each visit, and I am using the AddDisjunction function to allow nodes to be dropped, with the "prize" for each node as the penalty.

I tried using the following code, but this does not result in a feasible solution.

for visit in data['visit_pairs']:
if len(visit) == 2:
index1 = manager.NodeToIndex(visit[0])
index2 = manager.NodeToIndex(visit[1])
routing.solver().Add(routing.ActiveVar(index1) == routing.ActiveVar(index2))

I also tried below which gives me a feasible solution that often violates the constraint.

routing.solver().Add(time_dimension.CumulVar(index1) == time_dimension.CumulVar(index2))

How can I modify my model to implement service synchronization, given that I also need to allow nodes to be dropped?

(Also in Google or-tools-discuss)



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.