3
$\begingroup$

I have the following portfolio optimization problem that I want to solve using CVXPY: \begin{align}\min_w&\quad w^\top\Pi\\\text{s.t.}&\quad\sum_{i=1}^nw_i=1\\&\quad w^\top\Sigma w\le\sigma^{\rm target}\\&\quad|w_i-w_i^{\rm start}|\Bbb I_{\{|w_i-w_i^{\rm start}|>0\}}\ge0.02\Bbb I_{\{|w_i-w_i^{\rm start}|>0\}}\quad\forall i.\end{align}

However I am having trouble implementing the last constraint involving an indicator function. Any ideas on how to code that constraint? Also, if the constraint is not implementable in CVXPY, is there any open-source solver that can deal with that kind of constraint?

$\endgroup$

1 Answer 1

5
$\begingroup$

I assume that $w_i$ is a continuous variable with $0 \le w_i \le 1$ and $w_i^\text{start}$ is a constant with $0 \le w_i^\text{start} \le 1$. You want to enforce $$|w_i-w_i^\text{start}| > 0 \implies |w_i-w_i^\text{start}| \ge 0.02.$$ You can introduce binary variables $y_i^+$ and $y_i^-$ and linear big-M constraints: \begin{align} 0.02 y_i^+ \le w_i - w_i^\text{start} &\le (1 - w_i^\text{start}) y_i^+ &&\text{for all $i$} \tag1 \\ 0.02 y_i^- \le w_i^\text{start} - w_i &\le (w_i^\text{start} - 0) y_i^- &&\text{for all $i$} \tag2 \end{align} Constraint $(1)$ enforces $$w_i - w_i^\text{start} > 0 \implies w_i - w_i^\text{start} \ge 0.02.$$ Constraint $(2)$ enforces $$w_i^\text{start} - w_i > 0 \implies w_i^\text{start} - w_i \ge 0.02.$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.