Element expressions
Element expressions index arrays by decision variables.
An element expression indexes an array of values by a decision variable. In other words, it allows you to treat the index into an array as a decision variable, as something that can be constrained.
This kind of constrained indexing is conventionally expressed in other disciplines by a very large number of binary (0-1) or Boolean variables. However, in CP Optimizer this indirect relation can be stated straight forwardly and efficiently as an expression that can appear in constraints.
For example, in a logistics model you might use an element expression in a constraint to index products available in warehouses. Or in a sports scheduling application, your model might include two arrays, both listing all teams. An element expression might appear in constraints between the two arrays to enforce which teams play each other.
In the C++ API of CP Optimizer, the global
function IloElement has many signatures
that enable you to build element expressions. The index operator, operator[], allows you to index an array of integers
or constrained integer variables using a constrained integer variable.
In the Java™ API of
CP Optimizer, the methods IloCP.element allow
you to build element expressions. See the example Steelmill.java for
a sample of this expression in an application.
Likewise, in the C# API of CP Optimizer,
the methods CP.Element represent element
expressions. For samples of this expression, see Teambuilding.cs, Facility.cs, or Steelmill.cs.