5.266. minimum_weight_alldifferent
DESCRIPTION | LINKS | GRAPH |
- Origin
- Constraint
- Synonyms
, , , , .
- Arguments
- Restrictions
- Purpose
All variables of the collection should take a distinct value located within interval . In addition is equal to the sum of the costs associated with the fact that we assign value to variable . These costs are given by the matrix .
- Example
-
The constraint holds since the cost 17 corresponds to the sum .
- All solutions
FigureΒ 5.266.1 gives all solutions to the following non ground instance of the constraint:
Β Β Β Β , , , , , , ,
Β Β Β Β ,
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ,Β
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ,Β
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ,Β
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ,Β
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ,Β
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β .
Figure 5.266.1. All solutions corresponding to the non ground example of the constraint of the All solutions slot
- Typical
- Arg. properties
Functional dependency: determined by and .
- Algorithm
The Hungarian method for the assignment problemΒ [Kuhn55] can be used for evaluating the bounds of the variable. A filtering algorithm is described inΒ [Sellmann02]. It can be used for handling both side of the constraint:
Evaluating a lower bound of the variable and pruning the variables of the collection in order to not exceed the maximum value of .
Evaluating an upper bound of the variable and pruning the variables of the collection in order to not be under the minimum value of .
- Systems
all_different in SICStus, all_distinct in SICStus.
- See also
-
common keyword: Β (cost filtering constraint,weighted assignment), Β (weighted assignment), Β (cost filtering constraint,weighted assignment).
- Keywords
-
characteristic of a constraint: core.
filtering: cost filtering constraint, Hungarian method for the assignment problem.
final graph structure: one_succ.
- Arc input(s)
- Arc generator
-
- Arc arity
- Arc constraint(s)
- Graph property(ies)
-
- Graph model
Since each variable takes one value, and because of the arc constraint , each vertex of the initial graph belongs to the final graph and has exactly one successor. Therefore the sum of the out-degrees of the vertices of the final graph is equal to the number of vertices of the final graph. Since the sum of the in-degrees is equal to the sum of the out-degrees, it is also equal to the number of vertices of the final graph. Since , each vertex of the final graph belongs to a circuit. Therefore each vertex of the final graph has at least one predecessor. Since we saw that the sum of the in-degrees is equal to the number of vertices of the final graph, each vertex of the final graph has exactly one predecessor. We conclude that the final graph consists of a set of vertex-disjoint elementary circuits.
Finally the graph constraint expresses 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 that the items of the collection are sorted in lexicographically increasing order according to attributes and .
Figure 5.266.2. Initial and final graph of the constraint
(a) (b) PartsΒ (A) andΒ (B) of FigureΒ 5.266.2 respectively show the initial and final graph associated with the Example slot. Since we use the graph property, the arcs of the final graph are stressed in bold. We also indicate their corresponding weight.