资源简介
MATLAB编写的共轭梯度函数,适合处理二次型问题
代码片段和文件信息
ta http-equiv=Content-Type content=“text/html; charset=iso-8859-1“>
% Conjugate Gradients minimization routine. Uses gradient magnitude
% for termination condition.
%
% function [x] = conjgrad(x0lsfunlsparamsogfunogparamsvarargin)
% x0 - initial value of the solution [d1]
% lsfun - pointer to line search function
% function [alpha] = lsfun(x0directionogfunparams)
% x0 - location to start line search [d1]
% direction - direction from x0 along which to search [d1]
% ogfun - poitner to objective/gradient function
% params - cell array of parameters to pass to ogfun
% alpha - appx. location of minimum along direction
% appx. minimium is: x0+alpha.*direction
% lsparams - cell array of parameters to pass to lsparams
% ogfun - pointer to objective/gradient calculation function
% function [objgrad] = ogfun(xparams)
% x - parameter value at which to calculate obj/grad [d1]
% params - additional parameters
% obj - objective value at x [scalar]
% grad - gradient at x [d1]
% ogparams - cell array of parameters to pass to ogfun
% x - final value of the solution (appxroximate local minimum) [d1]
%
% Additional parameters given by name/value pairs via varagin.
% E.g. conjgrad(x0lsfunparamsogfun‘verbose‘0)
%
% This is an implementation of the Polak-Ribiere Nonlinear Conjugate
% Gradients as described by “An introduction to the conjugate
% gradient method without the agonizing pain“ by Shewchuk (1994) and
% “Numerical Optimization“ by Nocedal and Wright.
%
% Note: this code automatically uses the last alpha as initial value for
% line search. This can backfire causing lots of backtracking if the
% optimization surface isn‘t nice. To avoid this pass a value of alpha0
% as part of lsparams (e.g. ‘alpha0‘1e-6)
%
% Written by Jason Rennie February 2005
% Last modified: Wed Mar 29 22:46:42 2006
function [xnumiter] = conjgrad(x0lsfunlsparamsogfunogparamsvarargin)
fn = mfilename;
if nargin < 5
error(‘insufficient parameters‘)
end
% Parameters to be set via varargin
verbose = 1; % print progress information if true
tol = 1e-3; % geometric decrease in gradient magnitude to declare minimum
maxiter = 1000; % stop after this many iterations (if no minimum found)
nu = 0.1;
abstol = 0; % stop if gradient magnitude goes below this
allowNonDecrease = 0; % don‘t stop if line search fails to find decrease
% Process varargin
paramgt;
t0 = clock;
t1 = t0;
ogcalls = 0;
x = x0;
numiter = 0;
j = 0;
alpha = 1e-10;
ogcalls = ogcalls + 1;
[objdx] = ogfun(xogparams{:});
r = -dx;
s = r;
d = s;
deltanew = full(r‘*d);
deltazero = deltanew;
if verbose
fprintf(1‘Begin deltazero=%1.1e tol=%.0e obj=%.1f\n‘deltazerotolobj);
end
while numiter &l
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 585 2009-05-07 16:39 prpconj.m
文件 4909 2006-06-03 09:44 conjgrad.m
文件 678 2009-05-08 22:04 gongehanshu.m
----------- --------- ---------- ----- ----
6172 3
- 上一篇:MRF matlab源码
- 下一篇:WCDMA matlab代码
相关资源
- 最优化方法及其MATLAB程序设计
- 解线性方程组的共轭梯度算法(Matl
- MATLAB实现Jacobi 迭代法,Gauss-Seidel 迭代
- MATLAB实现最速下降法,牛顿法和共轭
- 优化方法:最速下降、阻尼牛顿、共
- 共轭梯度法的matlab实现
- Matlab单像素成像算法比较
- 共轭梯度法的matlab程序
- 共轭梯度法matlab程序
- 最优化 拟牛顿法,高斯-牛顿法,LM法
- 共轭梯度优化方法MATLAB代码
- 共轭梯度法相关matlab程序
- matlab预处理共轭梯度法
- 最优化共轭梯度法matlab实现
- matlab_FR共轭梯度算法+BFGS拟牛顿算法
- matlab实现共轭梯度法
- MATLAB实现共轭梯度解决最优化问题
- matlab叠前反演的代码
- 共轭梯度法的程序
评论
共有 条评论