The Constraint Programming Solver

REIFY Predicate

  • REIFY (scalar-variable, linear-constraint)

The REIFY predicate specifies a reify constraint, which associates a binary variable with a constraint. The value of the binary variable is 1 or 0, depending on whether the constraint is satisfied or not, respectively. The constraint is said to be reified, and the binary variable is referred to as the control variable. Currently, only linear constraints can be reified.

The REIFY predicate provides a convenient mechanism for expressing logical constraints, such as disjunctive and implicative constraints. For example, the disjunctive constraint

\[ (3X + 4Y < 20) \vee (5X - 2Y > 50) \]

can be expressed by the following statements:

var X integer, Y integer,
    P binary,  Q binary;
con reify(P, 3 * X + 4 * Y < 20);
con reify(Q, 5 * X - 2 * Y > 50);
con AtLeastOneHolds: P + Q >= 1;

The binary variable P reifies the linear constraint

\[ 3X+4Y < 20 \]

The binary variable Q reifies the linear constraint

\[ 5X - 2Y > 50 \]

The following linear constraint enforces the desired disjunction:

\[ P + Q \ge 1 \]

The following implicative constraint

\[ (3X + 4Y < 20) \Rightarrow (5X - 2Y > 50) \]

can be enforced by the linear constraint

\[ P \le Q \]

You can also use the REIFY constraint to express a constraint that involves the absolute value of a variable. For example, the constraint

\[ |X| = 5 \]

can be expressed by the following statements:

var X integer, P binary, Q binary;
con Xis5:      reify(P, X = 5);
con XisMinus5: reify(Q, X = -5);
con OneMustHold: P + Q = 1;