presenceOf

OPL constraint (scheduling) used to enforce the presence of intervals

Purpose

OPL constraint (scheduling) used to enforce the presence of intervals.

context type
Model files (.mod)
boolean

Syntax

presenceOf(a);

Where
dvar interval a;

Description

This constraint states that a certain interval must be present. It can be used in a meta-constraint; for example, there may be two optional variables a and b, but if a is present, then b must be present as well.

Example

The following code defines a chain of optional activities a1 ... an such that whenever an activity ai is abandoned (absent), all the remaining activities in the chain are also absent.

dvar interval a[i in 1..n] optional size d[i];
subject to {
  forall (i in 1..n-1) {
    endBeforeStart(a[i],a[i+1]);
    presenceOf(a[i+1]) => presenceOf(a[i]);
  }
}