74 [[nodiscard]]
auto value() const noexcept -> const
double& {
84 -> const
Eigen::ArrayXd& {
94 -> const
Eigen::ArrayXd& {
153 num_local_optima >= 2,
"num_local_optima must be at least 2.");
163 Eigen::ArrayXd optimal_variables;
165 std::generate(optimal_variables.begin(), optimal_variables.end(),
166 [
this] { return optimal_variable_dist_(generator_); });
168 Eigen::ArrayXd optimal_values;
171 std::generate(optimal_values.begin() + 1, optimal_values.end(),
172 [
this] { return non_global_optimal_value_dist_(generator_); });
174 Eigen::ArrayXd coefficients;
176 std::generate(coefficients.begin(), coefficients.end(),
177 [
this] { return coefficients_dist_(generator_); });
180 std::move(optimal_variables), std::move(optimal_values),
181 std::move(coefficients)};
Class to generate random single_variate_multi_optima_function objects.
static constexpr num_collect::index_type default_num_local_optima
Default value of the number of local optima.
std::uniform_real_distribution< double > coefficients_dist_
Distribution of coefficients.
std::uniform_real_distribution< double > non_global_optimal_value_dist_
Distribution of non-global optimal values.
static constexpr double max_variable
Maximum optimal variable.
auto operator()() noexcept -> single_variate_multi_optima_function
Generate a function.
num_collect::index_type num_local_optima_
Number of local minima.
std::mt19937 generator_
Random number generator.
static constexpr double max_non_global_optimal_value
Maximum non-global optimal value.
static constexpr double global_optimal_value
Global optimal value.
std::uniform_real_distribution< double > optimal_variable_dist_
Distribution of optimal variables.
static constexpr double min_variable
Minimum optimal variable.
static constexpr double min_non_global_optimal_value
Minimum non-global optimal value.
random_single_variate_multi_optima_function_generator(num_collect::index_type num_local_optima=default_num_local_optima)
Constructor.
Class of functions of single-variate optimization problems with multiple local optima.
double variable_type
Type of variables.
double value_type
Type of function values.
Eigen::ArrayXd coefficients_
Coefficients for optima.
single_variate_multi_optima_function(Eigen::ArrayXd optimal_variables, Eigen::ArrayXd optimal_values, Eigen::ArrayXd coefficients)
Constructor.
void evaluate_on(double variable) noexcept
Evaluate function value on variable.
auto optimal_variables() const noexcept -> const Eigen::ArrayXd &
Get the optimal variables.
auto coefficients() const noexcept -> const Eigen::ArrayXd &
Get the coefficients for optima.
Eigen::ArrayXd optimal_variables_
Optimal variables.
double value_
Function value.
auto optimal_values() const noexcept -> const Eigen::ArrayXd &
Get the optimal values.
auto value() const noexcept -> const double &
Get function value.
Eigen::ArrayXd optimal_values_
Optimal values.
Definition of exceptions.
Definition of index_type type.
Definition of macros for logging.
Namespace of Eigen library.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of optimization problems.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.