solve a linear equation system with box constrains

2 Ansichten (letzte 30 Tage)
Jan Klement
Jan Klement am 26 Nov. 2015
Kommentiert: Jan Klement am 26 Nov. 2015
How can I solve a overconstrained equation System in of the type A*x=b where A is a Matrix, b a vector, x is the solution vector. Each element has a box constrain of the type ci<xi<di. I know there are functions in the optimzation Toolbox, but unfortunatly I don't have it.

Akzeptierte Antwort

Torsten
Torsten am 26 Nov. 2015
min: sum_{i=1}^{n}{a_i^t*x-b_i}^2
Now replace x_j with lb_j*sin^2(y_j)+ub_j*cos^2(y_j) and use fminsearch to solve for the y_j.
Here, lb_j and ub_j are the lower and upper bounds for x_j.
Of course, using lsqlin to solve would be much more safe and efficient.
Best wishes
Torsten.
  1 Kommentar
Jan Klement
Jan Klement am 26 Nov. 2015
Thank you Torsten,
it works slow but it works sufficiently good if the number of function calls is increased. I have tested your aproach against fminsearchbnd from the matlab central and is it always faster. Here the code if someone Needs it:
xt is the solution.
n=100;
lb=rand(1,n)*(-1000);
ub=lb+rand(1,n)*1000;
A=rand(n);
b=rand(1,n);
xr=fminsearch(@(x) afun2(x,A,b,lb,ub),start,optimset('MaxFunEvals',1e5,'MaxIter',1e10));
[ysum y xt]=afun2(xr,A,b,lb,ub);
function [ysum y xt]=afun2(x,A,b,lb,ub)
xt=lb.*sin(x).^2+ub.*cos(x).^2;
y=xt*A-b;
ysum=(norm(y));
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by