Reification: OnlyEnforceIf
Use the OnlyEnforceIf method to conditionally activate constraints via a Boolean indicator, build full reifications by combining two half-reifications, and encode logical implications between constraints.
Tutorial
Half-Reification with OnlyEnforceIf
Many CP solvers (e.g., OR-Tools CP-SAT) let us conditionally activate a constraint via a Boolean indicator. Given a constraint and a Boolean variable , attaching \texttt{OnlyEnforceIf(b)} to imposes the rule
When , the constraint is deactivated — it places no restriction on the model. This is called half-reification: the implication runs in one direction only. Even if happens to be satisfied, is not forced to .
For example, with and Boolean , the statement
admits the following assignments:
- : feasible — forces , and satisfies it.
- : feasible — deactivates the constraint.
- : feasible — deactivates the constraint, even though happens to hold.
- : infeasible — requires , but violates it.
Notice that nothing in the model forces to be when . Half-reification is strictly one-way.