Problem in solution from Linprog

Hi,
I am using linprog to solve for parameters of the following problem -
minimise -a
subject to constraint : a + b*x < y
The parameter estimates that I get from linprog (a & b), should ideally give me errors which are all positive ie
e = y - a -b*x
e > 0, for all y and x
but few of my errors have value -0.0000
how can I get around this problem?
----------------
A = ones(80,1);
f = [-1;0];
options = optimoptions('linprog','Algorithm','simplex')
p_fit=linprog(f,[A xdata],[ydata],[],[],[-Inf -Inf],[],p_initial,options)
-----------------------------------
I have attached data for x and y in an excel file.
Thanks for your help!
Regards, Prachi

 Respuesta aceptada

John D'Errico
John D'Errico el 29 de Mayo de 2016

1 voto

Time to learn about the 'ConstraintTolerance' parameter, and about floating point arithmetic in general.
Are those values really negative? Or are they just effectively zero, plus or minus some trash? Note all of those zeros. In fact, it was reported as -0.0000. That should be the hint that it is just negative "zero".
If you cannot tolerate that amount of deviation, then you can add a tiny offset to the constraints.

Más respuestas (0)

Etiquetas

Preguntada:

el 29 de Mayo de 2016

Respondida:

el 29 de Mayo de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by