numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
|
Class of downhill simplex method [20]. More...
#include <num_collect/opt/downhill_simplex.h>
Public Types | |
using | objective_function_type = ObjectiveFunction |
Type of the objective function. | |
enum class | process_type : std::uint8_t { none , reflection , reflection_and_expansion , contraction , multiple_contraction } |
Type of processes. More... | |
using | this_type = downhill_simplex<ObjectiveFunction> |
This class. | |
using | value_type = typename objective_function_type::value_type |
Type of function values. | |
using | variable_scalar_type = typename variable_type::Scalar |
Type of scalars in variables. | |
using | variable_type = typename objective_function_type::variable_type |
Type of variables. | |
Public Member Functions | |
downhill_simplex (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 &init_var, const variable_scalar_type &width=default_width) |
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 | last_process () const noexcept -> process_type |
Get last process. | |
auto | last_process_name () const noexcept -> std::string_view |
Get the name of the last process. | |
auto | opt_value () const -> const value_type & |
Get current optimal value. | |
auto | opt_variable () const -> const variable_type & |
Get current optimal variable. | |
auto | simplex_size () const -> variable_scalar_type |
Get the size of simplex. | |
auto | tol_simplex_size (const variable_scalar_type &value) -> downhill_simplex & |
Set tolerance of size of simplex. | |
Public Member Functions inherited from num_collect::opt::optimizer_base< downhill_simplex< 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< downhill_simplex< 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< downhill_simplex< ObjectiveFunction > > | |
iteration_logger_mixin ()=default | |
Constructor. | |
void | configure_iteration_logger (num_collect::logging::iterations::iteration_logger< downhill_simplex< ObjectiveFunction > > &iteration_logger) const |
Configure an iteration logger. | |
auto | initialize_iteration_logger () -> num_collect::logging::iterations::iteration_logger< downhill_simplex< ObjectiveFunction > > & |
Get the iteration logger. | |
Static Public Member Functions | |
static auto | process_name (process_type process) -> std::string_view |
Convert type of process to string. | |
Static Public Attributes | |
static const auto | default_width |
Default width of simplex. | |
Private Member Functions | |
auto | calc_face_center () const -> variable_type |
Calculate center of the face composed from points other than highest point. | |
void | contract (const variable_type &face_center) |
Contract the highest point to the opposite face. | |
auto | evaluate_on (const variable_type &variable) |
Evaluate function value. | |
void | expand (const variable_type &face_center) |
Expand the simplex. | |
void | multi_contract () |
Contract all points other than the lowest point toward the lowest point. | |
void | reflect (const variable_type &face_center) |
Reflect the highest point. | |
void | reorder () |
Reorder function values. | |
Private Attributes | |
index_type | dim_ {0} |
Number of dimension. | |
index_type | evaluations_ {0} |
Number of function evaluations. | |
index_type | iterations_ {0} |
Number of iterations. | |
index_type | max_iterations_ {default_max_iterations} |
Maximum number of iterations. | |
objective_function_type | obj_fun_ |
Objective function. | |
std::vector< variable_type, Eigen::aligned_allocator< variable_type > > | points_ {} |
Points. | |
process_type | process_ {process_type::none} |
Last process. | |
variable_scalar_type | tol_simplex_size_ {default_tol_simplex_size} |
Tolerance of size of simplex. | |
std::vector< std::size_t > | value_order_ {} |
Order of function values (ascending order). | |
std::vector< value_type > | values_ {} |
Function values. | |
Static Private Attributes | |
static constexpr index_type | default_max_iterations = 1000 |
Default maximum number of iterations. | |
static const auto | default_tol_simplex_size |
Default tolerance of size of simplex. | |
static const auto | half = static_cast<variable_scalar_type>(0.5) |
Half. | |
static const auto | twice = static_cast<variable_scalar_type>(2.0) |
Two. | |
Additional Inherited Members | |
Protected Member Functions inherited from num_collect::base::iterative_solver_base< downhill_simplex< ObjectiveFunction > > | |
auto | derived () const noexcept -> const downhill_simplex< ObjectiveFunction > & |
Access derived object. | |
auto | derived () const noexcept -> const downhill_simplex< ObjectiveFunction > & |
Access derived object. | |
auto | derived () noexcept -> downhill_simplex< ObjectiveFunction > & |
Access derived object. | |
auto | derived () noexcept -> downhill_simplex< ObjectiveFunction > & |
Access derived object. | |
Class of downhill simplex method [20].
ObjectiveFunction | Type of the objective function. |
Definition at line 59 of file downhill_simplex.h.
using num_collect::opt::downhill_simplex< ObjectiveFunction >::objective_function_type = ObjectiveFunction |
Type of the objective function.
Definition at line 66 of file downhill_simplex.h.
using num_collect::opt::downhill_simplex< ObjectiveFunction >::this_type = downhill_simplex<ObjectiveFunction> |
This class.
Definition at line 63 of file downhill_simplex.h.
using num_collect::opt::downhill_simplex< ObjectiveFunction >::value_type = typename objective_function_type::value_type |
Type of function values.
Definition at line 75 of file downhill_simplex.h.
using num_collect::opt::downhill_simplex< ObjectiveFunction >::variable_scalar_type = typename variable_type::Scalar |
Type of scalars in variables.
Definition at line 72 of file downhill_simplex.h.
using num_collect::opt::downhill_simplex< ObjectiveFunction >::variable_type = typename objective_function_type::variable_type |
Type of variables.
Definition at line 69 of file downhill_simplex.h.
|
strong |
Type of processes.
Enumerator | |
---|---|
none | None. |
reflection | Reflection. |
reflection_and_expansion | Reflection and expansion. |
contraction | Contraction. |
multiple_contraction | Multiple contraction. |
Definition at line 78 of file downhill_simplex.h.
|
inlineexplicit |
Constructor.
[in] | obj_fun | Objective function. |
Definition at line 115 of file downhill_simplex.h.
|
inlinenodiscardprivate |
Calculate center of the face composed from points other than highest point.
Definition at line 322 of file downhill_simplex.h.
|
inline |
Change the objective function.
[in] | obj_fun | Objective function. |
Definition at line 126 of file downhill_simplex.h.
|
inline |
Configure an iteration logger.
[in] | iteration_logger | Iteration logger. |
Definition at line 203 of file downhill_simplex.h.
|
inlineprivate |
Contract the highest point to the opposite face.
[in] | face_center | Center of the face composed from points other than highest point. |
Definition at line 369 of file downhill_simplex.h.
|
inlinenodiscardprivate |
Evaluate function value.
[in] | variable | Variable. |
Definition at line 300 of file downhill_simplex.h.
|
inlinenodiscardnoexcept |
Get the number of function evaluations.
Definition at line 245 of file downhill_simplex.h.
|
inlineprivate |
Expand the simplex.
[in] | face_center | Center of the face composed from points other than highest point. |
Definition at line 356 of file downhill_simplex.h.
|
inline |
Initialize the algorithm.
[in] | init_var | An initial variable. |
[in] | width | Width of the initial simplex. |
Definition at line 136 of file downhill_simplex.h.
|
inlinenodiscard |
Determine if stopping criteria of the algorithm are satisfied.
Definition at line 195 of file downhill_simplex.h.
|
inline |
Iterate the algorithm once.
init
functions) are assumed to have been done. Definition at line 169 of file downhill_simplex.h.
|
inlinenodiscardnoexcept |
Get the number of iterations.
Definition at line 238 of file downhill_simplex.h.
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Get the name of the last process.
Definition at line 263 of file downhill_simplex.h.
|
inlineprivate |
Contract all points other than the lowest point toward the lowest point.
Definition at line 380 of file downhill_simplex.h.
|
inlinenodiscard |
Get current optimal value.
Definition at line 231 of file downhill_simplex.h.
|
inlinenodiscard |
Get current optimal variable.
Definition at line 224 of file downhill_simplex.h.
|
inlinestaticnodiscard |
Convert type of process to string.
[in] | process | Type of process. |
Definition at line 92 of file downhill_simplex.h.
|
inlineprivate |
Reflect the highest point.
[in] | face_center | Center of the face composed from points other than highest point. |
Definition at line 343 of file downhill_simplex.h.
|
inlineprivate |
Reorder function values.
Definition at line 309 of file downhill_simplex.h.
|
inlinenodiscard |
|
inline |
Set tolerance of size of simplex.
[in] | value | Value. |
Definition at line 287 of file downhill_simplex.h.
|
staticconstexprprivate |
Default maximum number of iterations.
Definition at line 423 of file downhill_simplex.h.
|
inlinestaticprivate |
Default tolerance of size of simplex.
Definition at line 416 of file downhill_simplex.h.
|
inlinestatic |
|
private |
Number of dimension.
Definition at line 394 of file downhill_simplex.h.
|
private |
Number of function evaluations.
Definition at line 413 of file downhill_simplex.h.
|
inlinestaticprivate |
Half.
Definition at line 335 of file downhill_simplex.h.
|
private |
Number of iterations.
Definition at line 410 of file downhill_simplex.h.
|
private |
Maximum number of iterations.
Definition at line 426 of file downhill_simplex.h.
|
private |
Objective function.
Definition at line 391 of file downhill_simplex.h.
|
private |
Points.
Definition at line 398 of file downhill_simplex.h.
|
private |
Last process.
Definition at line 407 of file downhill_simplex.h.
|
private |
Tolerance of size of simplex.
Definition at line 420 of file downhill_simplex.h.
|
inlinestaticprivate |
Two.
Definition at line 332 of file downhill_simplex.h.
|
private |
Order of function values (ascending order).
Definition at line 404 of file downhill_simplex.h.
|
private |
Function values.
Definition at line 401 of file downhill_simplex.h.