The quadprog does not work as intended when the values in A matrix are very small. Is there any other method to deal with such problem?
3 views (last 30 days)
Show older comments
Upon running the following code the quadprog gives the correct answer.
A = -1.0e-25*[0.1239,0.1302];
b = -349;
x = [0;0];
opts = optimoptions(@quadprog,'Display','off');
H = 2*eye(size(A,2));
f = zeros(size(A,2),1);
[vnew1, fval1] = quadprog(H, f, A, b, [],[], [], [] ,x,opts);
A*vnew1 <= 1.0*b %for testing the output (logical 1 in this case)
However, when changing A matrix as follows, doesnot give right results:
A = -1.0e-50*[0.1239,0.1302];
b = -349;
x = [0;0];
opts = optimoptions(@quadprog,'Display','off');
H = 2*eye(size(A,2));
f = zeros(size(A,2),1);
[vnew1, fval1] = quadprog(H, f, A, b, [],[], [], [] ,x,opts);
A*vnew1 <= 1.0*b % answer is logical 0 in this case.
Any suggestions to deal with such small values?
0 Comments
Accepted Answer
Matt J
on 27 Feb 2022
Edited: Matt J
on 27 Feb 2022
I suggest you don't use such small values. Rewrite the problem so that your x(i) are measured in larger units, so that you will not need the factor of 1e-50.
The alternative is to adjust all of the optimoption tolerance parameters to be consistent with the unconventional scalings of your constraints and variables.
1 Comment
John D'Errico
on 27 Feb 2022
Exactly. This is really just a problem of poor scaling. The solution? Avoid poor scaling, by scaling the variables and your problem so everything is a reasonable value. They invented picometers and light years for a good reason.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!