Can anyone tell me why the 2 scripts that i attached are giving different outputs for the same inputs?

조회 수: 1(최근 30일)
The Legend
The Legend 2020년 1월 11일
댓글: Meg Noah 2020년 1월 11일
Can anyone tell me why the 2 scripts that i attached are giving different outputs for the same inputs?
They should be doing exactly the same and it's crushing my brains.
The second script also seems to be slower and it's graph is less good than the first script, I have no clue why.
  댓글 수: 6
Meg Noah
Meg Noah 2020년 1월 11일
I don't know if this will fix it, but when you run monte carlo operations twice, without reinitializing the random number stream seed, then the algorithms will be operating on two different data sets and necessarily will produce different results. Depending on where and how the random numbers are called, you want to be sure they are solving the same set of mazes. If the only place rand is called is in the generation of a new maze,then executing this once in the main program should result in getting the same set of mazes to solve - you need to check it. The monte carlo solution should have a seed value that is the same. Here, it is '1' but you can make it any number even 8675301 if you want.
s = RandStream('mt19937ar','Seed',1);
RandStream.setGlobalStream(s);
If there are other places where rand is called, then it's going to be more complicated because you want the two algorithms to solve the same maze. Ideally, have the maze generated in a main,, and then send it to the different solvers all in one program.

댓글을 달려면 로그인하십시오.

답변(0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by