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

Class of golden section search method. More...

#include <num_collect/opt/golden_section_search.h>

+ Inheritance diagram for num_collect::opt::golden_section_search< ObjectiveFunction >:
+ Collaboration diagram for num_collect::opt::golden_section_search< ObjectiveFunction >:

Public Types

using objective_function_type = ObjectiveFunction
 Type of the objective function.
 
using this_type = golden_section_search<ObjectiveFunction>
 This type.
 
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

 golden_section_search (const objective_function_type &obj_fun=objective_function_type())
 Constructor.
 
void change_objective_function (const objective_function_type &obj_fun)
 Change the objective function.
 
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.
 
void init (variable_type end1, variable_type end2)
 Initialize the algorithm.
 
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 opt_value () const -> const value_type &
 Get current optimal value.
 
auto opt_variable () const -> const variable_type &
 Get current optimal variable.
 
auto section_len () const -> variable_type
 Get length of section between end points.
 
auto tol_section_len (variable_type value) -> golden_section_search &
 Set the tolerance of length of section between end points.
 
- Public Member Functions inherited from num_collect::opt::optimizer_base< golden_section_search< ObjectiveFunction > >
 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< golden_section_search< ObjectiveFunction > >
 iterative_solver_base (logging::log_tag_view tag)
 Constructor.
 
 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.
 
auto is_stop_criteria_satisfied () const -> bool
 Determine if stopping criteria of the algorithm are satisfied.
 
void iterate ()
 Iterate the algorithm once.
 
void iterate ()
 Iterate the algorithm once.
 
void solve ()
 Solve the problem.
 
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< golden_section_search< ObjectiveFunction > >
 iteration_logger_mixin ()=default
 Constructor.
 
void configure_iteration_logger (num_collect::logging::iterations::iteration_logger< golden_section_search< ObjectiveFunction > > &iteration_logger) const
 Configure an iteration logger.
 
auto initialize_iteration_logger () -> num_collect::logging::iterations::iteration_logger< golden_section_search< ObjectiveFunction > > &
 Get the iteration logger.
 

Static Public Attributes

static const auto default_tol_section_len
 Default tolerance of length of section between end points.
 
static const auto mid_point_ratio
 Ratio of middle point.
 

Private Attributes

variable_type end1_ {}
 An end point.
 
variable_type end2_ {}
 Another end point.
 
index_type iterations_ {0}
 Number of iterations.
 
variable_type mid1_ {}
 Middle point near to end1_.
 
objective_function_type obj_fun_
 Objective function.
 
variable_type tol_section_len_ {default_tol_section_len}
 Tolerance of length of section between end points.
 
value_type value1_ {}
 Function value on end1_.
 

Additional Inherited Members

- Protected Member Functions inherited from num_collect::base::iterative_solver_base< golden_section_search< ObjectiveFunction > >
auto derived () const noexcept -> const golden_section_search< ObjectiveFunction > &
 Access derived object.
 
auto derived () const noexcept -> const golden_section_search< ObjectiveFunction > &
 Access derived object.
 
auto derived () noexcept -> golden_section_search< ObjectiveFunction > &
 Access derived object.
 
auto derived () noexcept -> golden_section_search< ObjectiveFunction > &
 Access derived object.
 

Detailed Description

template<concepts::single_variate_objective_function ObjectiveFunction>
class num_collect::opt::golden_section_search< ObjectiveFunction >

Class of golden section search method.

Template Parameters
ObjectiveFunctionType of the objective function.

Definition at line 42 of file golden_section_search.h.

Member Typedef Documentation

◆ objective_function_type

template<concepts::single_variate_objective_function ObjectiveFunction>
using num_collect::opt::golden_section_search< ObjectiveFunction >::objective_function_type = ObjectiveFunction

Type of the objective function.

Definition at line 49 of file golden_section_search.h.

◆ this_type

template<concepts::single_variate_objective_function ObjectiveFunction>
using num_collect::opt::golden_section_search< ObjectiveFunction >::this_type = golden_section_search<ObjectiveFunction>

This type.

Definition at line 46 of file golden_section_search.h.

◆ value_type

template<concepts::single_variate_objective_function ObjectiveFunction>
using num_collect::opt::golden_section_search< ObjectiveFunction >::value_type = typename objective_function_type::value_type

Type of function values.

Definition at line 55 of file golden_section_search.h.

◆ variable_type

template<concepts::single_variate_objective_function ObjectiveFunction>
using num_collect::opt::golden_section_search< ObjectiveFunction >::variable_type = typename objective_function_type::variable_type

Type of variables.

Definition at line 52 of file golden_section_search.h.

Constructor & Destructor Documentation

◆ golden_section_search()

template<concepts::single_variate_objective_function ObjectiveFunction>
num_collect::opt::golden_section_search< ObjectiveFunction >::golden_section_search ( const objective_function_type & obj_fun = objective_function_type())
inlineexplicit

Constructor.

Parameters
[in]obj_funObjective function.

Definition at line 62 of file golden_section_search.h.

Member Function Documentation

◆ change_objective_function()

template<concepts::single_variate_objective_function ObjectiveFunction>
void num_collect::opt::golden_section_search< ObjectiveFunction >::change_objective_function ( const objective_function_type & obj_fun)
inline

Change the objective function.

Parameters
[in]obj_funObjective function.

Definition at line 73 of file golden_section_search.h.

◆ configure_iteration_logger()

template<concepts::single_variate_objective_function ObjectiveFunction>
void num_collect::opt::golden_section_search< ObjectiveFunction >::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 135 of file golden_section_search.h.

