Simple portfolio optimization (QP) with very small risk aversion

I’m trying to solve the following simple portfolio optimization problem. Note that I have a very small value of gamma, the risk aversion parameter.

% ... data loading above
gamma = 1e-10

cvx_begin;
    variable w(n)
    ret = sum(mu .* w)
    risk = gamma * w' * Sigma * w
    maximize(ret - risk)
cvx_end;

Unfortunately, the solvers I’ve tried (SDPT3, SeDuMi) have been unable to solve this problem. I can solve for larger values of gamma, such as 1e-2 or 1e-3, but below that either the solver fails or the solution is very far from the true solution. Is there a way I can modify the hyperparameters of one of these solvers to solve this problem? Which would be best to start with? It seems that CVX’s precision parameter settings do not help. I’ve tried some solver settings already, but I haven’t really gotten anywhere. I am familiar with the basics of IPMs and some of the parameters listed in the documentation for these solvers, but not all of them. I have tried scaling my problem before solving, which does work, but I was hoping I could find solver parameters to change rather than scaling each of my problems (potentially by a different amount) each time.

Thank you very much for reading! I appreciate any suggestions :slight_smile:

gamma = 1e-10 is just too small for double precision solvers to effectively handle. So yes, you need better scaling.

Maybe you could do better (require less rescaling) if you instead used
sqrt(gamma)*norm(sqrtm(Sigma)*w)
as your risk term. If your current risk can handle gamma of 1e-2 or 1e-3,maybe this new risk could handle gamma of 1e-5, and therefore sqrt(gamma) of 1e-2.5.

1 Like

See Example 7.6 here 7 Practical optimization — MOSEK Modeling Cookbook 3.3.0

Rescaling the problem to make it numerically nicer is always a better solution than trying to “fix” the issue by fiddling with solver parameters.

(And definitely never use cvx_precision).

And as Mark mentioned while the Markowitz formulation is quadratic because that’s how it classically was, with conic solvers it makes sense to replace the quadratic term with its square root, which brings you back on the same scale as w, see the discussion around and after equation (2.4) in 2 Markowitz portfolio optimization — MOSEK Portfolio Optimization Cookbook 1.6.0

1 Like

@Mark_L_Stone and @Michal_Adamaszek thank you both very much for the wisdom! It’s good to know that scaling is the right choice. I’ve done a more careful study of how scaling affects the error (vs the analytic solution) across several choices of gamma and scaling sizes/techniques for various solvers and I’m quite pleased with the results, which are quite stable and accurate. I really appreciate the help!

1 Like