I would suggest that you need to create unique dimensions for each
slot in capacity. I think you are almost there, but you are not
changing the "name" of the dimension. So perhaps this is the change
you need?
``` python
# (note I changed the last thing to demand_evaluator_fn)
def add_capacity_constraints(manager,routing, data, demand_evaluator_fn):
"""Adds capacity constraint"""
capacity_dimension_name = 'Capacity'
for jth_item in range(0,3):
# fix the dimension name to be unique
jth_item_capacity_name = f'{capacity_dimension_name}_item_{jth_item}'
# get a vector of capacities for each of the vehicles (your i iterator, I think)
vehicle_capacities = [vehicle_capacities[i][jth_item]
for i in range(0,4)] # i is per vehicle, I think
# create the callback function for the demand for this item
demand_evaluator_index = routing.RegisterUnaryTransitCallback(demand_evaluator_fn(jth_item))
routing.AddDimensionWithVehicleCapacity(
demand_evaluator_index,
0, # null capacity slack
vehicle_capacities,
True, # start cumul to zero
jth_item_capacity_name)
# Create callback function generator
demand_evaluator_fn = create_demand_evaluator(data, manager)
add_capacity_constraints(manager,routing, data, demand_evaluator_fn)
```
Something like that. I didn't double check things, so this probably
won't work, but the idea is the vehicle capacities is a vector (per
vehicle), and the dimension name must change for each new dimension.
Hope that helps,
James
> --
> You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
or-tools-discu...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/or-tools-discuss/24011098-c1e8-4853-a7d2-b1e49aa075f2n%40googlegroups.com.
--
James E. Marca
Activimetrics LLC