https://github.com/kul-forbes/ForBES
Revision dc65c2366e10a76b7166228adb65acb9a20d68a0 authored by Pantelis Sopasakis on 05 March 2018, 20:56:03 UTC, committed by GitHub on 05 March 2018, 20:56:03 UTC
crash of Forbes on Matlab 2017a
2 parent s 2d876d9 + 8253a09
Raw File
Tip revision: dc65c2366e10a76b7166228adb65acb9a20d68a0 authored by Pantelis Sopasakis on 05 March 2018, 20:56:03 UTC
Merge pull request #3 from Zilleplus/master
Tip revision: dc65c23
Direction_bfgs_naive.m
% BFGS, naive implementation intended for debugging purposes
% (direct update & backslash)

function [dir, tau0, cache] = Direction_bfgs_naive(prob, opt, it, restart, sk, yk, v, cache)

sk = sk(:);
yk = yk(:);

[m, n] = size(v);
v = v(:);

if it == 1 || restart
    dir = -v;
    cache.B = eye(prod(prob.n));
else
    B = cache.B;
    YSk = yk'*sk;
    if YSk > 0
        Bs = B*sk;
        sBs = sk'*Bs;
        B = B + (yk*yk')/YSk - (Bs*Bs')/sBs;
    else
        cache.cntSkip = cache.cntSkip+1;
    end
    dir = -B\v;
    cache.B = B;
end

tau0 = 1.0;
dir = reshape(dir, m, n);

end
back to top