Skip to main content
added 18 characters in body
Source Link
Sutanu Majumdar
  • 3.6k
  • 1
  • 3
  • 12

First you may need to sort your optimization variables. Taking idea from Dr. Kalvelagen (link) & YALMIP define additional continuous variablesvariable $0 \le x,z,$$0 z$, $x$ of same domain s $y$ & $i \times i$ matrix of binary variables $p$

Basically
$x_i = p_{i,j}x_i$

$\sum_i z_{i,j} = y_j \quad \forall j$
$\sum_j z_{i,j} = x_i \quad \forall i$
$\sum_i p_{i,j} = 1$
$\sum_j p_{i,j} = 1$
$x_i \le x_{i+1}$
$z_{i,j} \le Mp_{i,j}$

Median = $x_{I+1\over2}$ if $I$ or $J$ is odd, else ${x_{k}+x_{k+1}}\over 2$ where $k={{I+1}\over2}$$k={{I}\over2}$

First you may need to sort your optimization variables. Taking idea from Dr. Kalvelagen (link) & YALMIP define additional continuous variables $0 \le x,z,$ & $i \times i$ matrix of binary variables $p$

Basically
$x_i = p_{i,j}x_i$

$\sum_i z_{i,j} = y_j \quad \forall j$
$\sum_j z_{i,j} = x_i \quad \forall i$
$\sum_i p_{i,j} = 1$
$\sum_j p_{i,j} = 1$
$x_i \le x_{i+1}$
$z_{i,j} \le Mp_{i,j}$

Median = $x_{I+1\over2}$ if $I$ or $J$ is odd, else ${x_{k}+x_{k+1}}\over 2$ where $k={{I+1}\over2}$

First you may need to sort your optimization variables. Taking idea from Dr. Kalvelagen (link) & YALMIP define additional continuous variable $0 z$, $x$ of same domain s $y$ & $i \times i$ matrix of binary variables $p$

Basically
$x_i = p_{i,j}x_i$

$\sum_i z_{i,j} = y_j \quad \forall j$
$\sum_j z_{i,j} = x_i \quad \forall i$
$\sum_i p_{i,j} = 1$
$\sum_j p_{i,j} = 1$
$x_i \le x_{i+1}$
$z_{i,j} \le Mp_{i,j}$

Median = $x_{I+1\over2}$ if $I$ or $J$ is odd, else ${x_{k}+x_{k+1}}\over 2$ where $k={{I}\over2}$

added 16 characters in body
Source Link
Sutanu Majumdar
  • 3.6k
  • 1
  • 3
  • 12

First you may need to sort your optimization variables. Taking idea from Dr. Kalvelagen (link) & YALMIP define additional continuous variables $0 \le x,z,$ & $i^2$$i \times i$ matrix of binary variables $p$

Basically
$x_i = p_{i,j}x_i$

$\sum_i z_{i,j} = y_j \quad \forall j$
$\sum_j z_{i,j} = x_i \quad \forall i$
$\sum_i p_{i,j} = 1$
$\sum_j p_{i,j} = 1$
$x_i \le x_{i+1}$
$z_{i,j} \le Mp_{i,j}$

Median = $x_{I+1\over2}$ if $I$ or $J$ is odd, else $x_{k}+x_{k+1}$${x_{k}+x_{k+1}}\over 2$ where $k={{I+1}\over2}$

First you may need to sort your optimization variables. Taking idea from Dr. Kalvelagen (link) & YALMIP define additional continuous variables $0 \le x,z,$ & $i^2$ matrix of binary variables $p$

Basically
$x_i = p_{i,j}x_i$

$\sum_i z_{i,j} = y_j \quad \forall j$
$\sum_j z_{i,j} = x_i \quad \forall i$
$\sum_i p_{i,j} = 1$
$\sum_j p_{i,j} = 1$
$x_i \le x_{i+1}$
$z_{i,j} \le Mp_{i,j}$

Median = $x_{I+1\over2}$ if $I$ or $J$ is odd, else $x_{k}+x_{k+1}$ where $k={{I+1}\over2}$

First you may need to sort your optimization variables. Taking idea from Dr. Kalvelagen (link) & YALMIP define additional continuous variables $0 \le x,z,$ & $i \times i$ matrix of binary variables $p$

Basically
$x_i = p_{i,j}x_i$

$\sum_i z_{i,j} = y_j \quad \forall j$
$\sum_j z_{i,j} = x_i \quad \forall i$
$\sum_i p_{i,j} = 1$
$\sum_j p_{i,j} = 1$
$x_i \le x_{i+1}$
$z_{i,j} \le Mp_{i,j}$

Median = $x_{I+1\over2}$ if $I$ or $J$ is odd, else ${x_{k}+x_{k+1}}\over 2$ where $k={{I+1}\over2}$

Source Link
Sutanu Majumdar
  • 3.6k
  • 1
  • 3
  • 12

First you may need to sort your optimization variables. Taking idea from Dr. Kalvelagen (link) & YALMIP define additional continuous variables $0 \le x,z,$ & $i^2$ matrix of binary variables $p$

Basically
$x_i = p_{i,j}x_i$

$\sum_i z_{i,j} = y_j \quad \forall j$
$\sum_j z_{i,j} = x_i \quad \forall i$
$\sum_i p_{i,j} = 1$
$\sum_j p_{i,j} = 1$
$x_i \le x_{i+1}$
$z_{i,j} \le Mp_{i,j}$

Median = $x_{I+1\over2}$ if $I$ or $J$ is odd, else $x_{k}+x_{k+1}$ where $k={{I+1}\over2}$