Skip to content

Latest commit

 

History

History
 
 

Problems

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Problems of IOHexperimenter

IOHprofiler_problem is the base class of problems of IOHexperimenter. The property variables of problems include:

  • problem_id, will be assigned if the problem is added to a suite, otherwise default by 0.

  • instance_id, sets transformation methods on problems. The original problem is with instance_id 1, scale and shift are applied on objectives for instance_id in [2,100], XOR is applied on variables for instance_id in [2,50], and sigma function is applied on variables for instance_id in [51,100].

  • problem_name

  • problem_type

  • lowerbound, is a vector of lowerbound for variables.

  • upperbound, is a vector of upperbound for variables.

  • number_of_variables, is the dimension of the problem.

  • number_of_objectives, is only available as 1 now. The functionality of multi-objectives is under development.

  • best_variables, is a vector of optimal solution, which is used to calculate the optimum. If the best_variables is not given, the optimum will be set as DBL_MAX.

  • optimal, is a vector of optimal objectives, but currently only single objective is supported.

  • evaluate_int_info, is a vector of int values that are iteratively used in evaluate.

  • evaluate_double_info, is a vector of double values that are iteratively used in evaluate.

And some functions for personal experiments are supplied:

  • evaluate(x), returns a vector of fitness values. The argument x is a vector of variables.
  • evaluate(x,y), updates y with a vector of fitness values, and x is a vector of variables.
  • addCSVLogger(logger), assigns a IOHprofiler_csv_logger class to the problem.
  • clearLogger(), delete logger methods of the problem.
  • reset_problem(), reset the history information of problem evaluations. You should call this function at first when you plan to do another test on the same problem class.
  • IOHprofiler_hit_optimal(), returns true if the optimum of the problem has been found.
  • IOHprofiler_set_number_of_variables(number_of_variables), sets dimension of the problem.
  • IOHprofiler_set_instance_id(instance_id)

Creating a problem

IOHexperimenter provides a variety of problems for testing algorithms, but it is also easy to add your own problems. Overall, to create a problem of IOHexperimenter, two functions need to be implemented: construct functions and internel_evaluate. Additionally, you can define update_evaluate_double_info and update_evaluate_int_info to make evluate process more efficiently.

Taking the implementation of OneMax as an instance, construct functions are as below. problem_name and number_of_objectives must be set. In general, two methods of construction of the problems are given. One is constructing without giving instance_id and dimension, and the other one is with.

OneMax() {
  IOHprofiler_set_problem_name("OneMax");
  IOHprofiler_set_problem_type("pseudo_Boolean_problem");
  IOHprofiler_set_number_of_objectives(1);
  IOHprofiler_set_lowerbound(0);
  IOHprofiler_set_upperbound(1);
  IOHprofiler_set_best_variables(1);
}

OneMax(int instance_id, int dimension) {
  IOHprofiler_set_instance_id(instance_id);
  IOHprofiler_set_problem_name("OneMax");
  IOHprofiler_set_problem_type("pseudo_Boolean_problem");
  IOHprofiler_set_number_of_objectives(1);
  IOHprofiler_set_lowerbound(0);
  IOHprofiler_set_upperbound(1);
  IOHprofiler_set_best_variables(1);
  Initilize_problem(dimension);
}
  
~OneMax() {};

void Initilize_problem(int dimension) {
  IOHprofiler_set_number_of_variables(dimension);
  IOHprofiler_set_optimal((double)dimension);
};

The internal_evaluate must be implemented as well. It is used during evaluate process, returning a vector of (real) objective values of the corresponding variables x.

std::vector<double> internal_evaluate(std::vector<int> x) {
  std::vector<double> y;
  int n = x.size();
  int result = 0;
  for (int i = 0; i != n; ++i) {
    result += x[i];
  }
  y.push_back((double)result);
  return y;
};

If you want to register your problem by problem_name and add it into a suite, please add functions creating instances as following codes.

static OneMax * createInstance() {
  return new OneMax();
};

static OneMax * createInstance(int instance_id, int dimension) {
  return new OneMax(instance_id, dimension);
};

To register the problem, you can use the geniricGenerator in IOHprofiler_class_generator. For example, you can use the following statement to register and create OneMax ,

// Register
static registerInFactory<IOHprofiler_problem<int>,OneMax> regOneMax("OneMax");
// Create
std::shared_ptr<IOHprofiler_problem<int>> problem = genericGenerator<IOHprofiler_problem<int>>::instance().create("OneMax");