Conditional constraint on vehicles traveling from one node to another #4487
Unanswered
jpconde
asked this question in
Routing (and legacy CP) questions
Replies: 2 comments 8 replies
-
It's just an idea, I think you could try adding constraints that two nodes of different types must not on same vehicle. May be with something like this IntVar* both_active = solver->MakeMin(routing.ActiveVar(i), routing.ActiveVar(j))->var();
IntVar* different_vehicle = solver->MakeIsDifferentVar(routing.VehicleVar(i), routing.VehicleVar(j));
Constraint* ct = solver->MakeEquality(solver->MakeProd(both_vehicle, solver->MakeSum(different_vehicle, -1)), 0);
solver->AddConstraint(ct); for every pair (i, j) such that Hope that can help. |
Beta Was this translation helpful? Give feedback.
0 replies
-
If I were you I would:
aka in Python something along this line solver = routing.solver()
for id in PickupIdList:
idx = manager.NodeToIndex(id)
b_vars = []
for type_dim in TypeDimensionList:
b_vars.append(solver.IsDifferentCstVar(type_dim.CumulVar(idx), 0))
solver.Add(solver.Sum(b_vars) <= 1) |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am working on a pickup and delivery routing problem with capacity constraints. Vehicles load a certain number of passengers (demand) at pickup points and unload a certain number of passengers (negative demand) at drop-off points. So far it works correctly.
Now I want to add a passenger type restriction: vehicles can load only one type of passenger at a given time. This means that, in order to load a certain type of passenger, the vehicle has to either carry the same type of passenger or be empty.
For example: vehicle A carries passengers of type 1. It can pick up more passengers of type 1 as long as there is space in the vehicle. However, if the vehicle is to pick up passengers of type 2, it has to drop off all passengers of type 1 before.
Can someone please help me with this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions