I am trying to randomize this random_number generator, however , as i am new to c++ I am struggling to do so. any suggestions as to what steps i should take ?
i have posted the function i am using below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void mutate(double mutation_rate, genome &gen)
{
static default_random_engine e(duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count());
static uniform_real_distribution<double> dist;
double rnd;
auto num_threads = thread::hardware_concurrency();
#pragma omp parallel for num_threads(num_threads)
for (signedint bit = 0; bit < gen.bits.size(); ++bit)
{
rnd = dist(e);
if (rnd < mutation_rate)
gen.bits[bit] = !gen.bits[bit];
}
}
I think (from the original title and the OpenMP pragma) its a typo - read "parallelise this random-number generator" rather than "randomise this random-number generator".
If you are new to C++ ... writing code for parallel processing seems a bit of a daunting task!