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

Class of dividing rectangles (DIRECT) method [12] for optimization. More...

#include <num_collect/opt/dividing_rectangles.h>

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

Classes

struct  greater_rectangle
 Class to compare rectangles. More...
 
class  rectangle
 Class of hyper rectangle in DIRECT method. More...
 

Public Types

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

 dividing_rectangles (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 (const variable_type &lower, const variable_type &upper)
 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 max_evaluations (index_type value) -> dividing_rectangles &
 Set the maximum number of function evaluations.
 
auto min_rate_imp (value_type value) -> dividing_rectangles &
 Set the minimum rate of improvement in the function value required for potentially optimal rectangles.
 
auto opt_value () const -> const value_type &
 Get current optimal value.
 
auto opt_variable () const -> const variable_type &
 Get current optimal variable.
 
- Public Member Functions inherited from num_collect::opt::optimizer_base< dividing_rectangles< 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< dividing_rectangles< 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< dividing_rectangles< ObjectiveFunction > >
 iteration_logger_mixin ()=default
 Constructor.
 
void configure_iteration_logger (num_collect::logging::iterations::iteration_logger< dividing_rectangles< ObjectiveFunction > > &iteration_logger) const
 Configure an iteration logger.
 
auto initialize_iteration_logger () -> num_collect::logging::iterations::iteration_logger< dividing_rectangles< ObjectiveFunction > > &
 Get the iteration logger.
 

Private Member Functions

auto determine_divided_dimension (const rectangle &rect) -> std::tuple< index_type, value_type, value_type >
 Determine the divided dimension of a rectangle.
 
auto determine_rects () const -> std::vector< std::pair< std::size_t, value_type > >
 Search rectangles to divide.
 
void divide_rect (std::size_t index)
 Divide a rectangle.
 
auto evaluate_on (const variable_type &variable) -> value_type
 Evaluate function value.
 

Static Private Member Functions

static auto calculate_slope (const rectangle &larger_rect, const rectangle &smaller_rect) -> value_type
 Calculate slope.
 
static auto correct_value_if_needed (value_type value) noexcept -> value_type
 Correct function values if needed.
 
static auto separate_section (value_type lowest, value_type highest) -> std::pair< value_type, value_type >
 Separate a section.
 

Private Attributes

index_type dim_ {0}
 Number of dimension.
 
index_type evaluations_ {0}
 Number of function evaluations.
 
index_type iterations_ {0}
 Number of iterations.
 
variable_type lower_ {}
 Element-wise lower limit.
 
index_type max_evaluations_ {default_max_evaluations}
 Maximum number of function evaluations.
 
value_type min_rate_imp_ {default_min_rate_imp}
 Minimum rate of improvement in the function value required for potentially optimal rectangles.
 
objective_function_type obj_fun_
 Objective function.
 
value_type opt_value_ {}
 Current optimal value.
 
variable_type opt_variable_ {}
 Current optimal variable.
 
std::vector< std::priority_queue< std::shared_ptr< rectangle >, std::vector< std::shared_ptr< rectangle > >, greater_rectangle > > rects_ {}
 Rectangles.
 
variable_type upper_ {}
 Element-wise upper limit.
 
variable_type width_ {}
 Element-wise width.
 

Static Private Attributes

static constexpr index_type default_max_evaluations = 10000
 Default maximum number of function evaluations.
 
static const auto default_min_rate_imp
 Default minimum rate of improvement in the function value required for potentially optimal rectangles.
 

Additional Inherited Members

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

Detailed Description

template<concepts::objective_function ObjectiveFunction>
class num_collect::opt::dividing_rectangles< ObjectiveFunction >

Class of dividing rectangles (DIRECT) method [12] for optimization.

Template Parameters
ObjectiveFunctionType of the objective function.

Definition at line 61 of file dividing_rectangles.h.

Member Typedef Documentation

◆ objective_function_type

template<concepts::objective_function ObjectiveFunction>
using num_collect::opt::dividing_rectangles< ObjectiveFunction >::objective_function_type = ObjectiveFunction

Type of the objective function.

Definition at line 68 of file dividing_rectangles.h.

◆ this_type

template<concepts::objective_function ObjectiveFunction>
using num_collect::opt::dividing_rectangles< ObjectiveFunction >::this_type = dividing_rectangles<ObjectiveFunction>

This class.

Definition at line 65 of file dividing_rectangles.h.

◆ value_type

template<concepts::objective_function ObjectiveFunction>
using num_collect::opt::dividing_rectangles< ObjectiveFunction >::value_type = typename objective_function_type::value_type

Type of function values.

Definition at line 74 of file dividing_rectangles.h.

◆ variable_type

template<concepts::objective_function ObjectiveFunction>
using num_collect::opt::dividing_rectangles< ObjectiveFunction >::variable_type = typename objective_function_type::variable_type

Type of variables.

Definition at line 71 of file dividing_rectangles.h.

Constructor & Destructor Documentation

◆ dividing_rectangles()

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

Constructor.

Parameters
[in]obj_funObjective function.

Definition at line 81 of file dividing_rectangles.h.

Member Function Documentation

◆ calculate_slope()

template<concepts::objective_function ObjectiveFunction>
static auto num_collect::opt::dividing_rectangles< ObjectiveFunction >::calculate_slope ( const rectangle & larger_rect,
const rectangle & smaller_rect ) -> value_type
inlinestaticnodiscardprivate

Calculate slope.

Parameters
[in]larger_rectLarger rectangle.
[in]smaller_rectSmaller rectangle.
Returns
Slope.

Definition at line 456 of file dividing_rectangles.h.

◆ change_objective_function()

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

Change the objective function.

Parameters
[in]obj_funObjective function.

Definition at line 92 of file dividing_rectangles.h.

◆ configure_iteration_logger()

template<concepts::objective_function ObjectiveFunction>
void num_collect::opt::dividing_rectangles< 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 157 of file dividing_rectangles.h.

◆ correct_value_if_needed()

template<concepts::objective_function ObjectiveFunction>
static auto num_collect::opt::dividing_rectangles< ObjectiveFunction >::correct_value_if_needed ( value_type value) -> value_type
inlinestaticnodiscardprivatenoexcept

Correct function values if needed.

Parameters
[in]valueFunction value.
Returns
Corrected value.

Definition at line 583 of file dividing_rectangles.h.

◆ determine_divided_dimension()

template<concepts::objective_function ObjectiveFunction>
auto num_collect::opt::dividing_rectangles< ObjectiveFunction >::determine_divided_dimension ( const rectangle & rect) -> std::tuple<index_type, value_type, value_type>
inlinenodiscardprivate

Determine the divided dimension of a rectangle.

Parameters
[in]rectRectangle.
Returns
Dimension index, function value at lower new point, and function value at upper new point.

Definition at line 504 of file dividing_rectangles.h.

◆ determine_rects()

template<concepts::objective_function ObjectiveFunction>
auto num_collect::opt::dividing_rectangles< ObjectiveFunction >::determine_rects ( ) const -> std::vector<std::pair<std::size_t, value_type>>
inlinenodiscardprivate

Search rectangles to divide.

Returns
List of (index in rects_, slope).

Definition at line 405 of file dividing_rectangles.h.

◆ divide_rect()

template<concepts::objective_function ObjectiveFunction>
void num_collect::opt::dividing_rectangles< ObjectiveFunction >::divide_rect ( std::size_t index)
inlineprivate

Divide a rectangle.

Parameters
[in]indexIndex in rects_.

Definition at line 467 of file dividing_rectangles.h.

◆ evaluate_on()

template<concepts::objective_function ObjectiveFunction>
auto num_collect::opt::dividing_rectangles< ObjectiveFunction >::evaluate_on ( const variable_type & variable) -> value_type
inlinenodiscardprivate

Evaluate function value.

Parameters
[in]variableVariable in unit hyper-cube.
Returns
Function value.

Definition at line 382 of file dividing_rectangles.h.

◆ evaluations()

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

Get the number of function evaluations.

Returns
Number of function evaluations.

Definition at line 192 of file dividing_rectangles.h.

◆ init()

template<concepts::objective_function ObjectiveFunction>
void num_collect::opt::dividing_rectangles< ObjectiveFunction >::init ( const variable_type & lower,
const variable_type & upper )
inline

Initialize the algorithm.

Parameters
[in]lowerLower limit.
[in]upperUpper limit.

Definition at line 102 of file dividing_rectangles.h.

◆ is_stop_criteria_satisfied()

template<concepts::objective_function ObjectiveFunction>
auto num_collect::opt::dividing_rectangles< 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 150 of file dividing_rectangles.h.

◆ iterate()

template<concepts::objective_function ObjectiveFunction>
void num_collect::opt::dividing_rectangles< ObjectiveFunction >::iterate ( )
inline

Iterate the algorithm once.

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

Definition at line 138 of file dividing_rectangles.h.

◆ iterations()

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

Get the number of iterations.

Returns
Number of iterations.

Definition at line 185 of file dividing_rectangles.h.

◆ max_evaluations()

template<concepts::objective_function ObjectiveFunction>
auto num_collect::opt::dividing_rectangles< ObjectiveFunction >::max_evaluations ( index_type value) -> dividing_rectangles&
inline

Set the maximum number of function evaluations.

Parameters
[in]valueValue.
Returns
This object.

Definition at line 202 of file dividing_rectangles.h.

◆ min_rate_imp()

template<concepts::objective_function ObjectiveFunction>
auto num_collect::opt::dividing_rectangles< ObjectiveFunction >::min_rate_imp ( value_type value) -> dividing_rectangles&
inline

Set the minimum rate of improvement in the function value required for potentially optimal rectangles.

Parameters
[in]valueValue.
Returns
This object.

Definition at line 217 of file dividing_rectangles.h.

◆ opt_value()

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

Get current optimal value.

Returns
Current optimal value.

Definition at line 178 of file dividing_rectangles.h.

◆ opt_variable()

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

Get current optimal variable.

Returns
Current optimal variable.

Definition at line 171 of file dividing_rectangles.h.

◆ separate_section()

template<concepts::objective_function ObjectiveFunction>
static auto num_collect::opt::dividing_rectangles< ObjectiveFunction >::separate_section ( value_type lowest,
value_type highest ) -> std::pair<value_type, value_type>
inlinestaticnodiscardprivate

Separate a section.

Parameters
[in]lowestLower limit of the section.
[in]highestUpper limit of the section.
Returns
Lower, upper point to separate the section.

Definition at line 569 of file dividing_rectangles.h.

Member Data Documentation

◆ default_max_evaluations

template<concepts::objective_function ObjectiveFunction>
index_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::default_max_evaluations = 10000
staticconstexprprivate

Default maximum number of function evaluations.

Definition at line 630 of file dividing_rectangles.h.

◆ default_min_rate_imp

template<concepts::objective_function ObjectiveFunction>
const auto num_collect::opt::dividing_rectangles< ObjectiveFunction >::default_min_rate_imp
inlinestaticprivate
Initial value:
=
static_cast<value_type>(1e-4)
typename objective_function_type::value_type value_type
Type of function values.

Default minimum rate of improvement in the function value required for potentially optimal rectangles.

Definition at line 639 of file dividing_rectangles.h.

◆ dim_

template<concepts::objective_function ObjectiveFunction>
index_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::dim_ {0}
private

Number of dimension.

Definition at line 615 of file dividing_rectangles.h.

◆ evaluations_

template<concepts::objective_function ObjectiveFunction>
index_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::evaluations_ {0}
private

Number of function evaluations.

Definition at line 627 of file dividing_rectangles.h.

◆ iterations_

template<concepts::objective_function ObjectiveFunction>
index_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::iterations_ {0}
private

Number of iterations.

Definition at line 624 of file dividing_rectangles.h.

◆ lower_

template<concepts::objective_function ObjectiveFunction>
variable_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::lower_ {}
private

Element-wise lower limit.

Definition at line 606 of file dividing_rectangles.h.

◆ max_evaluations_

template<concepts::objective_function ObjectiveFunction>
index_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::max_evaluations_ {default_max_evaluations}
private

Maximum number of function evaluations.

Definition at line 633 of file dividing_rectangles.h.

◆ min_rate_imp_

template<concepts::objective_function ObjectiveFunction>
value_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::min_rate_imp_ {default_min_rate_imp}
private

Minimum rate of improvement in the function value required for potentially optimal rectangles.

Definition at line 646 of file dividing_rectangles.h.

◆ obj_fun_

template<concepts::objective_function ObjectiveFunction>
objective_function_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::obj_fun_
private

Objective function.

Definition at line 594 of file dividing_rectangles.h.

◆ opt_value_

template<concepts::objective_function ObjectiveFunction>
value_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::opt_value_ {}
private

Current optimal value.

Definition at line 621 of file dividing_rectangles.h.

◆ opt_variable_

template<concepts::objective_function ObjectiveFunction>
variable_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::opt_variable_ {}
private

Current optimal variable.

Definition at line 618 of file dividing_rectangles.h.

◆ rects_

template<concepts::objective_function ObjectiveFunction>
std::vector<std::priority_queue<std::shared_ptr<rectangle>, std::vector<std::shared_ptr<rectangle> >, greater_rectangle> > num_collect::opt::dividing_rectangles< ObjectiveFunction >::rects_ {}
private

Rectangles.

Rectangles are listed per size.

Definition at line 603 of file dividing_rectangles.h.

◆ upper_

template<concepts::objective_function ObjectiveFunction>
variable_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::upper_ {}
private

Element-wise upper limit.

Definition at line 609 of file dividing_rectangles.h.

◆ width_

template<concepts::objective_function ObjectiveFunction>
variable_type num_collect::opt::dividing_rectangles< ObjectiveFunction >::width_ {}
private

Element-wise width.

Definition at line 612 of file dividing_rectangles.h.


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