50template <concepts::
objective_function ObjectiveFunction>
58template <concepts::multi_variate_
objective_function ObjectiveFunction>
75 using value_type =
typename objective_function_type::value_type;
100 return "reflection and expansion";
102 return "contraction";
104 return "multiple contraction";
106 return "invalid process";
138 dim_ = init_var.size();
159 for (std::size_t i = 0; i < util::safe_cast<std::size_t>(
dim_ + 1);
172 const auto second_max_ind =
206 iteration_logger.template append<index_type>(
208 iteration_logger.template append<index_type>(
210 iteration_logger.template append<value_type>(
212 iteration_logger.template append<variable_scalar_type>(
216 .template append<std::string_view>(
218 ->width(process_width);
311 [
this](std::size_t i, std::size_t j) {
324 for (std::size_t i = 0; i < util::safe_cast<std::size_t>(
dim_); ++i) {
382 for (std::size_t i = 1; i <= util::safe_cast<std::size_t>(
dim_); ++i) {
397 std::vector<variable_type, Eigen::aligned_allocator<variable_type>>
Class to write logs of iterations.
Class of tags of logs without memory management.
typename variable_type::Scalar variable_scalar_type
Type of scalars in variables.
void contract(const variable_type &face_center)
Contract the highest point to the opposite face.
void expand(const variable_type &face_center)
Expand the simplex.
process_type process_
Last process.
std::vector< std::size_t > value_order_
Order of function values (ascending order).
process_type
Type of processes.
@ reflection_and_expansion
Reflection and expansion.
@ contraction
Contraction.
@ multiple_contraction
Multiple contraction.
auto opt_variable() const -> const variable_type &
Get current optimal variable.
auto evaluate_on(const variable_type &variable)
Evaluate function value.
void reorder()
Reorder function values.
static auto process_name(process_type process) -> std::string_view
Convert type of process to string.
auto is_stop_criteria_satisfied() const -> bool
Determine if stopping criteria of the algorithm are satisfied.
auto last_process_name() const noexcept -> std::string_view
Get the name of the last process.
index_type iterations_
Number of iterations.
index_type max_iterations_
Maximum number of iterations.
typename objective_function_type::value_type value_type
Type of function values.
static const auto half
Half.
ObjectiveFunction objective_function_type
Type of the objective function.
auto calc_face_center() const -> variable_type
Calculate center of the face composed from points other than highest point.
static const auto twice
Two.
auto iterations() const noexcept -> index_type
Get the number of iterations.
index_type evaluations_
Number of function evaluations.
variable_scalar_type tol_simplex_size_
Tolerance of size of simplex.
auto simplex_size() const -> variable_scalar_type
Get the size of simplex.
downhill_simplex(const objective_function_type &obj_fun=objective_function_type())
Constructor.
objective_function_type obj_fun_
Objective function.
auto tol_simplex_size(const variable_scalar_type &value) -> downhill_simplex &
Set tolerance of size of simplex.
index_type dim_
Number of dimension.
std::vector< value_type > values_
Function values.
typename objective_function_type::variable_type variable_type
Type of variables.
void iterate()
Iterate the algorithm once.
std::vector< variable_type, Eigen::aligned_allocator< variable_type > > points_
Points.
static const auto default_width
Default width of simplex.
void reflect(const variable_type &face_center)
Reflect the highest point.
auto evaluations() const noexcept -> index_type
Get the number of function evaluations.
void change_objective_function(const objective_function_type &obj_fun)
Change the objective function.
void multi_contract()
Contract all points other than the lowest point toward the lowest point.
auto opt_value() const -> const value_type &
Get current optimal value.
downhill_simplex< ObjectiveFunction > this_type
This class.
void configure_iteration_logger(logging::iterations::iteration_logger< this_type > &iteration_logger) const
Configure an iteration logger.
auto last_process() const noexcept -> process_type
Get last process.
static constexpr index_type default_max_iterations
Default maximum number of iterations.
static const auto default_tol_simplex_size
Default tolerance of size of simplex.
void init(const variable_type &init_var, const variable_scalar_type &width=default_width)
Initialize the algorithm.
Class of downhill simplex method.
optimizer_base(logging::log_tag_view tag)
Definition of index_type type.
Definition of iteration_logger class.
Definition of log_tag_view class.
Definition of multi_variate_objective_function concept.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of optimization algorithms.
constexpr auto downhill_simplex_tag
Tag of downhill_simplex.
auto safe_cast(const From &value) -> To
Cast safely.
Definition of objective_function concept.
Definition of optimizer_base class.
Definition of safe_cast function.