主要内容

Running Multiple Simulations

For workflows that involve multiple parallel simulations and logging of large amounts of data, you can use theparsim或者batchsim功能或运行模拟Multiple SimulationsSimulink中的面板万博1manbetx®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中万博1manbetx的面板。

在里面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

当池尚未打开并且首次运行仿真时,仿真需要额外的时间进行启动。随后的平行模拟更快。

多次模拟万博1manbetxEditor

Multiple Simulations面板允许您为块参数和变量的不同值设置多个模拟。您可以从模型画布中选择感兴趣的块参数,并指定要用于模拟的值。您还可以为模拟提供变量。要运行您设置的模拟,首先选择设计研究,然后单击运行全部button on模拟Simulink工具条万博1manbetx上的选项卡。要了解更多,请参阅Multiple Simulations Panel: Simulate for Different Values of Stiffness for a Vehicle Dynamics System例子。

多次模拟Parallel Computing Toolbox

parsim功能和Multiple Simulations面板将每个仿真分配给并联池工人,以减少并行运行时的整体模拟时间。使用parsim功能和Multiple Simulations面板创建一个并行池,该池可让您识别文件依赖性并管理加速器和快速加速器模式的模拟构建工件。

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.SimulationInput目的

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 thePresimfcnpostimfcn函数分别。当您使用时Simulink.SimulationInput对象,模拟参数在模拟结束后恢复。看使用PARSIM运行房屋热模型的平行模拟。这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 Parallel Server™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对象,DatasetRefobject is returned as part of the模拟Output目的。结果,您可以更快地访问并且不需要创建它们。

并行仿真可以产生比MATLAB内存所能保留的更多的记录数据。考虑记录以持续存储以进行并行模拟以减少内存要求。当您选择数据导入/导出>日志数据集数据到文件configuration parameter (LoggingToFile), for parallel simulations in Simulink:

  • 数据以垫子文件登录以数据集格式记录

  • ASimulink.SimulationData.DatasetRefobject is created for each Dataset element (for example,登录)对于每个仿真

您可以使用DatasetRefobjects to access data for a specific signal. You can creatematlab.io.datastore.SimulationDatastoreobjects to use for streaming logged data from persistent storage in to a model.

看Also

||||||||||

相关话题