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

Base class of implementations of descent methods for optimization. More...

#include <num_collect/opt/descent_method_base.h>

+ Inheritance diagram for num_collect::opt::descent_method_base< Derived, LineSearcher >:
+ Collaboration diagram for num_collect::opt::descent_method_base< Derived, LineSearcher >:

Public Types

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

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.
 

Protected Member Functions

 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.
 

Private Attributes

index_type iterations_ {0}
 Number of iterations.
 
line_searcher_type line_searcher_
 Object to perform line search.
 
value_type tol_grad_norm_ {default_tol_grad_norm}
 Tolerance of norm of gradient.
 

Static Private Attributes

static const auto default_tol_grad_norm
 Default tolerance of norm of gradient.
 

Detailed Description

template<typename Derived, concepts::line_searcher LineSearcher>
class num_collect::opt::descent_method_base< Derived, LineSearcher >

Base class of implementations of descent methods for optimization.

Template Parameters
DerivedType of derived class.
LineSearcherType of class to perform line search.

Definition at line 36 of file descent_method_base.h.

Member Typedef Documentation

◆ line_searcher_type

template<typename Derived , concepts::line_searcher LineSearcher>
using num_collect::opt::descent_method_base< Derived, LineSearcher >::line_searcher_type = LineSearcher

Type of class to perform line search.

Definition at line 39 of file descent_method_base.h.

◆ objective_function_type

template<typename Derived , concepts::line_searcher LineSearcher>
using num_collect::opt::descent_method_base< Derived, LineSearcher >::objective_function_type
Initial value:
typename line_searcher_type::objective_function_type

Type of the objective function.

Definition at line 42 of file descent_method_base.h.

◆ value_type

template<typename Derived , concepts::line_searcher LineSearcher>
using num_collect::opt::descent_method_base< Derived, LineSearcher >::value_type = typename objective_function_type::value_type

Type of function values.

Definition at line 49 of file descent_method_base.h.

◆ variable_type

template<typename Derived , concepts::line_searcher LineSearcher>
using num_collect::opt::descent_method_base< Derived, LineSearcher >::variable_type = typename objective_function_type::variable_type

Type of variables.

Definition at line 46 of file descent_method_base.h.

Constructor & Destructor Documentation

◆ descent_method_base()

template<typename Derived , concepts::line_searcher LineSearcher>
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() )
inlineexplicitprotected

Constructor.

Parameters
[in]tagLog tag.
[in]obj_funObjective function.

Definition at line 170 of file descent_method_base.h.

Member Function Documentation

◆ calc_direction()

template<typename Derived , concepts::line_searcher LineSearcher>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::calc_direction ( ) -> variable_type
inlinenodiscard

Calculate search direction.

Returns
Search direction.

Definition at line 66 of file descent_method_base.h.

◆ evaluations()

template<typename Derived , concepts::line_searcher LineSearcher>
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<typename Derived , concepts::line_searcher LineSearcher>
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<typename Derived , concepts::line_searcher LineSearcher>
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.

◆ init()

template<typename Derived , concepts::line_searcher LineSearcher>
void num_collect::opt::descent_method_base< Derived, LineSearcher >::init ( const variable_type & init_variable)
inline

Initialize.

Parameters
[in]init_variableInitial variable.

Definition at line 56 of file descent_method_base.h.

◆ is_stop_criteria_satisfied()

template<typename Derived , concepts::line_searcher LineSearcher>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::is_stop_criteria_satisfied ( ) const -> bool
inlinenodiscard

Determine if stopping criteria of the algorithm are satisfied.

Returns
If stopping criteria of the algorithm are satisfied.

Definition at line 81 of file descent_method_base.h.

◆ iterate()

template<typename Derived , concepts::line_searcher LineSearcher>
void num_collect::opt::descent_method_base< Derived, LineSearcher >::iterate ( )
inline

Iterate the algorithm once.

Warning
Any required initializations (with init functions) are assumed to have been done.

Definition at line 73 of file descent_method_base.h.

◆ iterations()

template<typename Derived , concepts::line_searcher LineSearcher>
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<typename Derived , concepts::line_searcher LineSearcher>
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<typename Derived , concepts::line_searcher LineSearcher>
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<typename Derived , concepts::line_searcher LineSearcher>
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.

◆ opt_variable()

template<typename Derived , concepts::line_searcher LineSearcher>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::opt_variable ( ) const -> const variable_type&
inlinenodiscard

Get current optimal variable.

Returns
Current optimal variable.

Definition at line 106 of file descent_method_base.h.

◆ tol_gradient_norm()

template<typename Derived , concepts::line_searcher LineSearcher>
auto num_collect::opt::descent_method_base< Derived, LineSearcher >::tol_gradient_norm ( const value_type & value) -> Derived&
inline

Set tolerance of norm of gradient.

Parameters
[in]valueValue.
Returns
This object.

Definition at line 155 of file descent_method_base.h.

Member Data Documentation

◆ default_tol_grad_norm

template<typename Derived , concepts::line_searcher LineSearcher>
const auto num_collect::opt::descent_method_base< Derived, LineSearcher >::default_tol_grad_norm
inlinestaticprivate
Initial value:
=
static_cast<value_type>(1e-3)
typename objective_function_type::value_type value_type
Type of function values.

Default tolerance of norm of gradient.

Definition at line 182 of file descent_method_base.h.

◆ iterations_

template<typename Derived , concepts::line_searcher LineSearcher>
index_type num_collect::opt::descent_method_base< Derived, LineSearcher >::iterations_ {0}
private

Number of iterations.

Definition at line 179 of file descent_method_base.h.

◆ line_searcher_

template<typename Derived , concepts::line_searcher LineSearcher>
line_searcher_type num_collect::opt::descent_method_base< Derived, LineSearcher >::line_searcher_
private

Object to perform line search.

Definition at line 176 of file descent_method_base.h.

◆ tol_grad_norm_

template<typename Derived , concepts::line_searcher LineSearcher>
value_type num_collect::opt::descent_method_base< Derived, LineSearcher >::tol_grad_norm_ {default_tol_grad_norm}
private

Tolerance of norm of gradient.

Definition at line 186 of file descent_method_base.h.


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