Running Multiple Simulations
For workflows that involve multiple parallel simulations and logging of large amounts of data, you can use theparsim
或者batchsim
函数,或使用模拟Multiple SimulationsSimulink中的面板金宝app®Editor. This approach is useful in scenarios like model testing, experiment design, Monte Carlo analysis, and model optimization.
对于命令行工作流程(parsim
或者batchsim
functions), you can create simulation sets by using an array ofSimulink.SimulationInput
objects to run multiple simulations. Alternatively, you can use theMultiple SimulationsSimulink的金宝app面板。
在里面Multiple Simulations面板中,您可以创建speci设计研究fy values for simulations. The panel allows you to specify values for block parameters, and variables for the simulations.
With the Parallel Computing Toolbox™, you can also use theparsim
和batchsim
功能,且Multiple Simulationspanel to run the simulations in parallel.
To run multiple simulations with
Simulink.SimulationInput
object andparsim
function, see使用Parsim运行House的热模型的并行模拟。To learn more about how theparsim
function runs simulations in parallel, seeRun Parallel Simulations。To learn about running multiple simulations in batch, see
batchsim
。了解命令行工作流程之间的差异以及它们的工作方式,请参阅多种仿真工作流程之间的比较。
要使用图形用户界面运行多个模拟,请参阅Configure and Run Simulations with Multiple Simulations Panel。
要了解如何监视模拟并查看结果,请参阅Analyze Data from Multiple Simulations。
Note
当池尚未打开并且第一次运行仿真时,仿真需要额外的时间开始。随后的并行模拟速度更快。
多次模拟金宝appEditor
这Multiple Simulations面板允许您为不同的块参数和变量设置多个模拟。您可以从模型画布中选择感兴趣的块参数,并指定要用于模拟的值。您还可以为仿真提供变量。要运行您设置的模拟,首先选择设计学习,然后单击跑全部button on模拟Simulink To金宝appolStrip上的选项卡。要了解更多信息,请参阅Multiple Simulations Panel: Simulate for Different Values of Stiffness for a Vehicle Dynamics System例子。
多次模拟Parallel Computing Toolbox
这parsim
功能和Multiple Simulations面板将每个模拟分发到并行池工人,以减少并行运行时的整体仿真时间。使用parsim
功能和Multiple Simulations面板创建一个并行池,允许您识别文件依赖性,并管理Accelerator和快速加速器模式中的模拟构建工件。
这batchsim
功能将模拟卸载到计算群集。仿真在群集中执行,这允许您在批处理作业处理时执行其他任务。您还可以关闭客户端matlab®会话并稍后访问批处理作业。
这batchsim
function uses the Parallel Computing Toolbox™ license to run the simulations on compute cluster. Thebatchsim
function runs the simulations in serial if a parallel pool cannot be created. Without the Parallel Computing Toolbox license,batchsim
function gives an errors.
多次模拟thesim
功能
在里面absence of a Parallel Computing Toolbox license, theparsim
功能和Multiple Simulationspanel behave like thesim
command. The simulations run in serial.
多次模拟Simulink.SimulationInput
Object
In command line workflows, you can make changes to your model using theSimulink.SimulationInput
对象并与这些更改并行运行模拟。更改值Simulink.SimulationInput
对象,覆盖模型中的值,允许您在不呈现模型的情况下修改模型。通过Simulink.SimulationInput
object, you can also specify MATLAB functions to run at the start and the end of each simulation by using thePresimfcn.
和Postsimfcn.
分别为功能。当你使用时Simulink.SimulationInput
对象,在模拟结束后恢复模型参数。看使用Parsim运行House的热模型的并行模拟。这Simulink.SimulationInput
对象允许您在模型中更改这些设置:
初始状态
External inputs
模型参数
Block parameters
变量
仿真经理to Monitor Simulations
这仿真经理allows you to monitor multiple parallel simulations. It shows the progress of the runs as they are running in parallel. You can view the details of every run such as parameters, elapsed time, and diagnostics. The Simulation Manager acts as a useful tool by giving you the option to analyze and compare your results in the Simulation Data Inspector. You can also select a run and apply its values to the model. For more information, see仿真经理。
这parsim/batchsim
功能能力
Outputs errors in the simulation output object for easier debugging
兼容快速加速器和快速重启
Compatible with file logging (to facilitate big data)
Compatible withMATLAB并行服务器™in addition to local parallel pools
Capable of transferring base workspace variables to workers
避免透明度错误
多个模拟的数据记录
所结果的Simulink.SimulationOutput
object, which contains the simulation outputs, captures error messages and the simulation metadata. When you select the数据导入/导出>日志数据集数据到文件configuration parameter, Simulink creates aSimulink.SimulationData.DatasetRef
object for each数据集
存储在生成的垫文件中。你可以使用datasetref.
对象访问数据的数据数据集
element. For simulations that are run using theSimulink.SimulationInput
对象,呢datasetref.
object is returned as part of the模拟Output
目的。因此,您可以更快地访问,不需要创建它们。
并行模拟可以产生比MATLAB内存能够保持更多的记录数据。考虑日志记录到持久存储,以便并行模拟以减少内存要求。当你选择数据导入/导出>日志数据集数据到文件configuration parameter (LoggingToFile
), for parallel simulations in Simulink:
数据在MAT文件中以数据集格式记录
A
Simulink.SimulationData.DatasetRef
object is created for each Dataset element (for example,Logsout.
)对于每个模拟
您可以使用datasetref.
objects to access data for a specific signal. You can creatematlab.io.datastore.simulationdatastore.
objects to use for streaming logged data from persistent storage in to a model.
看Also
Simulink.SimulationInput
|applyToModel
|setexternalInput.
|setInitialState
|setVariable
|setModelParameter
|setBlockParameter.
|validate
|setPostsimfcn.
|setpresimfcn.
|parsim