How to get seed used in the optimization problem?
Show older comments
Hi all,
I am working on an optimization problem in which I want to get the seed used after running it in order to launch another optimization problem with the same seed but different configuration and compared the results. How can I get it? I've seen in the documentation it is possible to get the configuration done by exporting the structure "optimproblem". However, in this structure it is just contained the information needed to resume the previous run but not the initial seed or initial population (just the final population).
I would really appreciate any help from your side.
Thank you. BR
El,
Answers (1)
Alan Weiss
on 4 Dec 2017
0 votes
If you are using ga, see Reproduce Results. For simulannealbnd, see Reproduce Your Results. For other solvers, use the same ideas.
Alan Weiss
MATLAB mathematical toolbox documentation
4 Comments
ElSer
on 4 Dec 2017
Alan Weiss
on 4 Dec 2017
I am not sure that I understand you. If you get the state of the global random number stream before running ga, then you can reset the state of the global random number stream before running ga again, and hence reproduce your results. If you don't know the state of the random number stream before running ga, then I believe that you cannot reproduce your result, because (among other reasons) you have no idea how many random numbers ga sampled during its run.
It is possible that I completely misunderstood you, though. See if the link I provided makes this any clearer.
Alan Weiss
MATLAB mathematical toolbox documentation
Walter Roberson
on 4 Dec 2017
Edited: Walter Roberson
on 4 Dec 2017
ga() does not keep any record of the random number seed that was in effect at the time you started the run. You need to set or record it before you start ga(). You can do that with a specific value, such as
rng(12345)
Note: floating point round-off can be different on systems have have different operating system, different MATLAB version, or different CPUs types (especially Intel vs AMD), so setting the same seed is not necessarily going to get you bit-for-bit identical results.
ElSer
on 13 Dec 2017
Categories
Find more on Problem-Based Optimization Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!