help writing component wise constraints in one line
ユーザーの入力を待っています。Hello
I am new to Gurobi and I need help writing component wise constraints.
I am trying to write a constraint which says that the sum of x_ijk over j for all i, and k is less than M_ik, which takes on different values for a given i,k pair. I am lost on how to do it as it brings the error below, which I have failed to fix. Please show me how to clean it up.
TypeError: unsupported operand type(s) for *: 'int' and 'generator'
#Constraint 1: products k produced at plant i can't exceed M_ik, maximum quantity of product k produced at i
for j in j_range:
mdl.addConstr(
quicksum(x_ijk[i,j,k] for i in i_range for k in k_range), GRB.LESS_EQUAL, (M_ik[i,k] for i in i_range for k in k_range)
)
-
正式なコメント
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try Gurobot? -
Hi Victor,
the reason for the error is that for the RHS you define
(M_ik[i,k] for i in i_range for k in k_range)
which generates a list \(\texttt{M_ik[0,0], M_ik[1,0], M_ik[2,0], ...}\). Thus, your RHS is not defined properly. Do you mean to sum over all \(\texttt{M_ik}\)? Could you write down the constraint you want to implement? You can use MathJax as described in Posting to the Community Forum.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
2件のコメント