2
$\begingroup$

I have the following portfolio optimization problem that I want to solve using Cvxpy:

Portfolio Optimization Problem

However I am having troubles 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 constraints? Thanks.

Paolo

$\endgroup$
3
$\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.$$

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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