THMMY's "Optimization Techniques" course assignments.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gamma_armijo.m 1.1 KiB

2 일 전
2 일 전
2 일 전
2 일 전
2 일 전
2 일 전
2 일 전
123456789101112131415161718192021222324252627282930313233
  1. function [gamma] = gamma_armijo(f, grad_f, dk, xk)
  2. % Calculates the best step based on amijo method
  3. %
  4. % f(xk​+ γk*dk) ≤ f(xk) + σ * γk * dk^T * ∇f(xk)
  5. % γk = β*γk_0
  6. %
  7. % f: Objective function
  8. % grad_fun: Gradient function of f
  9. % dk: Current value of selected direction -∇f or -inv{H}*∇f or -inv{H + lI}*∇f
  10. % xk: Current point (x,y)
  11. % beta: beta factor in [0.1, 0.5]
  12. % signam: sigma factor in (0, 0.1]
  13. global amijo_beta
  14. global amijo_sigma
  15. gf = grad_f(xk(1), xk(2));
  16. gamma = 1; % Start with a step size of 1
  17. % Perform Armijo line search
  18. while f(xk(1) + gamma * dk(1), xk(2) + gamma * dk(2)) > ...
  19. f(xk(1), xk(2)) + amijo_sigma * gamma * dk' * gf
  20. %while f(xk(1) + gamma * dk(1), xk(2) + gamma * dk(2)) > ...
  21. % f(xk(1), xk(2)) + amijo_sigma * gamma * norm(dk)^2
  22. gamma = amijo_beta * gamma; % Reduce step size
  23. if gamma < 1e-12 % Safeguard to prevent infinite reduction
  24. warning('Armijo step size became too small.');
  25. break;
  26. end
  27. end
  28. end