Template Class base

Inheritance Relationships

Derived Type

Class Documentation

template<class InputType>
class ioh::problem::base

A base class for defining problems.

Basic structure for IOHExperimenter, which is used for generating benchmark problems. To define a new problem, the ‘internal_evaluate’ method must be defined. The problem sets as maximization by default. If the ‘best_variables’ are given, the optimal of the problem will be calculated with the ‘best_variables’; or you can set the optimal by defining the ‘customized_optimal’ function; otherwise, the optimal is set as min()(max()) for maximization(minimization). If additional calculation is needed by ‘internal_evaluate’, you can configure it in ‘prepare_problem()’.

Subclassed by ioh::problem::python::ExternPythonProblem< InputType >

Public Functions

base(int instance_id = IOH_DEFAULT_INSTANCE, int dimension = IOH_DEFAULT_DIMENSION)

< to record optimization process.

base(const base&) = delete
base &operator=(const base&) = delete
double internal_evaluate(const std::vector<InputType> &x)

A virtual internal evaluate function.

The internal_evaluate function is to be used in evaluate function. This function must be decalred in derived function of new problems.

void prepare_problem()
double evaluate(std::vector<InputType> x)

A common function for evaluating fitness of problems.

Raw evaluate process, tranformation operations, and logging process are excuted in this function.

Return

A double vector of objectives.

Parameters
  • x: A InputType vector of variables.

void objectives_transformation(const std::vector<InputType> &x, std::vector<double> &y, const int transformation_id, const int instance_id)
void variables_transformation(std::vector<InputType> &x, const int transformation_id, const int instance_id)
void customize_optimal()
void calc_optimal()

A function to calculate optimal of the problem. It will be invoked after setting dimension (number_of_variables) or instance_id.

void reset_problem()

Reset problem as the default condition before doing evaluating.

Todo:

To support constrained optimization.

std::vector<double> loggerCOCOInfo() const
std::vector<double> loggerInfo() const
bool hit_optimal() const

Detect if the optimal have been found.

int get_problem_id() const
void set_problem_id(int problem_id)
int get_instance_id() const
void set_instance_id(int instance_id)

To set instance_id of the problem. Since the optimal will be updated as instanced_id updated, calc_optimal() is revoked here.

Parameters
  • instance_id:

std::string get_problem_name() const
void set_problem_name(std::string problem_name)
std::string get_problem_type() const
void set_problem_type(std::string problem_type)
std::vector<InputType> get_lowerbound() const
void set_lowerbound(InputType lowerbound)
void set_lowerbound(const std::vector<InputType> &lowerbound)
std::vector<InputType> get_upperbound() const
void set_upperbound(InputType upperbound)
void set_upperbound(const std::vector<InputType> &upperbound)
int get_number_of_variables() const
void set_number_of_variables(int number_of_variables)

To set number_of_variables of the problem. When the number_of_variables is updated, best_variables, lowerbound, upperbound, and optimal need to be updated as well.

To set number_of_variables of the problem. When the number_of_variables is updated, best_variables, lowerbound, upperbound, and optimal need to be updated as well. In case the best value for each bit is not staic, another input ‘best_variables’ is supplied.

Parameters
  • number_of_variables:

Parameters
  • number_of_variablesbest_variables:

void set_number_of_variables(int number_of_variables, const std::vector<InputType> &best_variables)
int get_number_of_objectives() const
void set_number_of_objectives(int number_of_objectives)
std::vector<double> get_raw_objectives() const
std::vector<double> get_transformed_objectives() const
int get_transformed_number_of_variables() const
std::vector<InputType> get_transformed_variables() const
std::vector<InputType> get_best_variables() const
void set_best_variables(InputType best_variables)
void set_best_variables(const std::vector<InputType> &best_variables)
bool has_optimal() const
std::vector<double> get_optimal() const
void set_optimal(double optimal)
void set_optimal(const std::vector<double> &optimal)
void evaluate_optimal(std::vector<InputType> best_variables)
void evaluate_optimal()
int get_evaluations() const
std::vector<double> get_best_so_far_raw_objectives() const
int get_best_so_far_raw_evaluations() const
std::vector<double> get_best_so_far_transformed_objectives() const
int get_best_so_far_transformed_evaluations() const
common::optimization_type get_optimization_type() const
void set_as_maximization()
void set_as_minimization()