numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
|
Class to perform optimization using samples of objective functions. More...
#include <num_collect/opt/sampling_optimizer.h>
Public Types | |
using | objective_function_type = ObjectiveFunction |
Type of the objective function. | |
using | this_type = sampling_optimizer<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 | |
sampling_optimizer (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< sampling_optimizer< ObjectiveFunction > > &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 | lower () const -> const variable_type & |
Get the current lower limit. | |
auto | max_iterations (index_type value) -> sampling_optimizer & |
Set the maximum number of iterations. | |
auto | num_samples (index_type value) -> sampling_optimizer & |
Set the number of samples. | |
auto | opt_value () const -> const value_type & |
Get current optimal value. | |
auto | opt_variable () const -> const variable_type & |
Get current optimal variable. | |
auto | upper () const -> const variable_type & |
Get the current upper limit. | |
Public Member Functions inherited from num_collect::opt::optimizer_base< sampling_optimizer< 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< sampling_optimizer< 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< sampling_optimizer< ObjectiveFunction > > | |
iteration_logger_mixin ()=default | |
Constructor. | |
void | configure_iteration_logger (num_collect::logging::iterations::iteration_logger< sampling_optimizer< ObjectiveFunction > > &iteration_logger) const |
Configure an iteration logger. | |
auto | initialize_iteration_logger () -> num_collect::logging::iterations::iteration_logger< sampling_optimizer< ObjectiveFunction > > & |
Get the iteration logger. | |
Private Attributes | |
index_type | evaluations_ {0} |
Number of function evaluations. | |
std::size_t | ind_opt_sample_ {0} |
Index of the minimum sampling point. | |
index_type | iterations_ {0} |
Number of iterations. | |
variable_type | lower_ {static_cast<variable_type>(0)} |
Lower limit. | |
index_type | max_iterations_ {default_max_iterations} |
Maximum number of iterations. | |
index_type | num_samples_ {default_num_samples} |
Number of sampling points. | |
objective_function_type | obj_fun_ |
Objective function. | |
std::vector< variable_type > | samples_ {} |
List of sampling points. | |
variable_type | upper_ {static_cast<variable_type>(1)} |
Upper limit. | |
std::vector< value_type > | values_ {} |
List of function values. | |
Static Private Attributes | |
static constexpr index_type | default_max_iterations = 3 |
Default maximum number of iterations. | |
static constexpr index_type | default_num_samples = 21 |
Default number of sampling points. | |
Additional Inherited Members | |
Protected Member Functions inherited from num_collect::base::iterative_solver_base< sampling_optimizer< ObjectiveFunction > > | |
auto | derived () const noexcept -> const sampling_optimizer< ObjectiveFunction > & |
Access derived object. | |
auto | derived () const noexcept -> const sampling_optimizer< ObjectiveFunction > & |
Access derived object. | |
auto | derived () noexcept -> sampling_optimizer< ObjectiveFunction > & |
Access derived object. | |
auto | derived () noexcept -> sampling_optimizer< ObjectiveFunction > & |
Access derived object. | |
Class to perform optimization using samples of objective functions.
ObjectiveFunction | Type of the objective function. |
Definition at line 57 of file sampling_optimizer.h.
using num_collect::opt::sampling_optimizer< ObjectiveFunction >::objective_function_type = ObjectiveFunction |
Type of the objective function.
Definition at line 64 of file sampling_optimizer.h.
using num_collect::opt::sampling_optimizer< ObjectiveFunction >::this_type = sampling_optimizer<ObjectiveFunction> |
This class.
Definition at line 61 of file sampling_optimizer.h.
using num_collect::opt::sampling_optimizer< ObjectiveFunction >::value_type = typename objective_function_type::value_type |
Type of function values.
Definition at line 70 of file sampling_optimizer.h.
using num_collect::opt::sampling_optimizer< ObjectiveFunction >::variable_type = typename objective_function_type::variable_type |
Type of variables.
Definition at line 67 of file sampling_optimizer.h.
|
inlineexplicit |
Constructor.
[in] | obj_fun | Objective function. |
Definition at line 77 of file sampling_optimizer.h.
|
inline |
Change the objective function.
[in] | obj_fun | Objective function. |
Definition at line 88 of file sampling_optimizer.h.
|
inline |
Configure an iteration logger.
[in] | iteration_logger | Iteration logger. |
Definition at line 158 of file sampling_optimizer.h.
|
inlinenodiscardnoexcept |
Get the number of function evaluations.
Definition at line 206 of file sampling_optimizer.h.
|
inline |
Initialize the algorithm.
[in] | lower | Lower limit. |
[in] | upper | Upper limit. |
Definition at line 98 of file sampling_optimizer.h.
|
inlinenodiscard |
Determine if stopping criteria of the algorithm are satisfied.
Definition at line 151 of file sampling_optimizer.h.
|
inline |
Iterate the algorithm once.
init
functions) are assumed to have been done. Definition at line 111 of file sampling_optimizer.h.
|
inlinenodiscardnoexcept |
Get the number of iterations.
Definition at line 199 of file sampling_optimizer.h.
|
inlinenodiscard |
Get the current lower limit.
Definition at line 194 of file sampling_optimizer.h.
|
inline |
Set the maximum number of iterations.
[in] | value | Value. |
Definition at line 229 of file sampling_optimizer.h.
|
inline |
Set the number of samples.
[in] | value | Value. |
Definition at line 216 of file sampling_optimizer.h.
|
inlinenodiscard |
Get current optimal value.
Definition at line 178 of file sampling_optimizer.h.
|
inlinenodiscard |
Get current optimal variable.
Definition at line 171 of file sampling_optimizer.h.
|
inlinenodiscard |
Get the current upper limit.
Definition at line 187 of file sampling_optimizer.h.
|
staticconstexprprivate |
Default maximum number of iterations.
Definition at line 262 of file sampling_optimizer.h.
|
staticconstexprprivate |
Default number of sampling points.
Definition at line 256 of file sampling_optimizer.h.
|
private |
Number of function evaluations.
Definition at line 271 of file sampling_optimizer.h.
|
private |
Index of the minimum sampling point.
Definition at line 253 of file sampling_optimizer.h.
|
private |
Number of iterations.
Definition at line 268 of file sampling_optimizer.h.
|
private |
Lower limit.
Definition at line 241 of file sampling_optimizer.h.
|
private |
Maximum number of iterations.
Definition at line 265 of file sampling_optimizer.h.
|
private |
Number of sampling points.
Definition at line 259 of file sampling_optimizer.h.
|
private |
Objective function.
Definition at line 238 of file sampling_optimizer.h.
|
private |
List of sampling points.
Definition at line 247 of file sampling_optimizer.h.
|
private |
Upper limit.
Definition at line 244 of file sampling_optimizer.h.
|
private |
List of function values.
Definition at line 250 of file sampling_optimizer.h.