Skip to main content

How to handle Abs constraints ?

Comments

3 comments

  • Official comment
    Simranjit Kaur
    Gurobi Staff 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?.
  • Cris
    Gurobi-versary
    Curious
    Conversationalist

    I had the same problem using python gurobi. I had to used the firt option you said.

    model.addGenConstrAbs (x5, x1, "absconstr" ) 
    0
  • Eli Towle
    Gurobi Staff Gurobi Staff

    Note that the difference between Model.addGenConstrAbs() and Model.addConstr()abs_() is purely syntax. In both cases, you add a general constraint to the problem. There are no dual values (Pi attributes) associated with general constraints.

    For example:

    >>> c = m.addConstr(y == abs_(x))
    >>> type(c)
    <class 'gurobipy.GenConstr'>
    0

Post is closed for comments.