Statements
Statements in a CPO file define the problem to be solved (variables, expressions, constraints and so on).
There are four types of statements, all of them are semicolon terminated:

Statement "identifier = expression;"
This statement assigns a name to the given expression so that it can be used
later by that name. The expression can be of any type. It is possible to assign
a name to constants, compound expressions, and constraints. Note that
if the expression is a constraint or boolExpr then this statement does not
require the constraint to be true as in the following example:
// Declare integer variables x, y a z with domains {0..10}
x = intVar(0..10);
y = intVar(0..10);
z = intVar(0..10);
// Name some Boolean expressions, but do not enforce them:
condition1 = (x < 5);
condition2 = (y > 10);
condition3 = (z == 20);
// Require that condition1 or condition2 is true:
condition1 || condition2;
// Require that condition2 and condition3 take opposite truth values:
condition2 != condition3;
Use statement identifier = expression; to declare variables and common
expressions that are going to be used multiple times.
Note that the declaration of a variable as described here
is a special case of the statement identifier = expression;.
Aliasing
If an expression already has a name name then the statement identifier =
name; assigns it a second name. The second name is called an
alias. For example y is an alias for variable x in the following
code:
x = intVar(1..10);
y = x;
y > 5;
CP Optimizer remembers aliases however when exporting the model it prefers not to use them (unless they are used as KPIs). For example the code above, when exported, is rewritten as:
x = intVar(1..10);
x > 5;
y = x;
Statement "constraint;"
This statement can be used only for expressions of type constraint and
boolExpr. It express a requirement to satisfy the constraint in every
solution.
Example
z == x + y; // Require that z = x + y. Note == instead of =.
alldiff([x, y, z]); // Require that x!=y, y!=z and x!=z
The following code contains an error because x has type intVar:
x = intVar(1..7);
x; // Error: the expression type is intVar.
Statement "identifier: constraint;"
This statement also express that the given constraint or boolExpr must be satisfied.
Additionally it also assigns a name to the constraint.
Example
"Max capacity": x + y + z < 100;
Statement "objective;"
This statement gives CP Optimizer a way to compare different solutions. CP
Optimizer then searches for a solution with the best value(s) according to the
criteria given in the particular objective. This statement can be used only once.
Example
In the following example we are searching for a solution such that the bigger
of the values x, y is minimal:
x = intVar(0..100);
y = intVar(0..100);
minimize(max(x, y));