Program Listing for File lsparameters.hpp#
↰ Return to documentation for file (source/pele/lsparameters.hpp)
// Copyright (C) 2016-2020 Yixuan Qiu <yixuan.qiu@cos.name>
// Copyright (C) 2016-2020 Dirk Toewe <DirkToewe@GoogleMail.com>
// Under MIT license
#ifndef LINE_SEARCH_NOCEDAL_WRIGHT_H
#define LINE_SEARCH_NOCEDAL_WRIGHT_H
#include <Eigen/Core>
#include <stdexcept>
using Scalar = double;
namespace pele {
enum LINE_SEARCH_TERMINATION_CONDITION {
LINESEARCH_BACKTRACKING_ARMIJO = 1,
LINESEARCH_BACKTRACKING = 2,
LINESEARCH_BACKTRACKING_WOLFE = 2,
LINESEARCH_BACKTRACKING_STRONG_WOLFE = 3
};
class LBFGSParam {
public:
int m;
Scalar epsilon;
Scalar epsilon_rel;
int past;
Scalar delta;
int max_iterations;
int max_linesearch;
Scalar min_step;
Scalar max_step;
Scalar ftol;
Scalar wolfe;
// The linesearch condition for termination
int linesearch;
public:
LBFGSParam(int m_ = 6, Scalar epsilon_ = Scalar(1e-5),
Scalar epsilon_rel_ = Scalar(1e-5), int past_ = 0,
Scalar delta_ = Scalar(0), int max_linesearch_ = 200,
Scalar min_step_ = Scalar(1e-20), Scalar max_step_ = Scalar(1e+20),
Scalar ftol_ = Scalar(1e-4), Scalar wolfe_ = Scalar(0.9),
int linesearch_ = LINESEARCH_BACKTRACKING_STRONG_WOLFE)
: m(m_),
epsilon(epsilon_),
epsilon_rel(epsilon_rel_),
past(past_),
delta(delta_),
max_linesearch(max_linesearch_),
min_step(min_step_),
max_step(max_step_),
ftol(ftol_),
wolfe(wolfe_),
linesearch(linesearch_) {}
inline void check_param() const {
if (m <= 0) throw std::invalid_argument("'m' must be positive");
if (epsilon < 0)
throw std::invalid_argument("'epsilon' must be non-negative");
if (epsilon_rel < 0)
throw std::invalid_argument("'epsilon_rel' must be non-negative");
if (past < 0) throw std::invalid_argument("'past' must be non-negative");
if (delta < 0) throw std::invalid_argument("'delta' must be non-negative");
if (max_iterations < 0)
throw std::invalid_argument("'max_iterations' must be non-negative");
throw std::invalid_argument(
"unsupported line search termination condition");
if (max_linesearch <= 0)
throw std::invalid_argument("'max_linesearch' must be positive");
if (min_step < 0)
throw std::invalid_argument("'min_step' must be positive");
if (max_step < min_step)
throw std::invalid_argument("'max_step' must be greater than 'min_step'");
if (ftol <= 0 || ftol >= 0.5)
throw std::invalid_argument("'ftol' must satisfy 0 < ftol < 0.5");
if (wolfe <= ftol || wolfe >= 1)
throw std::invalid_argument("'wolfe' must satisfy ftol < wolfe < 1");
}
};
} // namespace pele
#endif // LINE_SEARCH_NOCEDAL_WRIGHT_H