2025-03-05 10:53:15 +02:00

24 lines
791 B
Matlab
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function [gamma] = gamma_minimized(f, ~, dk, xk)
% Calculates the step based on minimizing f(xk γk*dk)
%
%
% f: Objective function
% ~: Gradient function of f - Not used
% dk: Current value of selected direction -∇f or -inv{H}*∇f or -inv{H + lI}*∇f
% xk: Current point (x,y)
% Define the line search function fmin(g) = f(xk - g * dk)
fmin = @(g) f(xk(1) + g*dk(1), xk(2) + g*dk(2));
% find g that minimizes fmin
e = 0.0001;
l = 0.001;
[a,b,k,~] = fmin_bisection(fmin, 0, 5, e, l);
gamma = 0.5*(a(k) + b(k));
% Define the line search function fmin(g) = f(xk - g * dk)
%fmin = @(g) f(xk(1) - gamma * dk(1), xk(2) - gamma * dk(2));
% find g that minimizes fmin
%gamma = fminbnd(g, 0, 1);
end