最優化——FR共軛梯度法matlab程序

%  cg.m

function [x, output] = cg(fun, dfun, x0)
% fun: character variable, the name of function computing objective function
% dfun: character variable, the name of function computing the gradient of objective function
% x0: real vector, input initial point
% x :real vector, output solution
% output: structure variable, output the value of f, the number ofiteration, the number of function evaluations and the norm of gradient at last point x
%
% Step 1: initialization
%
epsi = 1.0e-3; % termination tolenrence
k = 0; % the number of iteration
funcN = 0; % the number of function evaluation
rho = 0.01; l = 0.15; u = 0.85;
x = x0;
f = feval(fun, x);
funcN = funcN + 1;
n = length(x0);
%
% Step 2: check convergence condition
%
g = feval(dfun, x);
while norm(g) > epsi & k <= 150
%
% Step 3: form search direction
%
    iterm

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章