I'm trying to create an optimization problem where one of my constraints represents a median of another decision variable. Suppose I have decision variables $\bf{y}$ and $z$. My problem will look something like:
\begin{align}\min &\quad f(z)\\\ \text{s.t.} &\quad\text{constraint that defines z to be the median value of y}\\\ &\quad [\text{other constraints with y}]\end{align}
I'm not sure how to express this constraint. Any ideas?