1

I am working on a VRP optimization problem. It includes capacity, pickup delivery, and time window constraints. I also want to minimize no of vehicles used for the tour. The sample problem set is -

[A -> B] [B -> C] [C -> B] [D -> E]

As I have the same node for both pickup and delivery, I duplicated the node and made it like this -

[A -> B1] [B2 -> C1] [C2 -> B3] [D -> E], 

where B1, B2, and B3 are duplications of B.C1 and C2 are duplications of C.

I could solve the problem with an arbitrary start point without any issue. I want to solve this problem with fixed starting and endpoints. Each vehicle will start from a point and come back to the same point. For example, the start point is B. To solve this problem, I duplicated B2 and created B0. Now the list of points looks like this -

[A -> B1] (B0) [B2 -> C1] [C2 -> B3] [D -> E] 
* Pickup and deliveries - [A -> B1] [B2 -> C1] [C2 -> B3] [D -> E]
* B0 is my start and end point
The distance from B0 to B2 is zero.

I created distance and duration matrices with this sequence of points. My program works. But the problem is it starts with B0 but revisits B2 later, which I don't want. I want to force B2 to be visited immediately after starting from B0 so that I can later manually merge duplicate points in sequence. My question is how can I force VRP to force visit this point first? Or, any other suggestion to tackle this situation?

Enthusiast
  • 181
  • 1
  • 12

1 Answers1

0

to force the first visit you could try to tweak the NextVar() associated to the vehicle start node.

something like this:

start_index = routing.Start(vehicle_index)
end_index = routing.End(vehicle_index)
b0_index = manager.NodeToIndex(B0)
routing.NextVar(start_index).SetValues([b0_index, end_index])
Mizux
  • 8,222
  • 7
  • 32
  • 48