Ejemplo n.º 1
0
/**
 * Perform monotone oscillation transformation on input variables.
 */
static coco_problem_t *f_transform_vars_brs(coco_problem_t *inner_problem) {
  transform_vars_brs_data_t *data;
  coco_problem_t *self;
  data = coco_allocate_memory(sizeof(*data));
  data->x = coco_allocate_vector(inner_problem->number_of_variables);
  self = coco_transformed_allocate(inner_problem, data, transform_vars_brs_free);
  self->evaluate_function = transform_vars_brs_evaluate;
  return self;
}
Ejemplo n.º 2
0
/**
 * Oscillate the objective value of the inner problem.
 *
 * Caveat: this can change best_parameter and best_value. 
 */
static coco_problem_t *f_transform_obj_oscillate(coco_problem_t *inner_problem) {
  coco_problem_t *self;
  self = coco_transformed_allocate(inner_problem, NULL, NULL);
  self->evaluate_function = transform_obj_oscillate_evaluate;
  /* Compute best value */
  /* Maybe not the most efficient solution */
  transform_obj_oscillate_evaluate(self, self->best_parameter, self->best_value);
  return self;
}
/**
 * Perform monotone oscillation(?) transformation on input variables.
 */
static coco_problem_t *f_transform_vars_conditioning(coco_problem_t *inner_problem, const double alpha) {
  transform_vars_conditioning_data_t *data;
  coco_problem_t *self;
  data = coco_allocate_memory(sizeof(*data));
  data->x = coco_allocate_vector(inner_problem->number_of_variables);
  data->alpha = alpha;
  self = coco_transformed_allocate(inner_problem, data, transform_vars_conditioning_free);
  self->evaluate_function = transform_vars_conditioning_evaluate;
  return self;
}
/**
 * Perform monotone oscillation transformation on input variables.
 */
static coco_problem_t *f_transform_vars_asymmetric(coco_problem_t *inner_problem, const double beta) {
  transform_vars_asymmetric_data_t *data;
  coco_problem_t *self;
  data = coco_allocate_memory(sizeof(*data));
  data->x = coco_allocate_vector(inner_problem->number_of_variables);
  data->beta = beta;
  self = coco_transformed_allocate(inner_problem, data, transform_vars_asymmetric_free);
  self->evaluate_function = transform_vars_asymmetric_evaluate;
  return self;
}
Ejemplo n.º 5
0
/**
 * Shift the objective value of the inner problem by offset.
 */
static coco_problem_t *f_transform_obj_shift(coco_problem_t *inner_problem, const double offset) {
  coco_problem_t *self;
  transform_obj_shift_data_t *data;
  data = coco_allocate_memory(sizeof(*data));
  data->offset = offset;

  self = coco_transformed_allocate(inner_problem, data, NULL);
  self->evaluate_function = transform_obj_shift_evaluate;
  self->best_value[0] += offset; /* FIXME: shifts only the first objective */
  return self;
}
Ejemplo n.º 6
0
/*
 * Shift all variables of ${inner_problem} by ${offset}.
 */
