Syntax for solving linear equations

3 visualizaciones (últimos 30 días)
Alexander Kjærsgaard
Alexander Kjærsgaard el 31 de Oct. de 2016
Comentada: Torsten el 2 de Nov. de 2016
I have found out that I have phased my problem less complicated then I think it is, so I'll try again. I have a set of data points on my y-axis which has the expression: a-x*b-c*y
(a,b,c are constants, x and y are the variables to be optimized)
In an ideal case of x and y, this expression equals a straight line
a-x*b-c*y=d*z+e
(d and e are constant),
I want x and y to fit this straight line the best, so I want to optimize:
abs( a-x*b-c*y- (d*z+e) ) = 0 with the conditions (x,y >= 0 and x,y =< 1)

Respuesta aceptada

John D'Errico
John D'Errico el 31 de Oct. de 2016
Editada: John D'Errico el 31 de Oct. de 2016
Hmm. I'm not sure what the other solvers are seeing in your question that I don't. Here is your question:
a-x*b-c*y (where a,b and c are constants).
Is minimized under the conditions that: x,y >= 0 and x,y =< 1
so, for given KNOWN constants, you want to solve for x and y. This is just a basic linear programming problem.
Note that a is irrelevant, since if you find the min of -b*x-c*y, the location does not change regardless of the value of a. Just set up linprog, assuming that you have the optimization toolbox.
TRY IT!
xy = linprog([-b,-c],[],[],[],[],[0 0],[1 1]);
  3 comentarios
John D'Errico
John D'Errico el 1 de Nov. de 2016
Yes, completely so, because the objective is no longer linear. So linprog is now invalid for use directly. Depending on the values for a,b,c, and the ranges for x and y, that objective will now be piecewise linear, with a derivative discontinuity along a line. So most optimizers may have problems if you just fed them that problem.
So instead, use linprog, but solve it two times, with a linear inequality constraint, once with
a-x*b-c*y >= 0
and a second time with
a-x*b-c*y <= 0
Then take the better of the two solutions.
Torsten
Torsten el 2 de Nov. de 2016
The problem remains linear if you formulate it as
min: eps
a-x*b-y*c <= eps
a-x*b-y*c >= -eps
x,y >= 0
x,y <= 1
using linprog.
It's data fitting in the l_oo norm.
Best wishes
Torsten.

Iniciar sesión para comentar.

Más respuestas (2)

Torsten
Torsten el 31 de Oct. de 2016
x=(b>0);
y=(c>0);
Best wishes
Torsten.

Alexandra Harkai
Alexandra Harkai el 31 de Oct. de 2016
Editada: Walter Roberson el 31 de Oct. de 2016

Categorías

Más información sobre Linear Least Squares en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by