code-experiments/src/transform_vars_shift.c
/**
 * @brief Evaluates the transformed objective function.
 */
@brief Evaluates the transformed objective function.
@brief Evaluates the transformed objective function .
static void transform_vars_shift_evaluate_function(coco_problem_t *problem, const double *x, double *y) {
  size_t i;
  double *cons_values;
  int is_feasible;
  transform_vars_shift_data_t *data;
  coco_problem_t *inner_problem;
  if (coco_vector_contains_nan(x, coco_problem_get_dimension(problem))) {
  	coco_vector_set_to_nan(y, coco_problem_get_number_of_objectives(problem));
  	return;
  }
  data = (transform_vars_shift_data_t *) coco_problem_transformed_get_data(problem);
  inner_problem = coco_problem_transformed_get_inner_problem(problem);
  for (i = 0; i < problem->number_of_variables; ++i) {
    data->shifted_x[i] = x[i] - data->offset[i];
  }
  coco_evaluate_function(inner_problem, data->shifted_x, y);
  if (problem->number_of_constraints > 0) {
    cons_values = coco_allocate_vector(problem->number_of_constraints);
    is_feasible = coco_is_feasible(problem, x, cons_values);
    coco_free_memory(cons_values);    
    if (is_feasible)
      assert(y[0] + 1e-13 >= problem->best_value[0]);
  }
  else assert(y[0] + 1e-13 >= problem->best_value[0]);
}
static void transform_vars_shift_evaluate_function ( coco_problem_t * problem , const double * x , double * y ) { size_t i ; double * cons_values ; int is_feasible ; transform_vars_shift_data_t * data ; coco_problem_t * inner_problem ; if ( coco_vector_contains_nan ( x , coco_problem_get_dimension ( problem ) ) ) { coco_vector_set_to_nan ( y , coco_problem_get_number_of_objectives ( problem ) ) ; return ; } data = ( transform_vars_shift_data_t * ) coco_problem_transformed_get_data ( problem ) ; inner_problem = coco_problem_transformed_get_inner_problem ( problem ) ; for ( i = 0 ; i < problem -> number_of_variables ; ++ i ) { data -> shifted_x [ i ] = x [ i ] - data -> offset [ i ] ; } coco_evaluate_function ( inner_problem , data -> shifted_x , y ) ; if ( problem -> number_of_constraints > 0 ) { cons_values = coco_allocate_vector ( problem -> number_of_constraints ) ; is_feasible = coco_is_feasible ( problem , x , cons_values ) ; coco_free_memory ( cons_values ) ; if ( is_feasible ) assert ( y [ 0 ] + 1e-13 >= problem -> best_value [ 0 ] ) ; } else assert ( y [ 0 ] + 1e-13 >= problem -> best_value [ 0 ] ) ; }
@brief Evaluates the transformed objective function.
@brief Evaluates the transformed objective function .