What is the fastest way to run same simulink model multiple times ?

조회 수: 14 (최근 30일)
omar khater
omar khater 2019년 7월 14일
댓글: omar khater 2019년 7월 15일
If I have a large dataset say 6000 rows of data that I need to evaluate simulink model at each point
Currently I use for loop and use simout for each time to update simulink with each new value for my parameters.
I think there is more elegent approaches to do this task.
My simulink model uses components from Powerelctronics library. I assign each parameter with symbolic value that gets updated from Matlab workspace. This works fine with 6000 rows of data despite some affordable time. But more than that needs more elegent approaches.
Any suggestions will be appreciated.

채택된 답변

Jonas
Jonas 2019년 7월 15일
편집: Jonas 2019년 7월 15일
What is exactly the issue you are having with this approach? The speed, or the way you save and load data?
  • If you want to run it faster, you can parallelize the simulations with the Parallel Computing Toolbox and a parfor-loop. Each instance of the simulation will run on a separate processor thread. This will give you significant speed increases.
  • If data management is the issue, you may want to use the Simulink Test Toolbox to manage the parameter sweep, but I am not really sure you will benefit a lot from this since you have set up a way to run the simulations already.
I would in fact perform a parameter sweep on Simulink simulations in a very similar way as you are doing right now.
  댓글 수: 4
omar khater
omar khater 2019년 7월 15일
I have tried parfor loop but I have one problem.
In each loop iteration I need to update my parameters, I don't know why it flags in error that my parameters are not defined when calling simulink. It runs with i=7 and i=21 and then flags this error. I don't know why.
The solution here
reduces the time signifcantly but I have some one question
why does It run only 2 workers? Can I set it to more workers? How?
I have processor with 4 cores
cores.JPG
omar khater
omar khater 2019년 7월 15일
Another thing that I would like to try is here
but when I open the used example sldemo_parallel_rapid_accel_sims_script
it gives me this error. I double checked that I have this compiler installed
ldemo_parallel_rapid_accel_sims_script
[15-Jul-2019 19:21:05] Checking for availability of parallel pool...
[15-Jul-2019 19:21:05] Loading Simulink on parallel workers...
Analyzing and transferring files to the workers ...done.
[15-Jul-2019 19:21:07] Configuring simulation cache folder on parallel workers...
[15-Jul-2019 19:21:07] Running SetupFcn on parallel workers...
[15-Jul-2019 19:21:11] Cleaning up parallel workers...
Error using sldemo_parallel_rapid_accel_sims_script (line
121)
Error executing SetupFcn
Caused by:
Error using build_rapid_accel_target
Failed to build model 'sldemo_raccel_engine_idle_speed'
using LCC in rapid accelerator mode, please consider
using a different compiler instead. For details on
supported compiler versions, see
http://www.mathworks.com/support/compilers/current_release
Error using slbuild_private
It appears as though pwd (H:\MatlabScripts) contains
an existing build folder, while the root build folder
in Simulink.fileGenControl is set to another folder.
The build folder in pwd may shadow build artifacts in
the root build folder and cause unexpected errors.
Consider CDing to a folder that does not contain an
existing build folder prior to initiating a build.
The Build Process will terminate.
Error using build_rapid_accel_target
Failed to build model 'sldemo_raccel_engine_idle_speed'
using LCC in rapid accelerator mode, please consider
using a different compiler instead. For details on
supported compiler versions, see
http://www.mathworks.com/support/compilers/current_release
Error using slbuild_private
It appears as though pwd (H:\MatlabScripts) contains
an existing build folder, while the root build folder
in Simulink.fileGenControl is set to another folder.
The build folder in pwd may shadow build artifacts in
the root build folder and cause unexpected errors.
Consider CDing to a folder that does not contain an
existing build folder prior to initiating a build.
The Build Process will terminate.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Manual Performance Optimization에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by