<commit_before>#include <assert.h>

#include "coco.h"
#include "coco_problem.c"

typedef struct {
  double factor;
} _puv_data_t;

static void _puv_evaluate_function(coco_problem_t *self, double *x, double *y) {
	_puv_data_t *data = coco_get_transform_data(self);
	assert(coco_get_transform_inner_problem(self) != NULL);
	/*assert(problem->state != NULL);*/

	coco_evaluate_function(coco_get_transform_inner_problem(self), x, y);
	double penalty = 0.0;
	const double *lower_bounds = self->smallest_values_of_interest;
	const double *upper_bounds = self->largest_values_of_interest;
	for (size_t i = 0; i < self->number_of_variables; ++i) {
		assert(lower_bounds[i] < upper_bounds[i]);
		const double c1 = x[i] - upper_bounds[i];
		const double c2 = lower_bounds[i] - x[i];
		if (c1 > 0.0) {
			penalty += c1 * c1;
		} else if (c2 > 0.0) {
			penalty += c2 * c2;
		}
	}
	for (size_t i = 0; i < self->number_of_objectives; ++i) {
		y[i] += data->factor * penalty;
	}
}

/**
 * penalize_uninteresting_values(inner_problem):
 *
 * Add a penalty to all evaluations outside of the region of interest
 * of ${inner_problem}.
 */<commit_msg>modify penalize_uninteresting_values.c<commit_after>#include <assert.h>

#include "coco.h"
#include "coco_problem.c"

typedef struct {
  double factor;
} _puv_data_t;

static void _puv_evaluate_function(coco_problem_t *self, double *x, double *y) {
	_puv_data_t *data = coco_get_transform_data(self);
	assert(coco_get_transform_inner_problem(self) != NULL);
	/*assert(problem->state != NULL);*/

	coco_evaluate_function(coco_get_transform_inner_problem(self), x, y);
	double penalty = 0.0;
	const double *lower_bounds = self->smallest_values_of_interest;
	const double *upper_bounds = self->largest_values_of_interest;
	size_t i;
	for (i = 0; i < self->number_of_variables; ++i) {
		assert(lower_bounds[i] < upper_bounds[i]);
		const double c1 = x[i] - upper_bounds[i];
		const double c2 = lower_bounds[i] - x[i];
		if (c1 > 0.0) {
			penalty += c1 * c1;
		} else if (c2 > 0.0) {
			penalty += c2 * c2;
		}
	}
	for (i = 0; i < self->number_of_objectives; ++i) {
		y[i] += data->factor * penalty;
	}
}

/**
 * penalize_uninteresting_values(inner_problem):
 *
 * Add a penalty to all evaluations outside of the region of interest
 * of ${inner_problem}.
 */
{'fraction_non_alphanumeric': 0.14160839160839161, 'fraction_numerical': 0.013986013986013986, 'mean_word_length': 4.6940298507462686, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2538355', 'n_tokens_mistral': 947, 'n_tokens_neox': 879, 'n_words': 195}