Skip to content

Commit

Permalink
Introduce alpha_threshold into the framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Lht97 committed Nov 21, 2024
1 parent 6a6ae50 commit e050777
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/bds.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
% Default: 2.
% shrink Shrinking factor of step size. A positive number less than 1.
% Default: 0.5.
% alpha_threshold The threshold of the step size. If the step size is smaller than
% alpha_threshold, then the step size will be not allowed to shrink below
% alpha_threshold. It should be strictly less than StepTolerance.
% A positive number. Default: eps.
% forcing_function The forcing function used for deciding whether the step achieves
% a sufficient decrease. A function handle.
% Default: @(alpha) alpha^2. See also reduction_factor.
Expand Down Expand Up @@ -269,6 +273,14 @@
alpha_tol = get_default_constant("StepTolerance");
end

% Set the value of alpha_threshold. If the step size is smaller than alpha_threshold, then the step size
% will be not allowed to shrink below alpha_threshold.
if isfield(options, "alpha_threshold")
alpha_threshold = options.alpha_threshold;
else
alpha_threshold = get_default_constant("alpha_threshold");
end

% Set the target of the objective function.
if isfield(options, "ftarget")
ftarget = options.ftarget;
Expand Down Expand Up @@ -493,7 +505,10 @@
if sub_fopt + reduction_factor(3) * forcing_function(alpha_all(i_real)) < fbase
alpha_all(i_real) = expand * alpha_all(i_real);
elseif sub_fopt + reduction_factor(2) * forcing_function(alpha_all(i_real)) >= fbase
alpha_all(i_real) = shrink * alpha_all(i_real);
alpha_all(i_real) = max(shrink * alpha_all(i_real), alpha_threshold);
if shrink * alpha_all(i_real) < alpha_threshold
fprintf("The step size of the block %d is smaller than alpha_threshold.\n", i_real);
end
end

% Record the best function value and point encountered in the i_real-th block.
Expand Down
2 changes: 2 additions & 0 deletions src/private/get_default_constant.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
constant_value = @(alpha) alpha^2;
case {"alpha_init"}
constant_value = 1;
case {"alpha_threshold"}
constant_value = eps;
case {"StepTolerance"}
constant_value = 1e-6;
case {"permuting_period"}
Expand Down

0 comments on commit e050777

Please sign in to comment.