Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

Am I doing something wrong ? Should I worry about this warning ?

Hope I was clear thanks

share|cite|improve this question
up vote 1 down vote accepted

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


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.

For more information, see "Using Quadratic Programming on Portfolio Optimization Problems" in the Matlab documentation.

share|cite|improve this answer
Thanks so much for the detailed answer. I think I misused the ub and lb terms since I was using this ( book's algorithm as an help and misinterpreted some values as being ub and lb (and therefore named that as like that). minW = quadprog(t_covar, v0, [], [], e, 1, v0, [], []) is the real call where e is a vector of ones and v0 is a vector of zeros. I still get the warning and the same result but I guess it should be alright now. – Cemre Feb 21 '12 at 21:55
@Cemre: You're welcome. As I said, I would use the interior-point algorithm rather than the trust-region-reflective algorithm, though. – Mike Spivey Feb 21 '12 at 22:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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