Skip to main content

Python API: Using single component of a MVar object in a non-matrix constraint

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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 our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff

    Hi Marco,

    You could try to convert the \(\texttt{MVar}\) object to a nested list of Var objects via

    mvars = m.addMVar(10, name="myMVars")
    mvars_as_vars = mvars.tolist()
    m.addGenConstrPWL(mvars_as_vars[0], mvars_as_vars[1], [0,1,2], [1.5,0,3], "myPWLConstr")

    You will have to use the latest version of Gurobi to make it work as described above.

    Best regards,
    Jaromił

    0
  • Marco Corrao
    • Gurobi-versary
    • First Comment
    • First Question

    Great, this works! Thanks a lot for your help.

    Best

    Marco

    0

Post is closed for comments.