VRP-TW: restrict each vehicle to specific set of node locations

752 views
Skip to first unread message

Mohamed W. Mehrez

unread,
Jun 3, 2021, 10:44:57 PM6/3/21
to or-tools-discuss
Hi or-tools experts,

Now I would like to consider a vrp problem with time window constraints a little differently. In particular, I would like to restrict each vehicle in the fleet to a set of visit locations prior running the solver. Of course, this problem may seem as decoupled TSP's; however, I would like more than one vehicle to service the same location. 

For example, Let's say I have the following set of locations indicies
{0,1,2,3,4,5,6,7}
and 2 vehicles
vehicle_0 should service locations {0,1,2,3,4} 
vehicle_1 should service locations {4,5,6,7,1}

Note that the two vehicles would like to service nodes 1 and 4, but they shouldn't do that at the same time.

we also may have some time constraints on visiting each of the locations. I am wondering now how we can route these two vehicles.

I hope that my question is clear and I appreciate your help!

All the best,
Mohamed



Mizux Seiha

unread,
Jun 4, 2021, 3:14:43 AM6/4/21
to or-tools-discuss
You can play with the `VehicleVar(index)`
e.g.
```python
index = manager.NodeToIndex(4)
 routing.VehicleVar(index).SetValues([0, 1]) // you may also add the sentinel value -1 if node can be dropped
```

Mohamed W. Mehrez

unread,
Jun 7, 2021, 7:36:47 PM6/7/21
to or-tools-discuss
Hi Mizu,

I tried this solution, but only one vehicle gets routed to the "index" location 0 or 1 in your example. I wanted to have the same "index" (location) be visited by 2 or more vehicles without overlaps in the visit time.

Thanks for your help!
Mohamed

Mizux Seiha

unread,
Jun 8, 2021, 2:57:51 AM6/8/21
to or-tools-discuss
1. No in my example only vehicle 0 OR 1 can visit the location 4. i.e. SetValues([0, 1]) is a list of vehicle index...

2. All locations can only be visited once, if you want several visits you must duplicate the location..
Reply all
Reply to author
Forward
0 new messages