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

2 ビュー (過去 30 日間)
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 件のコメント
John D'Errico
John D'Errico 2020 年 1 月 11 日
編集済み: John D'Errico 2020 年 1 月 11 日
I'm not sure what I said that bothered the legend. But the point is, it can easily take far more time than just a few minutes to figure out what is being done, then digging deeply into the code, finally explaining what the problem is. When you make it difficult for someone to figure out what you are doing, that makes it just that less likely that someone will bother to make the effort to tackle your problem.
Make it easy for somone to help you. That means you need to tell them what you are trying to do, and what result you expect. In a case like this, you need to explain why you see a difference, and why you think it is significant. Is the difference just a difference in the least significant bits of a number (often the case) or is it something big?
One thing you should consider is that completely undocumented code is just a bunch of apparently random commands, doing whatever you decided to do. Figuring out what the code should do from just the code can be very difficult, especially when there are many functions involved calling each other.
Remember, you are asking someone (who is wholly unpaid to do this task) to invest potentially as much as an hour or more of their time on you. I can often spend more than an hour or more writing a response to a question, especially when followups are considered. By making it easy for someone to help you, you make it more likely that someone will invest that time in you.
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 件)

カテゴリ

Help Center および File ExchangeLabyrinth problems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by