Engine representation of constraints

Constraints in the engine are built using the decision variables in the engine.

The engine object for a constraint is an instance of IlcConstraint. Basically, a model constraint or group of constraints is extracted to an instance of IlcConstraint. To illustrate constraint extraction, consider the following model:


    IloIntVar x(env, 0, 3); 
    IloIntVar y(env, 0, 3); 
    IloModel model(env); 
    model.add(x < y); 

The code:


    IloCP cp(mode); 
    cp.propagate(); 

performs constraint propagation on the engine variables. First, it takes the constraint x < y and starts extracting it to an instance of IloCPEngine. In order to extract this constraint, it extracts the two variables x and y. The extraction of these variables creates two IlcIntVar objects: ix and iy. Then, the extraction of the constraint continues by taking the two IlcIntVar objects and creating the equivalent IlcConstraint: ix < iy. This inequality constraint is then added to the instance of IloCPEngine. Then, the constraint is propagated, and domains of ix and iy are reduced. The line "cp.propagate();" creates an equivalent of the following code:


    IlcIntVar ix(cp, 0, 3); 
    IlcIntVar iy(cp, 0, 3); 
    cpEngine.add(ix < iy);