Param.h
Go to the documentation of this file.
1 // Copyright (C) 2016 Yixuan Qiu <yixuan.qiu@cos.name>
2 // Under MIT license
3 
4 #ifndef PARAM_H
5 #define PARAM_H
6 
7 #include <Eigen/Core>
8 #include <stdexcept> // std::invalid_argument
9 
10 
11 namespace LBFGSpp {
12 
13 
19 
26 {
38 
44 
54 
64 };
65 
66 
70 template <typename Scalar = double>
72 {
73 public:
82  int m;
91  Scalar epsilon;
100  int past;
109  Scalar delta;
135  Scalar min_step;
141  Scalar max_step;
147  Scalar ftol;
155  Scalar wolfe;
156 
157 public:
163  {
164  m = 6;
165  epsilon = Scalar(1e-5);
166  past = 0;
167  delta = Scalar(0);
168  max_iterations = 0;
170  max_linesearch = 20;
171  min_step = Scalar(1e-20);
172  max_step = Scalar(1e+20);
173  ftol = Scalar(1e-4);
174  wolfe = Scalar(0.9);
175  }
176 
182  inline void check_param() const
183  {
184  if(m <= 0)
185  throw std::invalid_argument("'m' must be positive");
186  if(epsilon <= 0)
187  throw std::invalid_argument("'epsilon' must be positive");
188  if(past < 0)
189  throw std::invalid_argument("'past' must be non-negative");
190  if(delta < 0)
191  throw std::invalid_argument("'delta' must be non-negative");
192  if(max_iterations < 0)
193  throw std::invalid_argument("'max_iterations' must be non-negative");
194  if(linesearch < LBFGS_LINESEARCH_BACKTRACKING_ARMIJO ||
196  throw std::invalid_argument("unsupported line search algorithm");
197  if(max_linesearch <= 0)
198  throw std::invalid_argument("'max_linesearch' must be positive");
199  if(min_step < 0)
200  throw std::invalid_argument("'min_step' must be positive");
201  if(max_step < min_step )
202  throw std::invalid_argument("'max_step' must be greater than 'min_step'");
203  if(ftol <= 0 || ftol >= 0.5)
204  throw std::invalid_argument("'ftol' must satisfy 0 < ftol < 0.5");
205  if(wolfe <= ftol || wolfe >= 1)
206  throw std::invalid_argument("'wolfe' must satisfy ftol < wolfe < 1");
207  }
208 };
209 
210 
211 } // namespace LBFGSpp
212 
213 #endif // PARAM_H
void check_param() const
Definition: Param.h:182
Scalar min_step
Definition: Param.h:135
Definition: LBFGS.h:11
Scalar epsilon
Definition: Param.h:91
LINE_SEARCH_ALGORITHM
Definition: Param.h:25
Scalar max_step
Definition: Param.h:141


co_scan
Author(s):
autogenerated on Mon Feb 28 2022 23:00:45