Pack constraint strange behavior #2980
Replies: 2 comments
-
|
What are the values of all_vars_to_pack in the assignment ?
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00
Le dim. 28 juin 2020 à 20:58, AntonisK <[email protected]> a écrit :
… 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:
1.
Is there a way to avoid the mixing of items?
2.
Are there any examples of how to properly use the Pack class and
Pack() function while trying to solve a VRP?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2087>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3I6FVLGCK5J52SLMSTRY6HHFANCNFSM4OKU63RA>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Each var of all_vars_to_pack list has 1 as value in the assignment. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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:
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?
Beta Was this translation helpful? Give feedback.
All reactions