numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver > Class Template Reference

Class of newton method for optimization. More...

#include <num_collect/opt/newton_optimizer.h>

+ Inheritance diagram for num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >:
+ Collaboration diagram for num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >:

Public Types

using base_type = descent_method_base<this_type, LineSearcher>
 Type of base class.
 
using hessian_solver_type = HessianSolver
 Type of solvers of linear equation of Hessian.
 
using hessian_type = typename objective_function_type::hessian_type
 Type of Hessian.
 
using objective_function_type
 Type of the objective function.
 
using this_type
 This class.
 
using value_type
 Type of function values.
 
using variable_type
 Type of variables.
 
- Public Types inherited from num_collect::opt::descent_method_base< Derived, LineSearcher >
using line_searcher_type = LineSearcher
 Type of class to perform line search.
 
using objective_function_type
 Type of the objective function.
 
using value_type = typename objective_function_type::value_type
 Type of function values.
 
using variable_type = typename objective_function_type::variable_type
 Type of variables.
 

Public Member Functions

 newton_optimizer (const objective_function_type &obj_fun=objective_function_type())
 Constructor.
 
auto calc_direction () -> variable_type
 Calculate search direction.
 
void configure_iteration_logger (logging::iterations::iteration_logger< this_type > &iteration_logger) const
 Configure an iteration logger.
 
auto evaluations () const noexcept -> index_type
 Get the number of function evaluations.
 
auto gradient () const -> const variable_type &
 Get gradient for current optimal variable.
 
auto gradient_norm () const -> value_type
 Calculate norm of gradient.
 
auto hessian () const -> const hessian_type &
 Get Hessian for current optimal variable.
 
auto iterations () const noexcept -> index_type
 Get the number of iterations.
 
auto line_searcher () -> line_searcher_type &
 Access object to perform line search.
 
auto line_searcher () const -> const line_searcher_type &
 Access object to perform line search.
 
auto opt_value () const -> const value_type &
 Get current optimal value.
 
- Public Member Functions inherited from num_collect::opt::descent_method_base< Derived, LineSearcher >
auto calc_direction () -> variable_type
 Calculate search direction.
 
auto evaluations () const noexcept -> index_type
 Get the number of function evaluations.
 
auto gradient () const -> const variable_type &
 Get gradient for current optimal variable.
 
auto gradient_norm () const -> value_type
 Calculate norm of gradient.
 
void init (const variable_type &init_variable)
 Initialize.
 
auto is_stop_criteria_satisfied () const -> bool
 Determine if stopping criteria of the algorithm are satisfied.
 
void iterate ()
 Iterate the algorithm once.
 
auto iterations () const noexcept -> index_type
 Get the number of iterations.
 
auto line_searcher () -> line_searcher_type &
 Access object to perform line search.
 
auto line_searcher () const -> const line_searcher_type &
 Access object to perform line search.
 
auto opt_value () const -> const value_type &
 Get current optimal value.
 
auto opt_variable () const -> const variable_type &
 Get current optimal variable.
 
auto tol_gradient_norm (const value_type &value) -> Derived &
 Set tolerance of norm of gradient.
 
- Public Member Functions inherited from num_collect::opt::optimizer_base< Derived >
 optimizer_base (logging::log_tag_view tag)
 Constructor.
 
auto evaluations () const noexcept -> index_type
 Get the number of function evaluations.
 
auto iterations () const noexcept -> index_type
 Get the number of iterations.
 
auto opt_value () const
 Get current optimal value.
 
auto opt_variable () const
 Get current optimal variable.
 
- Public Member Functions inherited from num_collect::base::iterative_solver_base< Derived >
 iterative_solver_base (logging::log_tag_view tag)
 Constructor.
 
auto is_stop_criteria_satisfied () const -> bool
 Determine if stopping criteria of the algorithm are satisfied.
 
void iterate ()
 Iterate the algorithm once.
 
void solve ()
 Solve the problem.
 
- Public Member Functions inherited from num_collect::logging::logging_mixin
 logging_mixin (log_tag_view tag)
 Constructor.
 
template<typename Child >
void configure_child_algorithm_logger_if_exists (Child &child)
 Configure a logger of a child algorithm if exists.
 
auto logger () const noexcept -> const num_collect::logging::logger &
 Access to the logger.
 
auto logger () noexcept -> num_collect::logging::logger &
 Access to the logger.
 
- Public Member Functions inherited from num_collect::logging::iterations::iteration_logger_mixin< Derived >
 iteration_logger_mixin ()=default
 Constructor.
 
void configure_iteration_logger (num_collect::logging::iterations::iteration_logger< Derived > &iteration_logger) const
 Configure an iteration logger.
 
auto initialize_iteration_logger () -> num_collect::logging::iterations::iteration_logger< Derived > &
 Get the iteration logger.
 

Private Member Functions

auto calc_direction_impl (const hessian_type &hessian) -> variable_type
 Calculate search direction.
 

Private Attributes

hessian_solver_type solver_
 Solver of linear equation of Hessian.
 

Additional Inherited Members

