Bad results of lsqnonlin

1 次查看(过去 30 天)
samar
samar 2014-9-30
编辑: Matt J 2014-9-30
Hi everybody, I have to solve a 2 non-linear equations system with bounds(upper and lower) I tried lsqnonlin and sometimes it didn't converge to the right answer and i don't understand why!
***A simplified version of the problem (linear and deterministic):
options=optimset('Display','off','MaxIter',1000,'TolFun',1e-009,'TolX',1e-009);
lb = [0,0]; ub = [13.33,6.66]; x0 = [0;0];
xRes = lsqnonlin(@(x)OptimalStrategy2(x,30,1,10,8),q0,lb,ub,options);
***The defined function is the following:
function y = OptimalStrategy2(x,a,b,c1,c2)
y = [a-b*x(2)-c1-2*b*x(1);
a-b*x(1)-c2-2*b*x(2)];
end
*****by running the code I get xRes = 7.0720 6.6600 which is incorrect I'm supposed to get xRes = 6.6600 6.6600 to have both equations satisfied (i.e a-b*x(2)-c1-2*b*x(1)=0 and a-b*x(1)-c2-2*b*x(2)=0)
I need your help to undertand this point please!

采纳的回答

Matt J
Matt J 2014-9-30
编辑:Matt J 2014-9-30
I'm supposed to get xRes = 6.6600 6.6600 to have both equations satisfied
By direct inspection, I find that xRes = [6.6600 6.6600] does not satisfy your equations. Neither does xRes = [7.0720 6.6600], but it is better in a least squares sense:
K>> f=@(x) OptimalStrategy2(x,30,1,10,8);
K>> norm(f([6.66,6.66]))
ans =
2.0201
K>> norm(f([ 7.0720 6.6600]))
ans =
1.7978
Incidentally, your problem is linear, so you should probably be using LSQLIN.
  1 个评论
Matt J
Matt J 2014-9-30
编辑:Matt J 2014-9-30
Because your system is linear and nonsingular, it has a unique unconstrained solution
>> xunc = [-2*b -b; -b -2*b]\[a-c1;a-c2]
xunc =
-6
-8
There is therefore no way you can satisfy both equations exactly with lower bounds lb=[0,0] in place.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by