Wolfe和Armijo准则之Matlab实现

Wolfe准则

function [alpha, newxk, fk, newfk] = wolfe(xk, dk)
rho = 0.25; sigma = 0.75;
alpha = 1; a = 0; b = Inf;
while (1)
if ~(fun(xk+alpha*dk)<=fun(xk)+rho*alpha*gfun(xk)'*dk)
b = alpha;
alpha = (alpha+a)/2;
continue;
end
if ~(gfun(xk+alpha*dk)'*dk >= sigma*gfun(xk)'*dk)
a = alpha;
alpha = min([2*alpha, (b+alpha)/2]);
continue;
end
break;
end
newxk = xk+alpha*dk;
fk = fun(xk);
newfk = fun(newxk);


Armijo准则

function mk = armijo(xk, dk)
beta = 0.5; sigma = 0.2;
m = 0; mmax = 200;
while (m<=mmax)
if(fun(xk+beta^m*dk) <= fun(xk) + sigma*beta^m*gfun(xk)'*dk)
mk = m; break;
end
m = m+1;
end
alpha = beta^mk
newxk = xk + alpha*dk
fk = fun(xk)
newfk = fun(newxk)



你可能感兴趣的:(Wolfe和Armijo准则之Matlab实现)