## 5.7. all_equal_peak_max

Origin
Constraint

$\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}_\mathrm{𝚙𝚎𝚊𝚔}_\mathrm{𝚖𝚊𝚡}\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}\right)$

Argument
 $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ $\mathrm{𝚌𝚘𝚕𝚕𝚎𝚌𝚝𝚒𝚘𝚗}\left(\mathrm{𝚟𝚊𝚛}-\mathrm{𝚍𝚟𝚊𝚛}\right)$
Restrictions
 $|\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}|>0$ $\mathrm{𝚛𝚎𝚚𝚞𝚒𝚛𝚎𝚍}$$\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂},\mathrm{𝚟𝚊𝚛}\right)$
Purpose

A variable ${V}_{k}$ $\left(1 of the sequence of variables $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}={V}_{1},\cdots ,{V}_{m}$ is a peak if and only if there exists an $i$ $\left(1 such that ${V}_{i-1}<{V}_{i}$ and ${V}_{i}={V}_{i+1}=\cdots ={V}_{k}$ and ${V}_{k}>{V}_{k+1}$.

Enforce all the peaks of the sequence $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ to be assigned the same value, i.e. to be located at the same altitude corresponding to the maximum value of the sequence $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$.

Example
$\left(〈1,5,5,4,3,5,2,5〉\right)$

The $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}_\mathrm{𝚙𝚎𝚊𝚔}_\mathrm{𝚖𝚊𝚡}$ constraint holds since the two peaks, in bold, of the sequence $15\mathbf{5}43\mathbf{5}25$ are located at the same altitude 5 that is also the maximum value of the sequence $15543525$. Figure 5.7.1 depicts the solution associated with the example.

##### Figure 5.7.1. Illustration of the Example slot: a sequence of eight variables ${V}_{1}$, ${V}_{2}$, ${V}_{3}$, ${V}_{4}$, ${V}_{5}$, ${V}_{6}$, ${V}_{7}$, ${V}_{8}$ respectively fixed to values 1, 5, 5, 4, 3, 5, 2, 5 and its corresponding two peaks, in red, both located at altitude 5 that also corresponds to the maximum value of the sequence Note that the $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}_\mathrm{𝚙𝚎𝚊𝚔}_\mathrm{𝚖𝚊𝚡}$ constraint does not enforce that the sequence $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ contains at least one peak.

Typical
 $|\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}|\ge 5$ $\mathrm{𝚛𝚊𝚗𝚐𝚎}$$\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}.\mathrm{𝚟𝚊𝚛}\right)>1$ $\mathrm{𝚙𝚎𝚊𝚔}$$\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}.\mathrm{𝚟𝚊𝚛}\right)\ge 2$
Symmetries
• Items of $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ can be reversed.

• One and the same constant can be added to the $\mathrm{𝚟𝚊𝚛}$ attribute of all items of $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$.

Arg. properties
• Prefix-contractible wrt. $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$.

• Suffix-contractible wrt. $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$.

Counting
 Length ($n$) 2 3 4 5 6 7 8 Solutions 9 64 605 6707 81648 1065542 14829903

Number of solutions for $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}_\mathrm{𝚙𝚎𝚊𝚔}_\mathrm{𝚖𝚊𝚡}$: domains $0..n$  Keywords
Cond. implications

$•$ $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}_\mathrm{𝚙𝚎𝚊𝚔}_\mathrm{𝚖𝚊𝚡}\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}\right)$

with  $\mathrm{𝚙𝚎𝚊𝚔}$$\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}.\mathrm{𝚟𝚊𝚛}\right)>1$

implies $\mathrm{𝚜𝚘𝚖𝚎}_\mathrm{𝚎𝚚𝚞𝚊𝚕}$$\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}\right)$.

$•$ $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}_\mathrm{𝚙𝚎𝚊𝚔}_\mathrm{𝚖𝚊𝚡}\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}\right)$

with  $\mathrm{𝚙𝚎𝚊𝚔}$$\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}.\mathrm{𝚟𝚊𝚛}\right)>0$

implies $\mathrm{𝚗𝚘𝚝}_\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}$$\left(\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}\right)$.

Automaton

Figure 5.7.2 depicts the automaton associated with the $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}_\mathrm{𝚙𝚎𝚊𝚔}_\mathrm{𝚖𝚊𝚡}$ constraint. To each pair of consecutive variables $\left({\mathrm{𝚅𝙰𝚁}}_{i},{\mathrm{𝚅𝙰𝚁}}_{i+1}\right)$ of the collection $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ corresponds a signature variable ${S}_{i}$. The following signature constraint links ${\mathrm{𝚅𝙰𝚁}}_{i}$, ${\mathrm{𝚅𝙰𝚁}}_{i+1}$ and ${S}_{i}$: $\left({\mathrm{𝚅𝙰𝚁}}_{i}<{\mathrm{𝚅𝙰𝚁}}_{i+1}⇔{S}_{i}=0\right)\wedge \left({\mathrm{𝚅𝙰𝚁}}_{i}={\mathrm{𝚅𝙰𝚁}}_{i+1}⇔{S}_{i}=1\right)\wedge \left({\mathrm{𝚅𝙰𝚁}}_{i}>{\mathrm{𝚅𝙰𝚁}}_{i+1}⇔{S}_{i}=2\right)$.

##### Figure 5.7.2. Automaton for the $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}_\mathrm{𝚙𝚎𝚊𝚔}_\mathrm{𝚖𝚊𝚡}$ constraint; note the conditional transition from state $k$ to state $j$ testing that the counter $\mathrm{𝐴𝑙𝑡𝑖𝑡𝑢𝑑𝑒}$ is equal to ${\mathrm{𝚅𝙰𝚁}}_{i}$ for enforcing that all peaks are located at the same altitude; the conditional transitions from $j$ to $k$ and from $k$ to $k$ and the final check $\mathrm{𝐴𝑙𝑡𝑖𝑡𝑢𝑑𝑒}\ge {\mathrm{𝚅𝙰𝚁}}_{|\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}|}$ enforce the maximum value of the sequence $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$ to not exceed the altitude of the eventual peaks. ##### Figure 5.7.3. Hypergraph of the reformulation corresponding to the automaton of the $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚎𝚚𝚞𝚊𝚕}_\mathrm{𝚙𝚎𝚊𝚔}_\mathrm{𝚖𝚊𝚡}$ constraint where $A$ stands for the value of the counter $\mathrm{𝐴𝑙𝑡𝑖𝑡𝑢𝑑𝑒}$ (since all states of the automaton are accepting there is no restriction on the last variable ${Q}_{n-1}$) 