quadprog 'trust-region-reflective' algorithm error
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Matt J
2017-11-30
编辑:Matt J
2017-11-30
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.
更多回答(1 个)
Kaushik Lakshminarasimhan
2017-11-30
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!