Programming tips

Tips for writing efficient constraint propagators are provided.

All modifications made to decision variables inside a propagator are buffered. This means that the changes you make to variable domains are not visible inside the propagator, but are recorded and applied when the propagator exits. Your code needs be aware of this if it examines the domain of a variable after modifying it. For example, the following code will not cause the assertion to fail, but the lower bound of the decision variable will be set to one greater than its current value when the execute function of the propagator exits.


void BufferConstraintI::execute () {
    IloInt min = getMin(_x);
    setMin(_x, min + 1);
    assert(getMin(_x) == min);
}