## 5.208. max_nvalue

 DESCRIPTION LINKS GRAPH AUTOMATON
Origin

Derived from $\mathrm{𝚗𝚟𝚊𝚕𝚞𝚎}$.

Constraint

$\mathrm{𝚖𝚊𝚡}_\mathrm{𝚗𝚟𝚊𝚕𝚞𝚎}\left(\mathrm{𝙼𝙰𝚇},\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}\right)$

Arguments
 $\mathrm{𝙼𝙰𝚇}$ $\mathrm{𝚍𝚟𝚊𝚛}$ $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ $\mathrm{𝚌𝚘𝚕𝚕𝚎𝚌𝚝𝚒𝚘𝚗}\left(\mathrm{𝚟𝚊𝚛}-\mathrm{𝚍𝚟𝚊𝚛}\right)$
Restrictions
 $\mathrm{𝙼𝙰𝚇}\ge 1$ $\mathrm{𝙼𝙰𝚇}\le |\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}|$ $\mathrm{𝚛𝚎𝚚𝚞𝚒𝚛𝚎𝚍}$$\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂},\mathrm{𝚟𝚊𝚛}\right)$
Purpose

$\mathrm{𝙼𝙰𝚇}$ is the maximum number of times that the same value is taken by the variables of the collection $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$.

Example
$\left(\begin{array}{c}3,〈\begin{array}{c}\mathrm{𝚟𝚊𝚛}-9,\hfill \\ \mathrm{𝚟𝚊𝚛}-1,\hfill \\ \mathrm{𝚟𝚊𝚛}-7,\hfill \\ \mathrm{𝚟𝚊𝚛}-1,\hfill \\ \mathrm{𝚟𝚊𝚛}-1,\hfill \\ \mathrm{𝚟𝚊𝚛}-6,\hfill \\ \mathrm{𝚟𝚊𝚛}-7,\hfill \\ \mathrm{𝚟𝚊𝚛}-7,\hfill \\ \mathrm{𝚟𝚊𝚛}-4,\hfill \\ \mathrm{𝚟𝚊𝚛}-9\hfill \end{array}〉\hfill \end{array}\right)$

In the example, values $1,4,6,7,9$ are respectively used $3,1,1,3,2$ times. So the maximum number of time $\mathrm{𝙼𝙰𝚇}$ that a same value occurs is 3. Consequently the $\mathrm{𝚖𝚊𝚡}_\mathrm{𝚗𝚟𝚊𝚕𝚞𝚎}$ constraint holds.

Symmetries
• Items of $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ are permutable.

• All occurrences of two distinct values of $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}.\mathrm{𝚟𝚊𝚛}$ can be swapped; all occurrences of a value of $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}.\mathrm{𝚟𝚊𝚛}$ can be renamed to any unused value.

Usage

This constraint may be used in order to replace a set of $\mathrm{𝚌𝚘𝚞𝚗𝚝}$ or $\mathrm{𝚊𝚖𝚘𝚗𝚐}$ constraints were one would have to generate explicitly one constraint for each potential value. Also useful for constraining the number of occurrences of the mostly used value without knowing this value in advance and without giving explicitly an upper limit on the number of occurrences of each value as it is done in the $\mathrm{𝚐𝚕𝚘𝚋𝚊𝚕}_\mathrm{𝚌𝚊𝚛𝚍𝚒𝚗𝚊𝚕𝚒𝚝𝚢}$ constraint.

Reformulation

Assume that $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ is not empty. Let $\alpha$ and $\beta$ respectively denote the smallest and largest possible values that can be assigned to the variables of the $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ collection. Let the variables ${O}_{\alpha },{O}_{\alpha +1},...,{O}_{\beta }$ respectively correspond to the number of occurrences of values $\alpha ,\alpha +1,...,\beta$ within the variables of the $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ collection. The $\mathrm{𝚖𝚊𝚡}_\mathrm{𝚗𝚟𝚊𝚕𝚞𝚎}$ constraint can be expressed as the conjunction of the following two constraints:

$\mathrm{𝚐𝚕𝚘𝚋𝚊𝚕}_\mathrm{𝚌𝚊𝚛𝚍𝚒𝚗𝚊𝚕𝚒𝚝𝚢}$ $\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂},$

$〈\mathrm{𝚟𝚊𝚕}-\alpha \mathrm{𝚗𝚘𝚌𝚌𝚞𝚛𝚛𝚎𝚗𝚌𝚎}-{O}_{\alpha },$

$\mathrm{𝚟𝚊𝚕}-\alpha +1\mathrm{𝚗𝚘𝚌𝚌𝚞𝚛𝚛𝚎𝚗𝚌𝚎}-{O}_{\alpha +1},$

$...$

$\mathrm{𝚟𝚊𝚕}-\beta \mathrm{𝚗𝚘𝚌𝚌𝚞𝚛𝚛𝚎𝚗𝚌𝚎}-{O}_{\beta }〉\right)$,

$\mathrm{𝚖𝚊𝚡𝚒𝚖𝚞𝚖}$$\left(\mathrm{𝙼𝙰𝚇},〈{O}_{\alpha },{O}_{\alpha +1},...,{O}_{\beta }〉\right)$.

See also
Keywords
Arc input(s)

$\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$

Arc generator
$\mathrm{𝐶𝐿𝐼𝑄𝑈𝐸}$$↦\mathrm{𝚌𝚘𝚕𝚕𝚎𝚌𝚝𝚒𝚘𝚗}\left(\mathrm{𝚟𝚊𝚛𝚒𝚊𝚋𝚕𝚎𝚜}\mathtt{1},\mathrm{𝚟𝚊𝚛𝚒𝚊𝚋𝚕𝚎𝚜}\mathtt{2}\right)$

Arc arity
Arc constraint(s)
$\mathrm{𝚟𝚊𝚛𝚒𝚊𝚋𝚕𝚎𝚜}\mathtt{1}.\mathrm{𝚟𝚊𝚛}=\mathrm{𝚟𝚊𝚛𝚒𝚊𝚋𝚕𝚎𝚜}\mathtt{2}.\mathrm{𝚟𝚊𝚛}$
Graph property(ies)
$\mathrm{𝐌𝐀𝐗}_\mathrm{𝐍𝐒𝐂𝐂}$$=\mathrm{𝙼𝙰𝚇}$

Graph model

Because of the arc constraint, each strongly connected component of the final graph corresponds to a distinct value that is assigned to a subset of variables of the $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ collection. Therefore the number of vertices of the largest strongly connected component is equal to the mostly used value.

Parts (A) and (B) of Figure 5.208.1 respectively show the initial and final graph associated with the Example slot. Since we use the $\mathrm{𝐌𝐀𝐗}_\mathrm{𝐍𝐒𝐂𝐂}$ graph property, we show the largest strongly connected component of the final graph.

##### Figure 5.208.1. Initial and final graph of the $\mathrm{𝚖𝚊𝚡}_\mathrm{𝚗𝚟𝚊𝚕𝚞𝚎}$ constraint (a) (b)
Automaton

Figure 5.208.2 depicts the automaton associated with the $\mathrm{𝚖𝚊𝚡}_\mathrm{𝚗𝚟𝚊𝚕𝚞𝚎}$ constraint. To each item of the collection $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ corresponds a signature variable ${𝚂}_{i}$ that is equal to 0.

##### Figure 5.208.2. Automaton of the $\mathrm{𝚖𝚊𝚡}_\mathrm{𝚗𝚟𝚊𝚕𝚞𝚎}$ constraint 