How can I add a parameter into the the constraint?
AnsweredI am trying to solve the following generalized assignment problem in Gurobi. I managed to solve the problem when bij is =1 which is a simple assignment problem. Now I am trying to solve the generalized assignment problem when bij (capacity consumption values) has different values, but I got stuck in adding this bij parameter into the constraints. I think, I should firstly define bij (but not quite sure how to), then put into the Resource1 and Resource2 constraints, something like that, but it did not work.
Resource1 = m.addConstrs((x.sum('Resource1', '*')*b(i,j) for i in I for j in J<=5 ), 'Resource1')
-
Hi Merve,
You could use the quicksum function to model these 2 constraints as
Resource1 = m.addConstr( quicksum( x['Resource1',i] * mh['Resource1',i] for i in I ) <= 5 , name="Resource1" )
Resource2 = m.addConstr( quicksum( x['Resource2',i] * mh['Resource2',i] for i in I ) <= 12 , name="Resource2" )You can access the values of \(\texttt{mh}\) via the \(\texttt{[]}\) operator and the corresponding key given in the \(\texttt{matching}\) list. Thus, \(\texttt{mh['Resource1‘,'item1‘]}\) provides the integer 3.
Best regards,
Jaromił1 -
This is great! I obtained exactly what I wanted. Thank you very much.
Kind regards,
Merve
0
Please sign in to leave a comment.
Comments
2 comments