Conditional constraints

Shows how to define conditional constraints in OPL.

If-then-else statements make it possible to state constraints conditionally, as in:


if ( d>1 ) {
  abs(freq[f] - freq[g]) >= d;
} else {
  freq[f] == freq[g];
} 

Conditions in if-else statements must be ground; that is, they must not contain decision variables. Also, the if block should not contain forall statements such as:

if (..) {
  forall(...)
    ...
} 

Implications of constraints can be used instead when conditions contain decision variables. Conditionals can also be used in OPL to make different choices according to the truth value of a condition.