最优化——拟牛顿方法matlab程序

% BFGS
function [x, output] = bfgs(fun, dfun, x0, varargin)
% Step 1: initialization
epsi = 1.0e-6;
k = 0;
funcN = 0;
rho = 0.01; l = 0.15; u = 0.85;
x = x0;
f = feval(fun, x, varargin{:});
funcN = funcN + 1;
n = length(x0);
H = eye(n);
% Step 2: check termination condition
g = feval(dfun, x, varargin{:});
while norm(g) > epsi & k <= 100
    itercon = true;
    d = -H*g;
% Step 3: line search
    alpha_0 = 1.0;
    gd = g'*d;
    [alpha, funcNk, exitflag] = ...
        lines(fun, rho, l, u, alpha_0, f, gd, x, d, varargin{:});
    funcN = funcN + funcNk;
    if exitflag == -1
        itercon = false;
        restart = true;
        H = eye(n);
        gold = g;
    end
% Step 4: compute ne

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页