17 template <
typename Scalar>
40 template <
typename Foo>
41 static void Backtracking(Foo& f, Scalar& fx, Vector& x, Vector& grad,
43 const Vector& drt,
const Vector& xp,
47 const Scalar dec = 0.5;
48 const Scalar inc = 2.1;
52 std::invalid_argument(
"'step' must be positive");
55 const Scalar fx_init = fx;
57 const Scalar dg_init = grad.dot(drt);
60 std::logic_error(
"the moving direction increases the objective function value");
62 const Scalar dg_test = param.
ftol * dg_init;
69 x.noalias() = xp + step * drt;
73 if(fx > fx_init + step * dg_test)
81 const Scalar dg = grad.dot(drt);
82 if(dg < param.
wolfe * dg_init)
90 if(dg > -param.
wolfe * dg_init)
101 throw std::runtime_error(
"the line search routine reached the maximum number of iterations");
104 throw std::runtime_error(
"the line search step became smaller than the minimum value allowed");
107 throw std::runtime_error(
"the line search step became larger than the maximum value allowed");
117 #endif // LINE_SEARCH_H
static void Backtracking(Foo &f, Scalar &fx, Vector &x, Vector &grad, Scalar &step, const Vector &drt, const Vector &xp, const LBFGSParam< Scalar > ¶m)
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector