I am using or-tools vrp framework, and I am trying to create mutually exclusive paths.
Suppose I have 7 different locations [0,1,2,3,4,5,6]. I would like to make my vrp either visit [0,1,2,6] or [3,4,5,6] (in whatever order it deems optimal)
I know that I can use:
routing.AddDisjunction([manager.NodeToIndex(0), manager.NodeToIndex(1)])
to choose between visiting node 0 or 1.
However, I would like to make a disjunction between 2 sets rather than two nodes. So something like:
routing.AddDisjunction([[manager.NodeToIndex(0), manager.NodeToIndex(1),manager.NodeToIndex(2)],[manager.NodeToIndex(3), manager.NodeToIndex(4),manager.NodeToIndex(5)]])
I found that it is possible to do this by just using multiple disjunctions.
So if you want to force it to go to either {0,1} or {2,3} you can do this as such:
routing.AddDisjunction([manager.NodeToIndex(0), manager.NodeToIndex(2)])
routing.AddDisjunction([manager.NodeToIndex(0), manager.NodeToIndex(3)])
routing.AddDisjunction([manager.NodeToIndex(1), manager.NodeToIndex(2)])
routing.AddDisjunction([manager.NodeToIndex(1), manager.NodeToIndex(3)])
It is a bit cumbersome especially for larger sets, but I haven’t found any other method.