Reputation: 322
I have already defined various constraints on a working code with multiple vehicle types. Now, I want to add a new constraint.
For a given vehicle, it shouldn't service nodes with less than given demand. So, when this constraint will be applied to one type of vehicle, any nodes less than that demand will be served by OTHER vehicles [which won't have this constraint.]
Need help. I am currently stuck on this.
Example code for 2 types of vehicles
for i in range(vehicle_type_1_starting_index, vehicle_type_1_ending_index):
# [my constraints here, setting arc costs etc]
for i in range(vehicle_type_2_starting_index, vehicle_type_2_ending_index):
# [my constraints here, setting arc costs etc]
# NEW CONSTRAINT LIKE: routing.solver().Add((routing.ActiveVehicleVar(int(i)) * capacity_dimension.[? minimum demand each visited node ?] >= 20)
Upvotes: 1
Views: 586
Reputation: 322
Solution:
for node_index in range(len(nodes)):
if nodes[node_index] according to criteria:
routing.SetAllowedVehiclesForIndex(list(allowed_vehicle_list)), node_index)
I have just banned my vehicle type B from visiting nodes with demand less than X. They are visited by vehicle type A which have no such constraints.
Upvotes: 2