CP
OPL keyword to specify CP.
Purpose
OPL keyword to specify that the model must be solved by the constraint programming engine.
context |
---|
Model files (.mod) - Constraint programming |
Syntax
using CP;
Description
Use
this keyword at the beginning of your model to specify that it must
be solved by the constraint programming engine. This engine can solve
models with complex combinatorial constraint such as allDifferent or allowedAssignments /
forbiddenAssignments. It uses powerful
constraint-propagation and branch-and-bound techniques.
Use the CP engine to solve scheduling problems. In the OPL Language Quick Reference manual, keywords and functions that are useful with scheduling problems contain “scheduling” in the Purpose statement and in the Keyword Summary Table.
To specify the constraint programming engine CP Optimizer, start your model with the statement
using CP;
The other engine supported by OPL is CPLEX.
Example
using CP;
int n = 5;
range R = 1..n;
dvar int x[R] in R;
subject to {
allDifferent(all (i in R : i%2 == 0) x[i] );
allDifferent(all (i in R : i%2 == 1) x[i] );
}