Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/differential_evaluation_mh_producer_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,18 @@ std::pair<SampleType,double> perturb (const SampleType &x)

SampleType crossover(const SampleType &current_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<SampleType>(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 ()
Expand Down