If a seed number is defined for the random number generation, is it possible that different random number sequences are achieved on different computers? If so, how to achieve the same sequences?
private static final long seed = 1;
Random generator = new Random(seed);
for (int i = 0; i < nchrom; i++) {
val = (int) Math.round(generater.nextDouble()*(nchrom-1));
//...
}
Yes, with the same seed you should get the same sequence of numbers. The algorithm is specified in the documentation:
My only concern would be that if you're using
nextDouble()
you could run into some artifacts of floating point unit differences. I suspect you won't, but that would be my concern. I'd recommend that you usenextInt
anyway: