From: Duygu on 8 May 2010 17:37 Hi, I want to solve a system of multivariate quadratic equations with boundary constraints. I searched a lot and found that lsqnonlin is the most suitable function I could use. Assume my system of equations in 4 unknowns is: 2*(x(3)-x(4))^2 = 0.01 2*(x(2)-x(4))^2 + x(3)^2)= 0.02 2*(x(1)-x(4))^2 + 2*(x(2)-x(3))^2 = 0.225 2*(x(1)-x(3))^2 + x(2)^2 = 0.166 x(1)*x(1)+x(2)*x(2)+x(3)*x(3)+x(4)*x(4) = 1.05 So I write these equations in the following form: function f = ff(x) f = [2*(x(3)-x(4))*(x(3)-x(4))-0.01; 2*(x(2)-x(4))*(x(2)-x(4))+(x(3)-x(3))*(x(3)-x(3))-0.0266667; 2*(x(1)-x(4))*(x(1)-x(4))+2*(x(2)-x(3))*(x(2)-x(3))-0.225; 2*(x(1)-x(3))*(x(1)-x(3))+(x(2)-x(2))*(x(2)-x(2))-0.166667; x(1)*x(1)+x(2)*x(2)+x(3)*x(3)+x(4)*x(4)-1.070000]; I provide the startin point as x0=[0.5 0.5 0.5 0.5] When I make the function call lsqnonlin(@ff, x0), I get the same value for all the variables: 0.5172. However, the solution I am looking for is something like "0.9 0.1 0.4 0.3". I also get the following message: Optimization terminated: first-order optimality less than OPTIONS.TolFun, and no negative/zero curvature detected in trust region model. What can be the problem? Do you think it is suitable to use lsqnonlin for my problem or are there any other methods you can suggest? Finally, I might have quiet big systems with like more than 1000 unknowns, will lsqnonlin work in this case as well? Thanks in advance, Duygu
From: Alan Weiss on 10 May 2010 09:37 You are using the lsqnonlin syntax incorrectly. You should NOT form the squares in your objective function ff. Read the proper syntax: doc lsqnonlin Alan Weiss MATLAB mathematical toolbox documentation On 5/8/2010 5:37 PM, Duygu wrote: > Hi, > I want to solve a system of multivariate quadratic equations with > boundary constraints. I searched a lot and found that lsqnonlin is the > most suitable function I could use. Assume my system of equations in 4 > unknowns is: > > 2*(x(3)-x(4))^2 = 0.01 > 2*(x(2)-x(4))^2 + x(3)^2)= 0.02 > 2*(x(1)-x(4))^2 + 2*(x(2)-x(3))^2 = 0.225 > 2*(x(1)-x(3))^2 + x(2)^2 = 0.166 > x(1)*x(1)+x(2)*x(2)+x(3)*x(3)+x(4)*x(4) = 1.05 > > So I write these equations in the following form: > > function f = ff(x) > f = [2*(x(3)-x(4))*(x(3)-x(4))-0.01; > 2*(x(2)-x(4))*(x(2)-x(4))+(x(3)-x(3))*(x(3)-x(3))-0.0266667; > 2*(x(1)-x(4))*(x(1)-x(4))+2*(x(2)-x(3))*(x(2)-x(3))-0.225; > 2*(x(1)-x(3))*(x(1)-x(3))+(x(2)-x(2))*(x(2)-x(2))-0.166667; > x(1)*x(1)+x(2)*x(2)+x(3)*x(3)+x(4)*x(4)-1.070000]; > > I provide the startin point as x0=[0.5 0.5 0.5 0.5] > > When I make the function call lsqnonlin(@ff, x0), I get the same value > for all the variables: 0.5172. However, the solution I am looking for is > something like "0.9 0.1 0.4 0.3". I also get the following message: > > Optimization terminated: first-order optimality less than OPTIONS.TolFun, > and no negative/zero curvature detected in trust region model. > > What can be the problem? Do you think it is suitable to use lsqnonlin > for my problem or are there any other methods you can suggest? Finally, > I might have quiet big systems with like more than 1000 unknowns, will > lsqnonlin work in this case as well? > > Thanks in advance, > Duygu
|
Pages: 1 Prev: image recognition algorithms Next: how to plot line between any two pixels? |