Comments on: Simulating models in parallel made easy with parsim https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/?s_tid=feedtopost Guy Rouleau is an Application Engineer for MathWorks. He writes here about Simulink and other MathWorks tools used in Model-Based Design. Wed, 28 Aug 2019 13:12:47 +0000 hourly 1 https://wordpress.org/?v=6.2.2 By: Guy Rouleau https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-264548 Wed, 28 Aug 2019 13:12:47 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-264548 @Jake Hannafious: Your code should run fine. I recommend contacting technical support. One thing you could check is the output of “which -all parsim” to be sure there is no other file named “parsim” on your path.

We would also like to understand the performance issue. Thos should be equivalent.

]]>
By: Lauri Berkovits https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-264500 Wed, 28 Aug 2019 09:33:04 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-264500 Can you collect the Matlab console output if you use parsim? I don’t mean the output that parsim itself gives, I mean the output from fprintf etc. which I usually collect with ‘diary’. How about breakpoints? Can you use Matlab editor’s breakpoints (For Matlab Systems in a Simulink model) together with parsim?

]]>
By: Eric Anderson https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-248927 Tue, 23 Apr 2019 12:13:33 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-248927 I rediscovered this post two days ago after having struggled with using structs for a large batch of long running simulations with parfor. I had given up on parfor working without a ton of refactoring. parsim worked great! I got it up and running very quickly – my only feedback is that for long simulations, 5% ticks on the simulation manager status made me restart multiple times as I thought something was wrong when it was working fine.

This was always one of those things I wanted to try, but as long as parfor was working (and there was a stack of work ), I went with what I knew. This goes to show I should experiment with your posts more often! Thanks Guy!

]]>
By: Jake Hannafious https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-244600 Fri, 05 Apr 2019 02:20:22 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-244600 I’ve been trying to run various types of simulations: parfor and sim(), sim() with rapid acceleration, and variations of parsim(). The output I wanted to try the most was parsim rapid acceleration for Monte Carlo. Unfortunately I get the output quoted below for any parsim I try to run.
Here with this example:

>> mdl='sldemo_bounce';
>> blk=sprintf('sldemo_bounce/Coefficient of\n Restitution');
>> N=10;
>> k=linspace(-.0,-.2,N);
>> in(1:N)=Simulink.SimulationInput(mdl);
>> for i = 1:N
in(i)=in(i).setBlockParameter(blk,'Gain',num2str(k(i)));
end
>> out=parsim(in);
[04-Apr-2019 18:53:23] Checking for availability of parallel pool...
[04-Apr-2019 18:53:23] Loading Simulink on parallel workers...
[04-Apr-2019 18:53:23] Configuring simulation cache folder on parallel workers...
[04-Apr-2019 18:53:23] Loading model on parallel workers...
[04-Apr-2019 18:53:24] Cleaning up parallel workers...
Too many input arguments.

I get the same output even for

 parsim(Simulink.SimulationInput(aModelVar)) 

Is this a known bug? At this point I don’t believe I’m implementing anything incorrectly.

I also noticed that running a loop like

 (par)for
     assignin('base','var',val)
     out = sim(model)
  end

Was much faster than using Simulink.SimulationInput with sim(), with a normal simulation and with the rapid accelerator set up. So far have been fairly underwhelmed by what I’ve seen.

]]>
By: Guy Rouleau https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-237414 Tue, 19 Feb 2019 15:13:14 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-237414 @Ed: You are correct, the line you describe would work too. I wrote it that way just to put the emphasis on the variable for which we are sweeping..

]]>
By: Ed Hernandez https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-236686 Fri, 15 Feb 2019 17:41:36 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-236686 I was wondering why you bothered to declare a variable, var, that just contains the name of the variable you’re really interested in, Cr. Could you have simply done this instead:

in(i) = in(i).setVariable(‘Cr’,Cr_v(i));

or does that not work?

]]>
By: Guy Rouleau https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-226775 Mon, 10 Sep 2018 12:41:55 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-226775 @Krishna: My best guess is because of the line return. Notice the “\n” in my code. If this does not work, I recommend contacting technical support with reproduction files.

]]>
By: Krishna Kashampur https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-226705 Fri, 07 Sep 2018 11:24:27 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-226705 When I try the first example on this page, I get an error, and I have hard time understanding how to set parameters in simulink model in different levels, I gives me similar error.

The error was – ‘Invalid Simulink object name: sldemo_bounce/coefficient of RestitutionCaused by: No block called ‘coefficient of Restitution’ could be found’

Can someone help me understand this?

]]>
By: EWGates https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-209657 Thu, 18 May 2017 14:37:38 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-209657 When I run parsim() (and Parallel Computing Toolbox) with a single simple simulink model from a matlab script, I get different results than when I run using sim() from a matlab script. What is parsim() doing differently than sim()? I want to know because setting up the model with different blocks active (as you suggested above) did not run as expected, so simplified to experiment.

]]>
By: Guy Rouleau https://blogs.mathworks.com/simulink/2017/04/14/simulating-models-in-parallel-made-easy-with-parsim/#comment-207801 Tue, 25 Apr 2017 18:58:24 +0000 https://blogs.mathworks.com/simulink/?p=6393#comment-207801 @EWGates: The use case parsim is focussing on is running one model multiple times in parallel with different input, parameters, variables, etc. For the use case of running multiple models in parallel, we are considering that for the future. Currently, this can be done using parfor or other Parallel Computing Toolbox features.
For the use case of “running different blocks within a model simultaneously with parsim”, I can interpret that in two ways:
– If you mean simulating one model, and having part of it simulating on one core and other parts on other cores, this is not possible. We are looking into that for a future release
– If you mean running one model multiple times in parallel, but with different blocks active, this can be done by activating different variants in parsim, using either the setVariable or setParameter methods of the simulation input object.

]]>