Skip to main content

Does the abs_() function keep the problem a MILP?

Answered

Comments

2 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.
  • Jue Xue
    • Gurobi Staff

    Hi Carmel,

     

    Thank you for participating in Gurobi forum and contacting us.

     

    Using abs_() will not hurt the linearity of your MILP.

     

    If you want to know how this may work internally, I will explain it below. Note: you do not need to add any of the constraints below to your model. You may use the 'abs(.)' construct instead.

     

    Let z be a binary variable and M be a big constant (say, >= 2max{|x|}):

    1. use the following inequalities to ensure z = 1 if x >= 0, and z = 0 if x <= 0:
      • zM >= x >= (z-1)M
    2. Create two new inequalities:
      • (1-z)M >= y-x >= (z-1)M
      • zM >= y+x >= -zM

    Then, the above set of linear inequalities is equivalent to y = |x|. I assume you prefer to validate yourself. 

    0

Post is closed for comments.