static coco_problem_t *f_transform_vars_shift(coco_problem_t *inner_problem,
                                              const double *offset,
                                              const int shift_bounds) {
  transform_vars_shift_data_t *data;
  coco_problem_t *self;
  if (shift_bounds)
    coco_error("shift_bounds not implemented.");

  data = coco_allocate_memory(sizeof(*data));
  data->offset = coco_duplicate_vector(offset, inner_problem->number_of_variables);
  data->shifted_x = coco_allocate_vector(inner_problem->number_of_variables);

  self = coco_transformed_allocate(inner_problem, data, transform_vars_shift_free);
  self->evaluate_function = transform_vars_shift_evaluate;
  return self;
}
Ejemplo n.º 7
0
static coco_problem_t *logger_bbob2009(coco_problem_t *inner_problem, const char *alg_name) {
  logger_bbob2009_t *data;
  coco_problem_t *self;
  data = coco_allocate_memory(sizeof(*data));
  data->alg_name = coco_strdup(alg_name);
  if (bbob2009_logger_is_open)
    coco_error("The current bbob2009_logger (observer) must be closed before a new one is opened");
  /* This is the name of the folder which happens to be the algName */
  data->path = coco_strdup(alg_name);
  data->index_file = NULL;
  data->fdata_file = NULL;
  data->tdata_file = NULL;
  data->rdata_file = NULL;
  data->number_of_variables = inner_problem->number_of_variables;
  if (inner_problem->best_value == NULL) {
    /* coco_error("Optimal f value must be defined for each problem in order for the logger to work properly"); */
    /* Setting the value to 0 results in the assertion y>=optimal_fvalue being susceptible to failure */
    coco_warning("undefined optimal f value. Set to 0");
    data->optimal_fvalue = 0;
  } else {
    data->optimal_fvalue = *(inner_problem->best_value);
  }
  bbob2009_raisedOptValWarning = 0;

  data->idx_f_trigger = INT_MAX;
  data->idx_t_trigger = 0;
  data->idx_tdim_trigger = 0;
  data->f_trigger = DBL_MAX;
  data->t_trigger = 0;
  data->number_of_evaluations = 0;
  data->best_solution = coco_allocate_vector(inner_problem->number_of_variables);
  /* TODO: the following inits are just to be in the safe side and
   * should eventually be removed. Some fields of the bbob2009_logger struct
   * might be useless
   */
  data->function_id = coco_problem_get_suite_dep_function_id(inner_problem);
  data->instance_id = coco_problem_get_suite_dep_instance_id(inner_problem);
  data->written_last_eval = 1;
  data->last_fvalue = DBL_MAX;
  data->is_initialized = 0;

  self = coco_transformed_allocate(inner_problem, data, logger_bbob2009_free);
  self->evaluate_function = logger_bbob2009_evaluate;
  bbob2009_logger_is_open = 1;
  return self;
}
Ejemplo n.º 8
0
/*
 * Perform an affine transformation of the variable vector:
 *
 *   x |-> Mx + b
 *
 * The matrix M is stored in row-major format.
 */
static coco_problem_t *f_transform_vars_affine(coco_problem_t *inner_problem,
                                               const double *M,
                                               const double *b,
                                               const size_t number_of_variables) {
  coco_problem_t *self;
  transform_vars_affine_data_t *data;
  size_t entries_in_M;

  entries_in_M = inner_problem->number_of_variables * number_of_variables;
  data = coco_allocate_memory(sizeof(*data));
  data->M = coco_duplicate_vector(M, entries_in_M);
  data->b = coco_duplicate_vector(b, inner_problem->number_of_variables);
  data->x = coco_allocate_vector(inner_problem->number_of_variables);

  self = coco_transformed_allocate(inner_problem, data, transform_vars_affine_free);
  self->evaluate_function = transform_vars_affine_evaluate;
  return self;
}
Ejemplo n.º 9
0
/**
 * Initializes the toy logger.
 */
static coco_problem_t *logger_toy(coco_observer_t *observer, coco_problem_t *problem) {

  logger_toy_t *logger;
  coco_problem_t *self;
  FILE *output_file;

  if (problem->number_of_objectives != 1) {
    coco_warning("logger_toy(): The toy logger shouldn't be used to log a problem with %d objectives", problem->number_of_objectives);
  }

  logger = coco_allocate_memory(sizeof(*logger));
  logger->observer = observer;
  logger->next_target = 0;
  logger->number_of_evaluations = 0;

  output_file = ((observer_toy_t *) logger->observer->data)->log_file;
  fprintf(output_file, "\n%s, %s\n", coco_problem_get_id(problem), coco_problem_get_name(problem));

  self = coco_transformed_allocate(problem, logger, NULL);
  self->evaluate_function = logger_toy_evaluate;
  return self;
}