Dynamical Range
回答済みHi,
I am trying to solve a packaging problem where math model describes postion of products in packaging boxes. In problem formulation it is not known apriori how many pieces of product can be fitted in a box.
For example product of type 2 can be fitted in a box 3 times. Then the coordinates of 2nd product of type 2 would be X_2,2 and coordinates of 3d product of type 2 would be X_2,3.
The programm should check geometrical constraints for each product, so we have to iterate through product types and every product of said type in a box. For example:
n_p = model.addVars(P, vtype=GRB.Integer, name='n_p')
model.addConstrs(L[p, i]+l[p] <= B[p] for i in range(n_p[p]) for p in P)
where n_p[p] is how much product of type p can be fitted in a packaging box.
Can Gurobi iterate i over range(n_p[p]), where vector n_p is not known and should also be found out by the program?
If not, how can I try to go around this problem?
-
Hi Ilya,
This is not possible.
The values of \(\texttt{n_p}\) which are retrieved by \(\texttt{n_p[p].X}\) cannot be used in this way (they are not defined until the \(\texttt{optimize}\) call).Cheers,
David1
サインインしてコメントを残してください。
コメント
1件のコメント