数学建模社区-数学中国

标题: LMFnlsq - 非线性最小二乘优化算法 [打印本页]

作者: 建不了的模。    时间: 2014-8-11 15:40
标题: LMFnlsq - 非线性最小二乘优化算法
LMFnlsq - 非线性最小二乘优化算法


Efficient and stable MATLAB version of Fletcher's modification of Levenberg-Marquardt method

The function finds a solution of an algebraic nonlinear problem in the
least squares sense. The standard Levenberg- Marquardt algorithm was modified by Fletcher and coded in FORTRAN many years ago. LMFnlsq is its MATLAB version complemented by setting parameters of Options.  

The function calling has one of the following forms:  

Options = LMFnlsq; % Settings of Options  
Options = LMFnlsq('default');  
Options = LMFnlsq(Name1,Value1,Name2,Value2,…);  
Options = LMFnlsq(Options,Name1,Value1,Name2,Value2,…);  
x = LMFnlsq(Eqns,x0); % Problem solutions  
x = LMFnlsq(Eqns,x0,Options);  
x = LMFnlsq(Eqns,x0,Name1,Value1,Name2,Value2,…);  
[x,ssq] = LMFnlsq(Eqns,x0,…);  
[x,ssq,cnt] = LMFnlsq(Eqns,x0,…);  
[x,ssq,cnt,nfJ,xy] = LMFnlsq(Eqns,x0,…);  

The input variables have the following meaning:  
-Eqns is a function name or a handle defining a set of equations to be  solved and their residuals,  
-x0 is a vector of initial estimates of unknowns,  
-Name, Value is a pair of the Options structure. If no Options is defined,  default structure items are used. The structure has the following field  

names and default values (in braces):  

-'Display' for control of iteration results output, {0},  
-'Printf' for a handle or function name for output of iteration results,  
{printit} subfunction,  
-'Jacobian' for a handle of function, which evaluates Jacobian matrix J,  
-{finjac} subfunction. If no handle is declared, internal subfunction for  finite difference approximation of the matrix J is used.  
-'MaxIter' for setting maximum number of iterations, {100},  
-'ScaleD' for defining diagonal matrix of scales, {[]},  
-'FunTol' for tolerance of final function values, {1e-7},  
-'XTol' for tolerance of final solution increments, {1e-7},  
-'Lambda' for setting lambda parameter in the first iteration, {0},  
-'Trace' for control of storing intermediate results of the vector x , {0};  

The output variables are:  
-x is the final solution,  
-ssq is the sum of squares of residuals of Eqns,  
-cnt is a number of iterations needed for finding x,  
-nfJ is the number of calling Eqns and 'Jacobian',  
-xy is a matrix of intermediate solutions x in iterations.  

Example:  
The general Rosenbrock's function has the form of a sum of squares:  
f(x) = 100(x(2)-x(1)^2)^2 + (1-x(1))^2  
Optimum solution gives f(x)=0 for x(1)=x(2)=1. Function f(x) can be  
expressed in the form f(x) = f1(x)^2 +f2(x)^2,  
where f1(x) = 10(x(2)-x(1)^2) and f2(x) = 1-x(1).  
Values of the functions f1(x) and f2(x) can be used as residuals.  
LMFnlsq finds the solution of this problem in 17 iterations with default  
settings. The function FUN has the form of named function  

function r = rosen(x)  
% Rosenbrock valey residuals:  
r = [ 10*(x(2)-x(1)^2) % first part, f1(x)  
1-x(1) % second part, f2(x)  
];  
or an anonymous function  
rosen = @(x) [10*(x(2)-x(1)^2); 1-x(1)];  
The solution is x = [1; 1] with ssq = 0.  
Anonymous functions are applicable with MATLAB 7.  

The function LMFnlsq is able to solve even constrained problems, provided an appropriate penalty function is defined as additional function (see the screenshot and LMFtest.pdf).  
The function LMFnlsq overcomes earlier presented function LMFsolve (FEX Id: 16063) in much higher stability.  

See LMFtest for a short explanation and solved examples.




LMFnlsq.zip

283.59 KB, 下载次数: 4, 下载积分: 体力 -2 点

售价: 2 点体力  [记录]


作者: 龍羽落    时间: 2014-8-11 17:06
看看,,,,,,,,,,,,,
作者: ..继续、_Contin    时间: 2014-8-12 18:19
希望有用,看看
作者: 守穹望峰    时间: 2015-4-1 14:03
恩恩..........................

作者: 黎雪峰    时间: 2015-5-19 16:04
好些啊,大家都看看吧


作者: 天使很忙    时间: 2016-7-25 22:53
求大神赐教





欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5