Skip to content

Commit 7396ea4

Browse files
committed
Fix a test.
1 parent 1e534f2 commit 7396ea4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/differential_evaluation_mh_producer_01.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,18 @@ std::pair<SampleType,double> perturb (const SampleType &x)
9595

9696
SampleType crossover(const SampleType &current_sample, const SampleType &sample_a, const SampleType &sample_b)
9797
{
98-
return current_sample + (2.38 * sqrt(2)) * (sample_a - sample_b);
98+
const SampleType min = 1;
99+
const SampleType max = 100;
100+
const SampleType x_tilde = static_cast<SampleType>(current_sample +
101+
(2.38 * sqrt(2)) * (sample_a - sample_b));
102+
103+
// Wrap around the interval [1...100]
104+
if (x_tilde < min)
105+
return x_tilde + (max-min+1);
106+
else if (x_tilde > max)
107+
return x_tilde - (max-min+1);
108+
else
109+
return x_tilde;
99110
}
100111

101112
int main ()

0 commit comments

Comments
 (0)