Search code examples
mathematical-optimizationlinear-programming

if A>0 then b=1 else b=0


i would like to formulate a problem in linear programming and i cannot seem to be able to do it. The problem is: If A>0 then b=1 else(if A=0) then b=0,

where b is a binary variable and A>=0(integer).

Any suggestions/recommendations?


Solution

  • Assuming:

    • A is a scalar (notation using A is not great)
    • A is bounded from above by constant M-1

    Constraints:

    (1) A <= M * b
    (2) b <= M * A
    

    Check:

    A = 2
        (1) b = 1
        (2) b free
    
    A = 0
        (1) b free
        (2) b = 0
    
    b = 1
        (1) A free 
        (2) A > 0
    
    b = 0
        (1) A = 0
        (2) A free
    

    This pretty much follows:

    • the usual indicator-constraints approach like presented here @ page 2
    • Propositional calculus:
      • x == y <-> (x -> y) & (y -> x)