quadprog 'trust-region-reflective' algorithm error
14 views (last 30 days)
Show older comments
Hello, I get an error using the "trust region reflective" algorithm for a quadratic problem:
Error using quadprog (line 406)
Option Algorithm = 'trust-region-reflective' but this algorithm does not solve
problems with the constraints you have specified. Run a different algorithm by
setting the Algorithm option. For information on applicable algorithms, see
Choosing the Algorithm in the documentation.
Unfortunately the problem in not convex, so no other algorithms are available, a minimal example code is the following:
H=[1 0;0 -1 ];
f = zeros(2,1);
A=[1 1];
b=1.2;
lb = zeros(2,1);
ub = ones(2,1);
x0=(ub+lb)/2;
options=optimoptions('quadprog','Algorithm','trust-region-reflective');
x = quadprog(H,f,A,b,[],[],[],[],x0,options);
as far as I can understand, the only limit to the use of this algorithm is that only equality constraints or bound constraints can be used but not both.
The only way to make quadprog work is removing the linear bounds (A and b), not very useful. But the problem has no equality constraints (Aeq=[],beq=[]) so I don't understand the error. Thank you for any advice
0 Comments
Accepted Answer
Matt J
on 30 Nov 2017
Edited: Matt J
on 30 Nov 2017
Apparently, the structure of your problem is outside the scope of quadprog, but there is always fmincon,
[x,fval,exitflag,output] = fmincon(@(x) x.'*H*x/2+f'*x ,x0,A,b,[],[],lb,ub);
Naturally, I would recommend that you improve the implementation of the objective function, incorporating also the SpecifyObjectiveGradient option.
More Answers (1)
Kaushik Lakshminarasimhan
on 30 Nov 2017
As you said, the only limit to the use of this algorithm is that only equality constraints or bound constraints can be used but not both.
So, you can specify either Aeq & beq, or LB & UB, but not both. In your implementation, you are specifying inequality constraints ( A and b ). These are not the same as bound constraints which is why you're getting the error. If your problem is not convex, you can try this (untested) code: https://github.com/xiawei918/quadprogIP
See Also
Categories
Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!