필터 지우기
필터 지우기

Bad results of lsqnonlin

조회 수: 3 (최근 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