5.9. alldifferent_except_0
| DESCRIPTION | LINKS | GRAPH | AUTOMATON |
- Origin
- Constraint
- Synonyms
, .
- Argument
- Restriction
- Purpose
Enforce all variables of the collection to take distinct values, except those variables that are assigned value 0.
- Example
-
The constraint holds since all the values (that are different from 0) 5, 1, 9 and 3 are distinct.
- Typical
- Symmetries
Items of are permutable.
Two distinct values of that are both different from 0 can be swapped; a value of that is different from 0 can be renamed to any unused value that is also different from 0.
- Usage
Quite often it appears that, for some modelling reason, you create a joker value. You do not want that normal constraints hold for variables that take this joker value. For this purpose we modify the binary arc constraint in order to discard the vertices for which the corresponding variables are assigned value 0. This will be effectively the case since all the corresponding arcs constraints will not hold.
- See also
- Keywords
characteristic of a constraint: joker value, all different, automaton, automaton with array of counters.
- Arc input(s)
- Arc generator
-
- Arc arity
- Arc constraint(s)
-
- Graph property(ies)
-
- Graph model
The graph model is the same as the one used for the constraint, except that we discard all variables that are assigned value 0.
PartsΒ (A) andΒ (B) of FigureΒ 5.9.1 respectively show the initial and final graph associated with the Example slot. Since we use the graph property we show one of the largest strongly connected component of the final graph. The holds since all the strongly connected components have at most one vertex: a value different from 0 is used at most once.
Figure 5.9.1. Initial and final graph of the constraint


(a) (b)
- Automaton
FigureΒ 5.9.2 depicts the automaton associated with the constraint. To each variable of the collection corresponds a 0-1 signature variable . The following signature constraint links and : . The automaton counts the number of occurrences of each value different from 0 and finally imposes that each non-zero value is taken at most one time.
Figure 5.9.2. Automaton of the constraint
