# Matlab Trust-region-reflective algorithm warning

I am very new to matlab and trying to solve portfolio optimization problem (minimizing the variance) using quadprog:

minW = quadprog(t_covar, v0, [], [], e, ub, lb, [], []);


where t_covar is the covariance matrix, v0 is a zero vector, e is the identity vector, ub = 1 and lb is a zero vector. It seems to work fine but I get this warning:

Warning: Trust-region-reflective algorithm does not solve this type of problem, using active-set algorithm. You could also try the interior-point-convex algorithm: set the Algorithm option to interior-point-convex and rerun.

Hope I was clear thanks

-

I think you are doing something wrong. The most recent version of quadprog has this argument set:

quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options)


If you're using the most recent version of Matlab, then your function call has $e$, $ub$, and $lb$ being stuffed into the $Aeq$, $beq$, and $lb$ parameters, respectively. I don't think that's what you want, as (for example) $beq$ is supposed to be the right-hand side of an equality constraint, while $ub$ is your upper bound.

You're getting the warning message because you didn't specify a particular algorithm for the quadprog function to use, and so quadprog is trying the default algorithm, which is the trust-region-reflective algorithm. That algorithm apparently doesn't work on your problem. This is probably because of the parameter passing issue I mentioned above, as the trust-region-reflective algorithm works when the problem has "only bounds, or only linear equality constraints (but not both)." (For more information, see "Choosing a solver" in the Matlab documentation.)

Since the trust-region-reflective algorithm doesn't work, quadprog is trying the next algorithm in line, which is apparently the active-set algorithm. Then it's telling you that you might get better results with the interior-point-convex algorithm.

So, which algorithm should you use?

Matlab's general recommendations for the algorithm for the quadprog function are

• If you have a convex problem, or if you don't know whether your problem is convex, use interior-point-convex.
• If you have only bounds, or only linear equalities, use trust-region-reflective.
• If you have a nonconvex problem that does not satisfy the restrictions of trust-region-reflective, use active-set.

Since you're passing quadprog a covariance matrix (which must be positive semidefinite) your problem is convex. So it sounds like the interior-point-convex method is the way to go.