3 #include "../common.hpp"
37 check(
static_cast<bool>(_hessFun),
"Hessian function must be set for Newton solver");
39 for (_iters = 0; _iters < _max_iters; ++_iters) {
41 double gnorm = g.norm();
42 if (gnorm <= _tol)
break;
45 check(H.rows() == H.cols(),
"Hessian must be square");
46 check(H.rows() == g.size(),
"Hessian/gradient size mismatch");
51 const double max_mu = reg_max;
53 while (mu <= max_mu) {
55 Hreg += mu * M::Identity(H.rows(), H.cols());
58 if (ldlt.info() == Eigen::Success) {
60 if (ldlt.info() == Eigen::Success && p.dot(g) < 0.0) {
72 double alpha = line_search(x, p, f, Gradient);
81 double reg_init = 1e-6;
83 double reg_growth = 10.0;
Base class for Full Batch Minimizers.
Definition: full_batch_minimizer.hpp:23
double _tol
Definition: full_batch_minimizer.hpp:109
double line_search(V x, V p, VecFun< V, double > &f, GradFun< V > &Gradient)
Backtracking Line Search satisfying Wolfe Conditions.
Definition: full_batch_minimizer.hpp:126
unsigned int _iters
Definition: full_batch_minimizer.hpp:108
unsigned int _max_iters
Definition: full_batch_minimizer.hpp:107
Newton minimizer (full Newton) for unconstrained optimization.
Definition: newton.hpp:13
V solve(V x, VecFun< V, double > &f, GradFun< V > &Gradient) override
Solves the unconstrained optimization problem using Newton's Method.
Definition: newton.hpp:34
void setHessian(const HessFun< V, M > &hessFun) noexcept
Sets the Hessian function for computing the second derivative matrix.
Definition: newton.hpp:25
std::function< T(T)> GradFun
Gradient function type alias (T -> T).
Definition: common.hpp:32
std::function< W(T)> VecFun
Objective function type alias (T -> W).
Definition: common.hpp:35
#define check(condition, message)
Debug assertion with message and source location.
Definition: common.hpp:14
std::function< M(V)> HessFun
Hessian function type alias (V -> M).
Definition: common.hpp:38