Skip to content

Commit

Permalink
inexact arithmetic comparison in line search
Browse files Browse the repository at this point in the history
  • Loading branch information
lvanroye committed Sep 17, 2024
1 parent bcf259d commit 622b556
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions fatrop/auxiliary/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ namespace fatrop
double mach_eps = std::numeric_limits<double>::epsilon();
return (lhs - rhs <= 10. * mach_eps * std::max(std::abs(rhs), std::abs(lhs)));
}
bool CompareLessEqual(double lhs, double rhs, double ref)
{
double mach_eps = std::numeric_limits<double>::epsilon();
return (lhs - rhs <= 10. * mach_eps * std::abs(ref));
}
}
1 change: 1 addition & 0 deletions fatrop/auxiliary/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
namespace fatrop
{
bool CompareLessEqual(double lhs, double rhs);
bool CompareLessEqual(double lhs, double rhs, double ref);
} // namespace fatrop
#endif // COMMONINCLUDED
4 changes: 2 additions & 2 deletions fatrop/solver/LineSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ LineSearchInfo BackTrackingLineSearch::find_acceptable_trial_point(double mu, bo
{
// cout << filter_->GetSize() << endl;
bool switch_cond = (lin_decr_curr < 0) && (alpha_primal_accent * pow(-lin_decr_curr, s_phi) >= delta * pow(cv_curr, s_theta));
bool armijo = CompareLessEqual(obj_next - obj_curr, eta_phi * alpha_primal_accent * lin_decr_curr);
bool armijo = CompareLessEqual(obj_next - obj_curr, eta_phi * alpha_primal_accent * lin_decr_curr, obj_next);
if (switch_cond && (cv_curr <= theta_min))
{
// f-step
Expand All @@ -188,7 +188,7 @@ LineSearchInfo BackTrackingLineSearch::find_acceptable_trial_point(double mu, bo
{
// h-step
// check sufficient decrease wrt current iterate
if (CompareLessEqual(cv_next, (1.0 - gamma_theta) * cv_curr) || CompareLessEqual(obj_next, obj_curr - gamma_phi * cv_curr))
if (CompareLessEqual(cv_next, (1.0 - gamma_theta) * cv_curr, cv_curr) || CompareLessEqual(obj_next, obj_curr - gamma_phi * cv_curr, obj_curr))
{
if (!switch_cond || !(armijo))
{
Expand Down

0 comments on commit 622b556

Please sign in to comment.