Binary variables
Topics covered in this section:
 Logical conditions
 Minimum values
 Maximum values
 Absolute values
 Logical AND
 Logical OR
 Logical NOT
 Product values
 Disjunctions
 Minimum activity level
 take value 0 or 1
 model a discrete decision
 yes/no
 on/off
 open/close
 build or don't build
 strategy A or strategy B
Logical conditions
Projects A, B, C, D, ... with associated binary variables a, b, c, d, ... which are 1 if we decide to do the project and 0 if we decide not to do the project.
At most N of A, B, C,...  a + b + c + ...≤ N  
At least N of A, B, C,...  a + b + c + ...≥ N  
Exactly N of A, B, C,...  a + b + c + ... = N  
If A then B  b ≥ a  
Not B  b^{} = 1b  
If A then not B  a + b ≤ 1  
If not A then B  a + b ≥ 1  
If A then B, and if B then A  a = b  
If A then B and C; A only if B and C  b ≥ a and c ≥ a  
or alternatively: a ≤ (b + c)/2  
If A then B or C  b + c ≥ a  
If B or C then A  a ≥ b and a ≥ c  
or alternatively: a ≥


If B and C then A  a ≥ b + c  1  
If two or more of B, C, D or E then A  a ≥


If M or more of N projects (B, C, D, ...) then A  a ≥

Minimum values
y = min{x_{1}, x_{2}} for two continuous variables x_{1}, x_{2}
 Must know lower and upper bounds
L_{1} ≤ x_{1} ≤ U_{1} [1.1] L_{2} ≤ x_{2} ≤ U_{2} [1.2]  Introduce binary variables d_{1}, d_{2} to mean
d_{i} 1 if x_{i} is the minimum value; 0 otherwise  MIP formulation:
y ≤ x_{1} [2.1] y ≤ x_{2} [2.2] y ≥ x_{1}  (U_{1}  L_{min})(1  d_{1}) [3.1] y ≥ x_{2}  (U_{2}  L_{min})(1  d_{2}) [3.2] d_{1} + d_{2} = 1 [4]  Generalization to y = min{x_{1}, x_{2}, ..., x_{n}}
L_{i} ≤ x_{i} ≤ U_{i} [1.i] y ≤ x_{i} [2.i] y ≥ x_{i}  (U_{i}  L_{min})(1  d_{i}) [3.i] ∑_{i} d_{i} = 1 [4]  See Section General constraints for an alternative formulation via general constraints
Maximum values
y = max{x_{1}, x_{2}, ..., x_{n}} for continuous variables x_{1}, ..., x_{n}
 Must know lower and upper bounds
L_{i} ≤ x_{i} ≤ U_{i} [1.i]  Introduce binary variables d_{1}, ..., d_{n}
d_{i}=1 if x_{i} is the maximum value, 0 otherwise  MIP formulation
L_{i} ≤ x_{i} ≤ U_{i} [1.i] y ≥ x_{i} [2.i] y ≤ x_{i} + (U_{max}  L_{i})(1  d_{i}) [3.i] ∑_{i} d_{i} = 1 [4]  See Section General constraints for an alternative formulation via general constraints
Absolute values
y =  x_{1}  x_{2} for two variables x_{1}, x_{2} with 0 ≤ x_{i} ≤ U
 Introduce binary variables d_{1}, d_{2} to mean
d_{1} : 1 if x_{1}  x_{2} is the positive value d_{2} : 1 if x_{2}  x_{1} is the positive value  MIP formulation
0 ≤ x_{i} ≤ U [1.i] 0 ≤ y  (x_{1}x_{2}) ≤ 2 · U · d_{2} [2] 0 ≤ y  (x_{2}x_{1}) ≤ 2 · U · d_{1} [3] d_{1} + d_{2} = 1 [4]  See Section General constraints for an alternative formulation via general constraints
Logical AND
d = min {d_{1}, d_{2}} for two binary variables d_{1}, d_{2}, or equivalently
d = d_{1} · d_{2} (see Section Product values), or
d = d_{1} AND d_{2} as a logical expression
 IP formulation
d ≤ d_{1} [1.1] d ≤ d_{2} [1.2] d ≥ d_{1} + d_{2}  1 [2] d ≥ 0 [3]  Generalization to d = min {d_{1}, d_{2}, ..., d_{n}}
d ≤ d_{i} [1.i] d ≥ ∑_{i} d_{i}  (n  1) [2] d ≥ 0 [3]
and (as a logical expression): d = d_{1} AND d_{2} AND ... AND d_{n}  See Section Boolean variables for an alternative formulation via Boolean variables
Logical OR
d = max {d_{1}, d_{2}} for two binary variables d_{1}, d_{2}, or
d = d_{1} OR d_{2} as a logical expression
 IP formulation
d ≥ d_{1} [1.1] d ≥ d_{2} [1.2] d ≤ d_{1} + d_{2} [2] d ≤ 1 [3]  Generalization to d = max {d_{1}, d_{2} , ..., d_{n}}
d ≥ d_{i} [1.i] d ≤ ∑_{i} d_{i} [2.i] d ≤ 1 [3]  See Section Boolean variables for an alternative formulation via Boolean variables
Logical NOT
d = NOT d_{1} for one binary variable d_{1}
 IP formulation
d = 1  d_{1}
Product values
y = x · d for one continuous variable x, one binary variable d
 Must know lower and upper bounds
L ≤ x ≤ U  MIP formulation:
Ld ≤ y ≤ Ud [1] L(1  d) ≤ x  y ≤ U(1  d) [2]
Product of two binaries: d_{3} = d_{1} · d_{2}
 MIP formulation:
d_{3} ≤ d_{1} d_{3} ≤ d_{2} d_{3} ≥ d_{1} + d_{2} 1
Disjunctions
Either 5 ≤ x ≤ 10 or 80 ≤ x ≤ 100
 Introduce a new binary variable:
ifupper: 0 if 5 ≤ x ≤ 10; 1 if 80 ≤ x ≤ 100  MIP formulation:
x ≤ 10 + (100  10) · ifupper [1] x ≥ 5 + ( 80  5) · ifupper [2]
 Generalization to Either L_{1} ≤ ∑_{i} A_{i} x_{i} ≤ U_{1} or L_{2} ≤ ∑_{i} A_{i} x_{i} ≤ U_{2} (with U_{1} ≤ L_{2})
∑_{i} A_{i} x_{i} ≤ U_{1} + (U_{2}  U_{1}) · ifupper [1] ∑_{i} A_{i} x_{i} ≥ L_{1} + (L_{2}  L_{1}) · ifupper [2]
Minimum activity level
Continuous production rate make that may be 0 (the plant is not operating) or between allowed production limits MAKEMIN and MAKEMAX
 Introduce a binary variable ifmake to mean
ifmake : 0 if plant is shut 1 plant is open make ≥ MAKEMIN · ifmake [1] make ≤ MAKEMAX · ifmake [2]  The ifmake binary variable also allows us to model fixed costs
 FCOST: fixed production cost
 VCOST: variable production cost
cost = FCOST · ifmake + VCOST · make [3] make ≥ MAKEMIN · ifmake [1] make ≤ MAKEMAX · ifmake [2]
© 20012022 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.