lm优化算法 matlab,LMFnlsq - 非线性最小二乘优化算法

LMFnlsq是Fletcher对Levenberg-Marquardt算法的MATLAB实现,用于求解非线性最小二乘问题。该函数允许用户设置选项,包括迭代输出控制、雅可比矩阵计算方式等,并能处理约束问题。通过提供方程组和初始估计值,LMFnlsq可以找到解,并返回最终解、残差平方和、迭代次数等相关信息。示例中展示了使用LMFnlsq解决Rosenbrock函数的问题,仅用17次迭代就得到了解。
摘要由CSDN通过智能技术生成

324619ae995a043bc12bde7d078becb8.gif

LMFnlsq050.jpg (81.79 KB, 下载次数: 35)

2008-12-13 10:06 上传

源代码参见:http://www.mathworks.com/matlabcentral/fileexchange/16063

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.

499e06954e472d6fa8bfc041fe26e10e.gif

2008-12-13 10:06 上传

点击文件名下载附件

下载积分: 贝壳 -1

283.58 KB, 下载次数: 4131, 下载积分: 贝壳 -1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值