I have been struggling to run a genetic algorithm; however currently there is an issue when I want to generator random number. I use the one here. I have written it as follows:
double randomgens()
{
std::mt19937_64 rng;
double currentRandomNumber;
// initialize the random number generator with time-dependent seed
uint64_t timeSeed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
std::seed_seq ss{ uint32_t(timeSeed & 0xffffffff), uint32_t(timeSeed >> 32) };
rng.seed(ss);
// initialize a uniform distribution between 0 and 1
std::uniform_real_distribution<double> unif(0, 1);
// ready to generate random numbers
const int nSimulations = 10;
currentRandomNumber = unif(rng);
return currentRandomNumber;
}
I assign it to a double variable: random = randomgens(); But when it gets to the randomgens function at the first I see the message visual studio triggered breakpoint and when I press continue I see an error:
Unhandled exception at 0x00007FFB6BB2AA2C (ntdll.dll) in project in Visual Studio.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FFB6BB83180). Can anyone help me to sort out this problem?
Aucun commentaire:
Enregistrer un commentaire