主要内容

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或者batchsimfunctions), you can create simulation sets by using an array ofSimulink.SimulationInputobjects 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 theparsimbatchsim功能,且Multiple Simulationspanel to run the simulations in parallel.

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®会话并稍后访问批处理作业。

batchsimfunction uses the Parallel Computing Toolbox™ license to run the simulations on compute cluster. Thebatchsimfunction runs the simulations in serial if a parallel pool cannot be created. Without the Parallel Computing Toolbox license,batchsimfunction gives an errors.

多次模拟thesim功能

在里面absence of a Parallel Computing Toolbox license, theparsim功能和Multiple Simulationspanel behave like thesimcommand. The simulations run in serial.

多次模拟Simulink.SimulationInputObject

In command line workflows, you can make changes to your model using theSimulink.SimulationInput对象并与这些更改并行运行模拟。更改值Simulink.SimulationInput对象,覆盖模型中的值,允许您在不呈现模型的情况下修改模型。通过Simulink.SimulationInputobject, 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.SimulationOutputobject, which contains the simulation outputs, captures error messages and the simulation metadata. When you select the数据导入/导出>日志数据集数据到文件configuration parameter, Simulink creates aSimulink.SimulationData.DatasetRefobject 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文件中以数据集格式记录

  • ASimulink.SimulationData.DatasetRefobject 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

||||||||||

相关话题