mercredi 8 juin 2016

Using random generator with same seed does not lead to the same output

In my program, I am using a seed for the random generator so that I will be able to replicate results. Unfortunately, my results however are not the same when I replicate them.

The general structure of my code is as follows:

public class iMaxAnalysis 
{

public static void main(String[] args) throws FileNotFoundException
{
    int seed = 3;
    I3CHperinstance test = new I3CHperinstance(seed, noIMPR, neighbours);

}

public class I3CHperinstance extends BASIS 
{
private Random rnd;

public I3CHperinstance(int seed)
{
    this.rnd = new Random(seed);}

My code is quite long and complex and it will not be of added value to add it here. In I3CHperinstance I am using the random generator and I am passing rnd to different classes since it is needed there as well. Do I have to return this rnd in order to solve the issue with having different outputs?




Aucun commentaire:

Enregistrer un commentaire