|
- function [gamma] = gamma_armijo(f, grad_f, dk, xk)
- % Calculates the best step based on amijo method
- %
- % f(xk+ γk*dk) ≤ f(xk) + σ * γk * dk^T * ∇f(xk)
- % γk = β*γk_0
- %
- % f: Objective function
- % grad_fun: Gradient function of f
- % dk: Current value of selected direction -∇f or -inv{H}*∇f or -inv{H + lI}*∇f
- % xk: Current point (x,y)
-
-
- % beta: beta factor in [0.1, 0.5]
- % signam: sigma factor in (0, 0.1]
- global amijo_beta
- global amijo_sigma
-
- gf = grad_f(xk(1), xk(2));
- gamma = 1; % Start with a step size of 1
-
- % Perform Armijo line search
- while f(xk(1) + gamma * dk(1), xk(2) + gamma * dk(2)) > ...
- f(xk(1), xk(2)) + amijo_sigma * gamma * dk' * gf
- %while f(xk(1) + gamma * dk(1), xk(2) + gamma * dk(2)) > ...
- % f(xk(1), xk(2)) + amijo_sigma * gamma * norm(dk)^2
- gamma = amijo_beta * gamma; % Reduce step size
- if gamma < 1e-12 % Safeguard to prevent infinite reduction
- warning('Armijo step size became too small.');
- break;
- end
- end
-
- end
|