-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Hello, I want to use the Pack() function (https://developers.google.com/optimization/reference/python/constraint_solver/pywrapcp#pack_1) of the Routing solver.
I read the documentation and I wrote some code based on the basic VRP example (https://developers.google.com/optimization/routing/vrp#entire_program1) to test this function.
In the above VRP example, I just added the following code before the solver starts to search for a solution:
solver = routing.solver()
all_vars_to_pack = [solver.IntVar(0,2,"a"), solver.IntVar(0,2,"a")]
for var in all_vars_to_pack:
routing.AddToAssignment(var)
pack_constraint = solver.Pack(all_vars_to_pack, 2)
usage_vars = [solver.IntVar(4,4,"a"), solver.IntVar(4,4,"a")]
for var in usage_vars:
routing.AddToAssignment(var)
pack_constraint.AddSumVariableWeightsLessOrEqualConstantDimension(usage_vars, [3, 5])
solver.Add(pack_constraint)The problem is this: When the program is executed, I see that it packed both of the items (quantity 4+4=8) in the 2nd bin which is not feasible because the capacity of the 2nd bin is 5.
My questions are the following:
-
Is there a way to avoid the mixing of items?
-
Are there any examples of how to properly use the Pack class and Pack() function while trying to solve a VRP?