The Constraint Programming Solver (Experimental)

Common Syntax Components

The following syntax components are used in multiple predicates. They depend on the definition of an identifier-exprression. For more information, see the section Identifier Expressions in ChapterĀ 5: The OPTMODEL Procedure. For information about other syntactic components, see the section that describes the corresponding predicate.

data-list


is a space-separated list of items, each of which can be prefixed by an indexing set and conforms to one of the following syntaxes:

  • a number

  • an identifier-expression , but excluding suffixes

  • the name of a numeric array

  • ( expression ), which must evaluate to a number

For example, the first three constraints in the following statements refer to valid data-lists, whereas the last four do not. Each incorrect constraint is preceded by a comment that explains why the constraint is incorrect.

var X integer, Y integer, Z integer;
num n;
con CorrectDataList1:   element(X, 1 2 3 4, Y);
con CorrectDataList2:   element(X, 1 2 3 4 n, Y);
con CorrectDataList3:   element(X, {i in 1..4} i n, Y);
/* The parenthesis imply a scalar expression */
con IncorrectDataList1: element(X, ({i in 1..4} i) n, Y);
/* [1 2 3 4] is an array initializer, not an array name */
con IncorrectDataList2: element(X, [1 2 3 4], Y);
/* Z is a variable */
con IncorrectDataList3: element(X, 1 2 3 4 Z, Y);
/* Impossible to distinguish Z.sol from [ Z . sol ] */
con IncorrectDataList4: element(X, 1 2 3 4 Z.sol, Y);
scalar-variable


is an identifier-expression that refers to a single variable (that is, not to an array of variables).

variable-list


is a space-separated list of identifier-expressions , each of which can be prefixed by an indexing set and must resolve to a variable or a variable array. For example, the first three constraints in the following statements refer to valid variable-lists, whereas the last four do not. Each incorrect constraint is preceded by a comment that explains why the constraint is incorrect.

var X{1..3} integer, A integer, B integer;
con CorrectVariableList1: alldiff({j in 1..3} X[j]);
con CorrectVariableList2: alldiff(A B);
con CorrectVariableList3: alldiff({j in 1..3} X[j] A B);
/* Indexing is not distributive in variable lists */
var Y{1..3} integer;
con IncorrectVariableList1: alldiff({j in 1..3} (X[j] Y[j]));
/* literals or expressions are not allowed in variable lists */
con IncorrectVariableList2: alldiff(1 A B);
/* literals or expressions are not allowed in variable lists */
con IncorrectVariableList3: alldiff(A.dual B);
/* you must refer only to variables */
num n;
con IncorrectVariableList4: alldiff(A B n);