number of occurrences of specific values constraint

79 Views Asked by At

I am dealing with an optimization problem near the bin packing problem

I have $y_i$ where $i = 1, 2, 3, ... , 9$ as a decision variable y can take value of $1$ or $2$ or $3$

so if the solution $S = [y_1, y_2, y_3, ..., y_9]$ (as an example : $S = [3, 2, 3, 3, 2, 1, 1, 2, 1]$)

and $S_j = [y_1, y_2, ..., y_j]$ where $j = 2, 3, ..., 9$, ($S_9 = S$), (as an example : $S_2 = [3, 2], S_5 = [3, 2, 3, 3, 2]$

I have to make a condition that for any $S_j$, the number of occurrences of the value $3, (n(3)),$ is bigger than or equal those of value $2$ which are bigger than of those of value $1$

for any $S_j : n(3) \geq n(2) \geq n(1)$

in other words $y$ can't take the value of $2$ until a previous $y$ (not necessarily the preceding $y$) took the value of $3$ and so on

so the number of $ys$ taking value of $2$ can't exceed the number of $ys$ taking the value of $3$

and also the number of $ys$ taking the value of $1$ can't exceed the number of $ys$ already taking the value of $2$

so how can these be expressed in terms of $y$ using any transformation or other thing I don't know

thank you for your help

1

There are 1 best solutions below

1
On BEST ANSWER

For $i\in\{1,\dots,9\}$ and $k\in\{1,2,3\}$, let binary decision variable $x_{i,k}$ indicate whether $y_i=k$. Impose linear constraints \begin{align} \sum_k x_{i,k} &= 1 &&\text{for all $i$}\\ \sum_k k x_{i,k} &= y_i &&\text{for all $i$}\\ \sum_{i=1}^j x_{i,k} &\ge \sum_{i=1}^j x_{i,k-1} &&\text{for $j\in\{2,\dots,9\}$ and $k\in\{2,3\}$} \end{align}