## 5.9. alldifferent_except_0

Origin
Constraint

$\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi ‘\pi \pi \pi \pi }_\mathtt{0}\left(\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\right)$

Synonyms

$\mathrm{\pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi ‘\pi \pi \pi \pi }_\mathtt{0}$, $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi ‘\pi \pi \pi \pi }_\mathtt{0}$.

Argument
 $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi }-\mathrm{\pi \pi \pi \pi }\right)$
Restriction
$\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }$$\left(\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi },\mathrm{\pi \pi \pi }\right)$
Purpose

Enforce all variables of the collection $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ to take distinct values, except those variables that are assigned value 0.

Example
$\left(\begin{array}{c}β©\begin{array}{c}\mathrm{\pi \pi \pi }-5,\hfill \\ \mathrm{\pi \pi \pi }-0,\hfill \\ \mathrm{\pi \pi \pi }-1,\hfill \\ \mathrm{\pi \pi \pi }-9,\hfill \\ \mathrm{\pi \pi \pi }-0,\hfill \\ \mathrm{\pi \pi \pi }-3\hfill \end{array}βͺ\hfill \end{array}\right)$

The $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi ‘\pi \pi \pi \pi }_\mathtt{0}$ constraint holds since all the values (that are different from 0) 5, 1, 9 and 3 are distinct.

Typical
 $|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|>2$ $\mathrm{\pi \pi \pi \pi \pi \pi \pi }$$\left(1,\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi },0\right)$
Symmetries
• Items of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ are permutable.

• Two distinct values of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }.\mathrm{\pi \pi \pi }$ that are both different from 0 can be swapped; a value of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }.\mathrm{\pi \pi \pi }$ 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.

Keywords
Arc input(s)

$\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$

Arc generator
$\mathrm{\pi Ά\pi Ώ\pi Ό\pi \pi \pi Έ}$$\beta ¦\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }\mathtt{1},\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }\mathtt{2}\right)$

Arc arity
Arc constraint(s)
 $\beta ’\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }\mathtt{1}.\mathrm{\pi \pi \pi }=\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }\mathtt{2}.\mathrm{\pi \pi \pi }$
Graph property(ies)
$\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi \pi }$$\beta €1$

Graph model

The graph model is the same as the one used for the $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$ 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 $\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi \pi }$ graph property we show one of the largest strongly connected component of the final graph. The $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi ‘\pi \pi \pi \pi }_\mathtt{0}$ holds since all the strongly connected components have at most one vertex: a value different from 0 is used at most once.

Automaton

FigureΒ 5.9.2 depicts the automaton associated with the $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi ‘\pi \pi \pi \pi }_\mathtt{0}$ constraint. To each variable ${\mathrm{\pi  \pi °\pi }}_{i}$ of the collection $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ corresponds a 0-1 signature variable ${\mathrm{\pi }}_{i}$. The following signature constraint links ${\mathrm{\pi  \pi °\pi }}_{i}$ and ${\mathrm{\pi }}_{i}$: . 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.