◆ evaluations()

template<concepts::single_variate_objective_function ObjectiveFunction>
auto num_collect::opt::golden_section_search< ObjectiveFunction >::evaluations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of function evaluations.

Returns
Number of function evaluations.

Definition at line 170 of file golden_section_search.h.

◆ init()

template<concepts::single_variate_objective_function ObjectiveFunction>
void num_collect::opt::golden_section_search< ObjectiveFunction >::init ( variable_type end1,
variable_type end2 )
inline

Initialize the algorithm.

Parameters
[in]end1An end point.
[in]end2Another end point.

Definition at line 83 of file golden_section_search.h.

◆ is_stop_criteria_satisfied()

template<concepts::single_variate_objective_function ObjectiveFunction>
auto num_collect::opt::golden_section_search< ObjectiveFunction >::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 128 of file golden_section_search.h.

◆ iterate()

template<concepts::single_variate_objective_function ObjectiveFunction>
void num_collect::opt::golden_section_search< ObjectiveFunction >::iterate ( )
inline

Iterate the algorithm once.

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

Definition at line 108 of file golden_section_search.h.

◆ iterations()

template<concepts::single_variate_objective_function ObjectiveFunction>
auto num_collect::opt::golden_section_search< ObjectiveFunction >::iterations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of iterations.

Returns
Number of iterations.

Definition at line 163 of file golden_section_search.h.

◆ opt_value()

template<concepts::single_variate_objective_function ObjectiveFunction>
auto num_collect::opt::golden_section_search< ObjectiveFunction >::opt_value ( ) const -> const value_type&
inlinenodiscard

Get current optimal value.

Returns
Current optimal value.

Definition at line 156 of file golden_section_search.h.

◆ opt_variable()

template<concepts::single_variate_objective_function ObjectiveFunction>
auto num_collect::opt::golden_section_search< ObjectiveFunction >::opt_variable ( ) const -> const variable_type&
inlinenodiscard

Get current optimal variable.

Returns
Current optimal variable.

Definition at line 149 of file golden_section_search.h.

◆ section_len()

template<concepts::single_variate_objective_function ObjectiveFunction>
auto num_collect::opt::golden_section_search< ObjectiveFunction >::section_len ( ) const -> variable_type
inlinenodiscard

Get length of section between end points.

Returns
Length of section between end points.

Definition at line 179 of file golden_section_search.h.

◆ tol_section_len()

template<concepts::single_variate_objective_function ObjectiveFunction>
auto num_collect::opt::golden_section_search< ObjectiveFunction >::tol_section_len ( variable_type value) -> golden_section_search&
inline

Set the tolerance of length of section between end points.

Parameters
[in]valueTolerance of length of section between end points.
Returns
This object.

Definition at line 100 of file golden_section_search.h.

Member Data Documentation

◆ default_tol_section_len

template<concepts::single_variate_objective_function ObjectiveFunction>
const auto num_collect::opt::golden_section_search< ObjectiveFunction >::default_tol_section_len
inlinestatic
Initial value:
=
static_cast<variable_type>(1e-3)
typename objective_function_type::variable_type variable_type
Type of variables.

Default tolerance of length of section between end points.

Definition at line 189 of file golden_section_search.h.

◆ end1_

template<concepts::single_variate_objective_function ObjectiveFunction>
variable_type num_collect::opt::golden_section_search< ObjectiveFunction >::end1_ {}
private

An end point.

Definition at line 197 of file golden_section_search.h.

◆ end2_

template<concepts::single_variate_objective_function ObjectiveFunction>
variable_type num_collect::opt::golden_section_search< ObjectiveFunction >::end2_ {}
private

Another end point.

Definition at line 200 of file golden_section_search.h.

◆ iterations_

template<concepts::single_variate_objective_function ObjectiveFunction>
index_type num_collect::opt::golden_section_search< ObjectiveFunction >::iterations_ {0}
private

Number of iterations.

Definition at line 209 of file golden_section_search.h.

◆ mid1_

template<concepts::single_variate_objective_function ObjectiveFunction>
variable_type num_collect::opt::golden_section_search< ObjectiveFunction >::mid1_ {}
private

Middle point near to end1_.

Definition at line 203 of file golden_section_search.h.

◆ mid_point_ratio

template<concepts::single_variate_objective_function ObjectiveFunction>
const auto num_collect::opt::golden_section_search< ObjectiveFunction >::mid_point_ratio
inlinestatic
Initial value:
=
static_cast<variable_type>((3.0 - std::sqrt(5.0)) / 2.0)

Ratio of middle point.

Definition at line 185 of file golden_section_search.h.

◆ obj_fun_

template<concepts::single_variate_objective_function ObjectiveFunction>
objective_function_type num_collect::opt::golden_section_search< ObjectiveFunction >::obj_fun_
private

Objective function.

Definition at line 194 of file golden_section_search.h.

◆ tol_section_len_

template<concepts::single_variate_objective_function ObjectiveFunction>
variable_type num_collect::opt::golden_section_search< ObjectiveFunction >::tol_section_len_ {default_tol_section_len}
private

Tolerance of length of section between end points.

Definition at line 212 of file golden_section_search.h.

◆ value1_

template<concepts::single_variate_objective_function ObjectiveFunction>
value_type num_collect::opt::golden_section_search< ObjectiveFunction >::value1_ {}
private

Function value on end1_.

Definition at line 206 of file golden_section_search.h.


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