To implement the Armijo rule using the condition you specified:
[ f(x_k + \alpha_k d_k) \leq f(x_k) + c_1 \alpha_k \nabla f(x_k)^T d_k ]
You'll need to adjust the backtracking line search process accordingly. Here’s how you can rewrite the algorithm using this version of the Armijo condition:
function [x, fun_val, x_hist] = gradient_method_armijo(f, g, x0, epsilon, c1, beta)
% Gradient method with Armijo rule using backtracking line search
%
% INPUT
%======================================================================
% f .......... objective function
% g .......... gradient of the objective function
% x0 ......... initial point
% epsilon .... tolerance parameter for gradient norm
% c1 ......... parameter for Armijo rule (0 < c1 < 1)
% beta ....... backtracking scaling factor (0 < beta < 1)
%
% OUTPUT
%======================================================================
% x .......... optimal solution (up to a tolerance)
% fun_val .... optimal function value at the solution
% x_hist ..... history of x values
x = x0;
grad = g(x);
x_hist = x0';
iter = 0;
while norm(grad) > epsilon
iter = iter + 1;
% Descent direction (gradient descent, so direction is negative gradient)
d = -grad;
% Initial step size
alpha = 1; % Starting with a step size of 1
% Evaluate the current function value
fun_val = f(x);
% Backtracking line search to satisfy the Armijo condition
while f(x + alpha * d) > fun_val + c1 * alpha * grad' * d
alpha = beta * alpha; % Reduce step size using the backtracking factor
end
% Update x using the determined step size
x = x + alpha * d;
grad = g(x);
fun_val = f(x);
% Store the history of x
x_hist = [x_hist; x'];
% Print the iteration details
fprintf('iter_number = %3d norm_grad = %2.6f fun_val = %2.6f step_size = %2.6f\n', iter, norm(grad), fun_val, alpha);
end
end
Explanation:
-
Descent Direction:
- The descent direction
d is chosen as -grad for simple gradient descent.
- For more complex algorithms,
d may differ (e.g., conjugate directions or Newton's method).
-
Armijo Condition:
- This condition ensures the step size yields a sufficient reduction in function value relative to the directional derivative.
- It's given by:
[ f(x_k + \alpha_k d_k) \leq f(x_k) + c_1 \alpha_k \nabla f(x_k)^T d_k ]
-
Backtracking:
- Start with an initial step size
alpha (commonly 1).
- Reduce
alpha by multiplying with beta (a value like 0.5 or 0.8) until the Armijo condition is satisfied.
-
Updating:
- Once the suitable
alpha is found, update x with the new value.
- Continue until the stopping criterion (gradient norm smaller than
epsilon) is met.
This approach dynamically adjusts the step size to balance between sufficiently large steps for rapid convergence and steps small enough to ensure steady decrease in function value.