Skip to main content

How can I add a parameter into the the constraint?

Answered

Comments

2 comments

  • Jaromił Najman
    Gurobi Staff 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ł

    1
  • merve özer
    Gurobi-versary
    First Comment
    First Question

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

    Kind regards,

    Merve

    0

Please sign in to leave a comment.