How to specify an IF-THEN constraint with an Integer Linear Programming (ILP) solver

Problem :

    For example:  if (A > 0) then B >= 0.
    (Note that "<=" denotes "less than or equal".)

Answer :

if (A > 0) then B >= 0
==> 
        ( A > 0 and B >= 0 ) or ( A <= 0 )

==> 
        ( 0 < A and 0 <= B ) or ( A <= 0 )

==>
        0 < A + M1*y                ........ (1)
        0 <= B + M2*y              ........ (2)
        A <= 0 + M3*(1-y)        ........ (3)
        where y = {0, 1}

        Note that y is a binary variable, that is, y = {0, 1}. In addition, M1, M2, and M3 are constants whose values should be large enough.
        If y=0, then (A > 0 and B >= 0) and constraint (3) is redundant.
        If y=1, then constraints (1) and (2) are redundant.

==>    /* constraint (1) can be removed */
        0 <= B + M2*y              ........ (4)
        A <= 0 + M3*(1-y)        ........ (5)
        where y = {0, 1}

        Note that y is a binary variable, that is, y = {0, 1}. In addition, M2 and M3 are constants whose values should be large enough.
        According to (5), if A > 0, then y=0 and thus B >= 0.
        If (A > 0) is not satisfied, then y=0 or y=1. Therefore, B is unrestricted.

  


last update: May 29, 2009