## 5.29. among_var

Origin
Constraint

$\mathrm{\pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi }\left(\mathrm{\pi ½\pi  \pi °\pi },\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi },\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }\right)$

Arguments
 $\mathrm{\pi ½\pi  \pi °\pi }$ $\mathrm{\pi \pi \pi \pi }$ $\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)$ $\mathrm{\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)$
Restrictions
 $\mathrm{\pi ½\pi  \pi °\pi }\beta ₯0$ $\mathrm{\pi ½\pi  \pi °\pi }\beta €|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|$ $\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)$ $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }$$\left(\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi },\mathrm{\pi \pi \pi }\right)$
Purpose

$\mathrm{\pi ½\pi  \pi °\pi }$ is the number of variables of the collection $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ that are equal to one of the variables of the collection $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }$.

Example
$\left(3,β©4,5,5,4,1βͺ,β©1,5,8,1βͺ\right)$

The $\mathrm{\pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi }$ constraint holds since exactly 3 values of the collection of variables $\beta ©4,5,5,4,1\beta ͺ$ occurs within the collection $\beta ©1,5,8,1\beta ͺ$.

Typical
 $|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|>1$ $|\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }|>1$ $|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|>|\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }|$
Symmetries
• Items of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ are permutable.

• Items of $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }$ are permutable.

• All occurrences of two distinct values in $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }.\mathrm{\pi \pi \pi }$ or $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }.\mathrm{\pi \pi \pi }$ can be swapped; all occurrences of a value in $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }.\mathrm{\pi \pi \pi }$ or $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }.\mathrm{\pi \pi \pi }$ can be renamed to any unused value.

• An occurrence of a value of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }.\mathrm{\pi \pi \pi }$ that belongs to $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }.\mathrm{\pi \pi \pi }$ (resp. does not belong to $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }.\mathrm{\pi \pi \pi }$) can be replaced by any other value in $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }.\mathrm{\pi \pi \pi }$ (resp. not in $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }.\mathrm{\pi \pi \pi }$).

Arg. properties
• Functional dependency: $\mathrm{\pi ½\pi  \pi °\pi }$ determined by $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ and $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }$.

• Contractible wrt. $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ when $\mathrm{\pi ½\pi  \pi °\pi }=0$.

• Contractible wrt. $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ when $\mathrm{\pi ½\pi  \pi °\pi }=|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|$.

• Aggregate: $\mathrm{\pi ½\pi  \pi °\pi }\left(+\right)$, $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\left(\mathrm{\pi \pi \pi \pi \pi }\right)$, $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }\left(\mathrm{\pi \pi \pi \pi \pi }\right)$.

Systems

among in Choco, count in Gecode, amongvar in JaCoP.

specialisation: $\mathrm{\pi \pi \pi \pi \pi }$Β ($\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }$ replaced by $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }$ within list of $\mathrm{\pi \pi \pi \pi \pi \pi }$ $\mathrm{\pi  \pi °\pi »\pi \pi ΄\pi }$).

Keywords
Arc input(s)

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

Arc generator
$\mathrm{\pi \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 },\mathrm{\pi \pi \pi \pi \pi \pi }\right)$

Arc arity
Arc constraint(s)
$\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }.\mathrm{\pi \pi \pi }=\mathrm{\pi \pi \pi \pi \pi \pi }.\mathrm{\pi \pi \pi }$
Graph property(ies)
$\mathrm{\pi \pi \pi \pi \pi \pi \pi }$$=\mathrm{\pi ½\pi  \pi °\pi }$

Graph class
 $\beta ’$$\mathrm{\pi °\pi ²\pi \pi ²\pi »\pi Έ\pi ²}$ $\beta ’$$\mathrm{\pi ±\pi Έ\pi Ώ\pi °\pi \pi \pi Έ\pi \pi ΄}$ $\beta ’$$\mathrm{\pi ½\pi Ύ}_\mathrm{\pi »\pi Ύ\pi Ύ\pi Ώ}$

Graph model

PartsΒ (A) andΒ (B) of FigureΒ 5.29.1 respectively show the initial and final graph associated with the Example slot. Since we use the $\mathrm{\pi \pi \pi \pi \pi \pi \pi }$ graph property, the source vertices of the final graph are stressed with a double circle. Since the final graph has only 3 sources the variables $\mathrm{\pi ½\pi  \pi °\pi }$ is fixed to 3.