I have a SIMULINK simulation that I am trying to run using different random numbers each time. I need to run the simulation n
times in order to quantify how it behaves under the broad range of random conditions. Each run takes long enough so that all n
runs take too long.
I am trying to replace the for
loop I have with a parfor
loop. The simplified code is shown below.
n = ... % Number of runs I want to do
parfor i = 1:n
% Run simulation
sim('model')
% Store data here
end
The problem I'm running into is the random number generation. I have read through this question and have gotten some idea from it, but it does not solve my problem. The approach with "'Seed','shuffle'
" would seed the rng with the current time. While I could save the seed of each individual stream and then run them individually, I don't see how I would be able to rerun the entire parfor loop under the same conditions.
I need:
- A way to run the
parfor
loop so that each simulation has its own random number generator that will work properly and independently of the other loops. - A way to set the seed for each of the iterations of the loops so that I can reproduce the entire
parfor
loop, rather than only single iterations.
Aucun commentaire:
Enregistrer un commentaire