In ortools, I know you can run the CVRP with different capacities per vehicle. However, can you pass a different distance matrix based upon the vehicle? For example, two cities may be 1000 miles apart, but it may be much faster to get there by airplane than by automobile, so in doing CVRP work I may wish to pass a time matrix, not an actual distance matrix. That time matrix would be different based upon the vehicle type.
Should be close to this:
callback_indices = []
for vehicle_idx in range(data['n_vehicles']):
def vehicle_callback(from_index, to_index, i=vehicle_idx):
from_node = manager.IndexToNode(from_index)
to_node = manager.IndexToNode(to_index)
return data['vehicle_costs'][i] * data['time_matrices'][i][from_node][to_node]
callback_index = routing.RegisterTransitCallback(vehicle_callback)
callback_indices.append(callback_index)
routing.AddDimensionWithVehicleTransits(
callback_indices,
0,
max,
False,
'DimensionName')
You can pass a vector/list of evaluators.
Here is the C++ API/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With