Formulation of the $k$ biggest elements in a set

26 Views Asked by At

I consider a set $D = \{d_1,\dots, d_j,\dots, d_n\}$.

How can I express $M_j$ such that $M_j = d_j$ if $j \in M$ and $M_j = 0$ otherwise?
WHERE the set $M\sqsubseteq J$ the $k$ biggest elements of $D$ (i.e. $\max_{j \in J \setminus \{M \}} d_j \leq \min_{j \in M: |M| = k} d_j $.

$M_j$ is a term which will belong to the constraint $j$.

Thank you.

1

There are 1 best solutions below

0
On

Introduce a binary decision variable $x_j$ to indicate whether $j \in M$. Let $L = \min_j d_j$ and $U = \max_j d_j$. The constraints are: \begin{align} \sum_j x_j &= k \\ M_j &= d_j x_j &&\text{for all $j$}\\ L x_i + d_i(1-x_i) &\le d_j x_j + U(1-x_j) &&\text{for all $i$ and $j$}\\ \end{align} The third constraint enforces $(\neg x_i \land x_j) \implies d_i \le d_j$.