linear-programminggurobimixed-integer-programming

How to use inidicator constraints with multiple boolean conditions - Gurobi


I regularly use indicator constraints, is there an easy way to write (e.g.) : if z1 and z2 (boolean) are both true then a particular constraint holds. So essentially use indicator constraints with a series of boolean logic


Solution

  • Directly, am not sure you can do, however, if you want to express:

    z1 == 1 AND z2 == 1 ==> constraint_holds
    

    introduce another auxiliary binary variable z3, and state the following constraint:

    z3 == AND(z1, z2)
    

    and then you can use z3 as:

    z3 == 1 ==> constraint_holds