5.142. global_cardinality_with_costs
| DESCRIPTION | LINKS | GRAPH |
- Origin
- Constraint
- Synonyms
, .
- Arguments
- Restrictions
- Purpose
Each value should be taken by exactly variables of the collection. In addition the of an assignment is equal to the sum of the elementary costs associated with the fact that we assign the variable of the collection to the value of the collection. These elementary costs are given by the collection.
- Example
-
The constraint holds since:
Values 3, 5 and 6 respectively occur 3, 0 and 1 times within the collection .
The argument corresponds to the sum of the costs respectively associated with the first, second, third and fourth items of , namely 4, 1, 3 and 6.
- Typical
- Usage
A classical utilisation of the constraint corresponds to the following assignment problem. We have a set of persons as well as a set of jobs to perform. Each job requires a number of persons restricted to a specified interval. In addition each person has to be assigned to one specific job taken from a subset of . There is a cost associated with the fact that person is assigned to job . The previous problem is modelled with one single constraint where the persons and the jobs respectively correspond to the items of the and collection.
The constraint can also be used for modelling a conjunction and . For this purpose we set the domain of the variables to and the cost attribute of a variable and one of its potential value to . In practice this can be used for the magic squares and the magic hexagon problems where all the are set to 1.
- Algorithm
- Reformulation
Let and respectively denote the number of items of the and of the collections. Let denote the values . In addition let denote the values , i.e.,Β the -th line of the matrix .
By introducing auxiliary variables and , the constraint can be expressed in term of the conjunction of one constraint, constraints and one arithmetic constraint .
For each variable of the collection a first constraint provides the correspondence between the variable and the index of the value to which it is assigned. A second links the previous index to the cost variable associated with variable . Finally the total cost is equal to the sum .
In the context of the Example slot we get the following conjunction of constraints:
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ,
Β Β Β .
- Systems
- See also
attached to cost variant: Β ( associated with each , pair removed).
common keyword: Β (cost filtering constraint,weighted assignment), , Β (weighted assignment).
implies: .
- Keywords
-
filtering: cost filtering constraint.
modelling: cost matrix, scalar product.
For all items of :
- Arc input(s)
- Arc generator
-
- Arc arity
- Arc constraint(s)
- Graph property(ies)
-
- Arc input(s)
- Arc generator
-
- Arc arity
- Arc constraint(s)
- Graph property(ies)
-
- Graph model
The first graph constraint enforces each value of the collection to be taken by a specific number of variables of the collection. It is identical to the graph constraint used in the constraint. The second graph constraint expresses the fact that the variable is equal to the sum of the elementary costs associated with each variable -value assignment. All these elementary costs are recorded in the collection. More precisely, the cost is recorded in the attribute of the entry of the collection. This is ensured by the restriction that enforces the fact that the items of the collection are sorted in lexicographically increasing order according to attributes and .
PartsΒ (A) andΒ (B) of FigureΒ 5.142.1 respectively show the initial and final graph associated with the second graph constraint of the Example slot.
Figure 5.142.1. Initial and final graph of the constraint


(a) (b)