- Protected Member Functions inherited from num_collect::opt::descent_method_base< Derived, LineSearcher >
 descent_method_base (logging::log_tag_view tag, const objective_function_type &obj_fun=objective_function_type())
 Constructor.
 
- Protected Member Functions inherited from num_collect::base::iterative_solver_base< Derived >
auto derived () const noexcept -> const Derived &
 Access derived object.
 
auto derived () noexcept -> Derived &
 Access derived object.
 

Detailed Description

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
class num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >

Class of newton method for optimization.

Template Parameters
ObjectiveFunctionType of the objective function.
LineSearcherType of class to perform line search.
HessianSolverType of solvers of linear equation of Hessian.

Definition at line 51 of file newton_optimizer.h.

Member Typedef Documentation

◆ base_type

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
using num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::base_type = descent_method_base<this_type, LineSearcher>

Type of base class.

Definition at line 61 of file newton_optimizer.h.

◆ hessian_solver_type

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
using num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::hessian_solver_type = HessianSolver

Type of solvers of linear equation of Hessian.

Definition at line 70 of file newton_optimizer.h.

◆ hessian_type

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
using num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::hessian_type = typename objective_function_type::hessian_type

Type of Hessian.

Definition at line 67 of file newton_optimizer.h.

◆ objective_function_type

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
using num_collect::opt::descent_method_base< Derived, LineSearcher >::objective_function_type

Type of the objective function.

Definition at line 42 of file descent_method_base.h.

◆ this_type

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
using num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::this_type
Initial value:
newton_optimizer(const objective_function_type &obj_fun=objective_function_type())
Constructor.

This class.

Definition at line 57 of file newton_optimizer.h.

◆ value_type

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
using num_collect::opt::descent_method_base< Derived, LineSearcher >::value_type

Type of function values.

Definition at line 49 of file descent_method_base.h.

◆ variable_type

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
using num_collect::opt::descent_method_base< Derived, LineSearcher >::variable_type

Type of variables.

Definition at line 46 of file descent_method_base.h.

Constructor & Destructor Documentation

◆ newton_optimizer()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::newton_optimizer ( const objective_function_type & obj_fun = objective_function_type())
inlineexplicit

Constructor.

Parameters
[in]obj_funObjective function.

Definition at line 77 of file newton_optimizer.h.

Member Function Documentation

◆ calc_direction()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::calc_direction ( ) -> variable_type
inlinenodiscard

Calculate search direction.

Returns
Search direction.

Definition at line 101 of file newton_optimizer.h.

◆ calc_direction_impl()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::calc_direction_impl ( const hessian_type & hessian) -> variable_type
inlinenodiscardprivate

Calculate search direction.

Parameters
[in]hessianHessian.
Returns
Search direction.

Definition at line 128 of file newton_optimizer.h.

◆ configure_iteration_logger()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
void num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::configure_iteration_logger ( logging::iterations::iteration_logger< this_type > & iteration_logger) const
inline

Configure an iteration logger.

Parameters
[in]iteration_loggerIteration logger.

Definition at line 108 of file newton_optimizer.h.

◆ evaluations()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::evaluations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of function evaluations.

Returns
Number of function evaluations.

Definition at line 127 of file descent_method_base.h.

◆ gradient()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::gradient ( ) const -> const variable_type&
inlinenodiscard

Get gradient for current optimal variable.

Returns
Gradient for current optimal variable.

Definition at line 136 of file descent_method_base.h.

◆ gradient_norm()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::gradient_norm ( ) const -> value_type
inlinenodiscard

Calculate norm of gradient.

Returns
Norm of gradient.

Definition at line 145 of file descent_method_base.h.

◆ hessian()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::hessian ( ) const -> const hessian_type&
inlinenodiscard

Get Hessian for current optimal variable.

Returns
Hessian for current optimal variable.

Definition at line 94 of file newton_optimizer.h.

◆ iterations()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::iterations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of iterations.

Returns
Number of iterations.

Definition at line 120 of file descent_method_base.h.

◆ line_searcher() [1/2]

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::line_searcher ( ) -> line_searcher_type&
inlinenodiscard

Access object to perform line search.

Returns
Object to perform line search.

Definition at line 90 of file descent_method_base.h.

◆ line_searcher() [2/2]

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::line_searcher ( ) const -> const line_searcher_type&
inlinenodiscard

Access object to perform line search.

Returns
Object to perform line search.

Definition at line 99 of file descent_method_base.h.

◆ opt_value()

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::opt_value ( ) const -> const value_type&
inlinenodiscard

Get current optimal value.

Returns
Current optimal value.

Definition at line 113 of file descent_method_base.h.

Member Data Documentation

◆ solver_

template<concepts::multi_variate_twice_differentiable_objective_function ObjectiveFunction, concepts::line_searcher LineSearcher = backtracking_line_searcher<ObjectiveFunction>, typename HessianSolver = Eigen::LLT<typename ObjectiveFunction::hessian_type>>
hessian_solver_type num_collect::opt::newton_optimizer< ObjectiveFunction, LineSearcher, HessianSolver >::solver_
private

Solver of linear equation of Hessian.

Definition at line 135 of file newton_optimizer.h.


The documentation for this class was generated from the following file: