diff --git a/tests/differential_evaluation_mh_producer_01.cc b/tests/differential_evaluation_mh_producer_01.cc index 3b2eb34..9848378 100644 --- a/tests/differential_evaluation_mh_producer_01.cc +++ b/tests/differential_evaluation_mh_producer_01.cc @@ -95,7 +95,18 @@ std::pair perturb (const SampleType &x) SampleType crossover(const SampleType ¤t_sample, const SampleType &sample_a, const SampleType &sample_b) { - return current_sample + (2.38 * sqrt(2)) * (sample_a - sample_b); + const SampleType min = 1; + const SampleType max = 100; + const SampleType x_tilde = static_cast(current_sample + + (2.38 * sqrt(2)) * (sample_a - sample_b)); + + // Wrap around the interval [1...100] + if (x_tilde < min) + return x_tilde + (max-min+1); + else if (x_tilde > max) + return x_tilde - (max-min+1); + else + return x_tilde; } int main ()