## 5.318. peak

Origin
Constraint

$\mathrm{\pi \pi \pi \pi }\left(\mathrm{\pi ½},\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\right)$

Arguments
 $\mathrm{\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)$
Restrictions
 $\mathrm{\pi ½}\beta ₯0$ $2*\mathrm{\pi ½}\beta €\mathrm{\pi \pi \pi ‘}\left(|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|-1,0\right)$ $\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

A variable ${V}_{k}$ $\left(1 of the sequence of variables $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }={V}_{1},\beta ―,{V}_{m}$ is a peak if and only if there exists an $i$ (with $1) such that ${V}_{i-1}<{V}_{i}$ and ${V}_{i}={V}_{i+1}=\beta ―={V}_{k}$ and ${V}_{k}>{V}_{k+1}$. $\mathrm{\pi ½}$ is the total number of peaks of the sequence of variables $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$.

Example
 $\left(2,β©1,1,4,8,6,2,7,1βͺ\right)$ $\left(0,β©1,1,4,4,4,6,7,7βͺ\right)$ $\left(4,β©1,5,4,9,4,6,2,7,6βͺ\right)$

The first $\mathrm{\pi \pi \pi \pi }$ constraint holds since the sequence $11486271$ contains two peaks that respectively correspond to the variables that are assigned to values 8 and 7.

All solutions

FigureΒ 5.318.2 gives all solutions to the following non ground instance of the $\mathrm{\pi \pi \pi \pi }$ constraint: $\mathrm{\pi ½}\beta \left[1,2\right]$, ${V}_{1}\beta \left[1,2\right]$, ${V}_{2}=2$, ${V}_{3}\beta \left[1,2\right]$, ${V}_{4}\beta \left[1,2\right]$, ${V}_{5}\beta \left[2,3\right]$, $\mathrm{\pi \pi \pi \pi }$$\left(\mathrm{\pi ½},\beta ©{V}_{1},{V}_{2},{V}_{3},{V}_{4},{V}_{5}\beta ͺ\right)$.

Typical
 $|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|>2$ $\mathrm{\pi \pi \pi \pi \pi }$$\left(\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }.\mathrm{\pi \pi \pi }\right)>1$
Symmetries
• Items of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ can be reversed.

• One and the same constant can be added to the $\mathrm{\pi \pi \pi }$ attribute of all items of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$.

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

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

Usage

Useful for constraining the number of peaks of a sequence of domain variables.

Remark

Since the arity of the arc constraint is not fixed, the $\mathrm{\pi \pi \pi \pi }$ constraint cannot be currently described with the graph-based representation. However, this would not hold anymore if we were introducing a slot that specifies how to merge adjacent vertices of the final graph.

Counting
 Length ($n$) 2 3 4 5 6 7 8 Solutions 9 64 625 7776 117649 2097152 43046721

Number of solutions for $\mathrm{\pi \pi \pi \pi }$: domains $0..n$

Length ($n$)2345678
Total9646257776117649209715243046721
 Parameter value

095029517921108869498439791
1-1433053137352894443011654622
2---67133033101092224895038
3-----723026057270

Solution count for $\mathrm{\pi \pi \pi \pi }$: domains $0..n$

generalisation: $\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi \pi }$Β (a tolerance parameter is added for counting only big peaks).

specialisation: $\mathrm{\pi \pi }_\mathrm{\pi \pi \pi \pi }$Β (the variable counting the number of peaks is set to 0 and removed).

Keywords
Cond. implications

$\beta ’$ $\mathrm{\pi \pi \pi \pi }\left(\mathrm{\pi ½},\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\right)$

Β Β Β  withΒ  $\mathrm{\pi ½}>0$

Β Β implies $\mathrm{\pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi }$$\left(\mathrm{\pi ½\pi  \pi °\pi »},\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\right)$

Β Β Β  whenΒ  $\mathrm{\pi ½\pi  \pi °\pi »}=2$.

$\beta ’$ $\mathrm{\pi \pi \pi \pi }\left(\mathrm{\pi ½},\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\right)$

Β Β implies $\mathrm{\pi \pi \pi \pi \pi \pi ‘\pi \pi \pi }$$\left(\mathrm{\pi ½},\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\right)$

Β Β Β  whenΒ  $\mathrm{\pi ½}=\mathrm{\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 ’}$$\left(\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }.\mathrm{\pi \pi \pi }\right)$.

Automaton

FigureΒ 5.318.3 depicts the automaton associated with the $\mathrm{\pi \pi \pi \pi }$ constraint. To each pair of consecutive variables $\left({\mathrm{\pi  \pi °\pi }}_{i},{\mathrm{\pi  \pi °\pi }}_{i+1}\right)$ of the collection $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ corresponds a signature variable ${S}_{i}$. The following signature constraint links ${\mathrm{\pi  \pi °\pi }}_{i}$, ${\mathrm{\pi  \pi °\pi }}_{i+1}$ and ${S}_{i}$: $\left({\mathrm{\pi  \pi °\pi }}_{i}<{\mathrm{\pi  \pi °\pi }}_{i+1}\beta {S}_{i}=0\right)\beta §\left({\mathrm{\pi  \pi °\pi }}_{i}={\mathrm{\pi  \pi °\pi }}_{i+1}\beta {S}_{i}=1\right)\beta §\left({\mathrm{\pi  \pi °\pi }}_{i}>{\mathrm{\pi  \pi °\pi }}_{i+1}\beta {S}_{i}=2\right)$.