Linear objective with quadratic constraint

3 views (last 30 days)
Hey guys!
I'm trying to solve a portfolio optimization problem with a maximum return strategy, which implies that I try to maximize the return for a given level of std.deviation. As far as I know this kind of problem involves Fmincon as optimizer.
I would like to maximize the portfolio return s.t. to a given level of std. deviation, therefore I have done the following:
I've set Q=zero(2,2) (as I have a portfolio of two assets) and c = zero(1,1) which implies that I end up with the problem to minimize f'x (which should be negative in order to maximize it). In my constraint I have set k equal to zero and d equal to minus my maximum level of daily std. deviation.
This should as far is i'm aware do the job, but when I try to run the optimization I get the following error message:
As far as i'm aware my dimension should be fine, as my f vektor is a 2x1 which is transposed and therefor f'x is 1x1. H is a 2x2 and x should be a 2x1, which should imply that the dimension in the constraint should be fine.
I would really appreciate if someone could point out where the error lies.
I could poste the entire code, but I thought that it would be to much and that's why I referred to the link above.
Best regards,
Kristian Lunow Nielsen

Answers (2)

Torsten
Torsten on 18 Apr 2016
Take a look at the documentation of fmincon about the form of the functions "fun" and "nonlconstr".
Best wishes
Torsten.

Steve Grikschat
Steve Grikschat on 18 Sep 2020
As of R2020b, Optimization Toolbox now has a dedicated solver for second-order cone programming, which can be used to solve quadratic constrained problems.
https://www.mathworks.com/help//optim/ug/convert-qp-to-socp.html
Function reference:
coupled with a function to make a second-order cone constraint
For an example see

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!