• Gurobi Staff

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ł

This is great! I obtained exactly what I wanted. Thank you very much.

Kind regards,

Merve