Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a test. #263

Merged
merged 1 commit into from
Dec 16, 2024
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