Search code examples
c#traveling-salesmanor-toolsvehicle-routing

Vehicle skills using or-tools with C#


Im trying to solve Vehicle Routing with Pickups and Deliveries using or-tool with C#. Is it possible to add some kind of skills (product type) to the vehicle? example:

  • vehicle1 - skills [liquid]
  • vehicle2 - skills [liquid, gas]
  • vehicle3 - skills [solid]
  • pickup1 - type [gas]
  • pickup2 - type [liquid]

So pickup1 can only be picked up by vehicle2, but pickup2 can be picked up by vehicle1 or vehicle2.


Solution

  • You can restrict the vehicle var of each node to filter unskilled vehicles.

    For a given node, the vehicle var has a domain [-1, 0, .., num_vehicle - 1].

    -1 is assigned to the vehicle var if the node is not visited.

    So if you have n vehicle, and you want to forbid vehicle i to visit node j, you need to remove i from the domain of the vehicle var j.

    After this removal, the domain of the vehicle var should be [0, .., i - 1, i + 1, .. , n - 1] if the node is not optional, or [-1, .., i - 1, i + 1, .. , n - 1] if the node is optional.