Skip to main content

Linearizing Max function in constraint

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Joao Coelho
    • Gurobi-versary
    • First Question
    • First Comment

    the list earliest is a parameter of my problem, not a variable

     

    0
  • Maliheh Aramon
    • Gurobi Staff

    Hi Joao, 

    Let us assume that you would like to implement a constraint in the form \(\max(x, c)\) with \(c\) being a constant value. 

    • You need to fist define an auxiliary variable \(y\)
    • You can then use the method Model.addGenConstrMax() (or general constraint helper function gurobipy.max_()) to implement the relationship \(y = \max(x, c)\). 
    • You can then use \(y\) in place of \(\max(x, c)\) in any other constraint where the \(\max\) function appears. 

    Best regards,

    Maliheh

    0

Post is closed for comments.