- Function cp::Channel(mapBinding, map, inverseMapBinding, inverseMap)
cp::Channel
The function cp::Channel
links two arrays of variables such that
they are uniquely matched to each other. For instance, see
Fig. 1. This function is often used to model different perspectives
of the same problem.
Mathematical Formulation
The function
cp::Channel(i,x_i,j,y_j)
returns 1 if for all \(i,j\): \(x_i=j\) implies \(y_j=i\) and vice versa.cp::Channel(i,x_i,j,y_j)
is equivalent to
Function Prototype
cp::Channel( mapBinding, ! (input) an index binding map, ! (input/output) an expression inverseMapBinding, ! (input) an index binding inverseMap ! (input/output) an expression )
Arguments
- mapBinding
The index binding corresponding to the domain of the first expression
map
.- map
For each element in
mapBinding
,map
will contain an element ininverseMapBinding
. This expression may involve variables.- inverseMapBinding
The index binding corresponding to the domain of the second expression
inverseMap
.- inverseMap
For each element in
inverseMapBinding
,inverseMap
will contain an element inmapBinding
. This expression may involve variables.
Return Value
If a unique mapping between the two index bindings is created, this function returns 1. When the index bindings
mapBinding
andinverseMapBinding
are both empty, this function returns 1 as well. In all other cases, the function returns 0, e.g. when the number of possible values of index bindingmapBinding
is different from that of the index bindinginverseMapBinding
.
Note
The
cp::Channel
constraint is also referred to in the Constraint Programming literature asInverse
.The
cp::Channel
constraint can be used to implement theone_factor(i,x(i))
orsymm_AllDifferent(i,x(i))
constraints encountered in the Constraint Programming literature ascp::Channel(i,X(i),i,X(i))
.
Example
In a sports team scheduling problem, the following constraint
Constraint LinkingDuplicateView { Definition : cp::Channel( s, Games(s), g, Slots(g) ); }links the variable
Games(s)
to the variableSlots(g)
. A game is the identification number of a match between a home and an away team. A slot is the identification number of a week and a match within a week number. For each game, there is a unique slot and for each slot there is a unique game.
See also
Constraint Programming on Constraint Programming in the Language Reference.
The Global Constraint Catalog, which references this function as
inverse
.