Skip to main content

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

Answered

Comments

1 comment

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

Please sign in to leave a comment.