Reputation: 265
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.
Upvotes: 3
Views: 908
Reputation: 9281
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')
Upvotes: 3
Reputation: 11014
You can pass a vector/list of evaluators.
Here is the C++ API/
Upvotes: 2