I am working on algorithm which contain a random initial state. So the output of this algorithm is not robust in each time I run it. This causes a lot of headache for me while I catch a wrong output and want to debug it to see where the problem was because when I run it again, the problem may not re-produced due the random factor of the algorithm. I am using C++ random generator as follow:
std::random_device rd;
std::mt19937 rnd_generator(rd());
std::uniform_int_distribution<> rnd_distribution(0, data_size - 1);
auto get_random_index = [&](){
return rnd_distribution(rnd_generator);
};
How I can imitate the last random sequence generated by this function? For example, Can I give it some kind of static seed that I can re enter it and get the exactly same random sequence? I am asking because I think it is common problem so there may be some nice and efficient well-known way.