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
或者batchsim
functions), you can create simulation sets by using an array ofSimulink.SimulationInput
objects 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 theparsim
和batchsim
功能,和Multiple Simulationspanel to run the simulations in parallel.
To run multiple simulations with
Simulink.SimulationInput
object andparsim
function, see使用PARSIM运行房屋热模型的平行模拟。To learn more about how theparsim
function runs simulations in parallel, seeRun Parallel Simulations。To learn about running multiple simulations in batch, see
batchsim
。要了解命令行工作流与它们的工作方式之间的差异,请参阅多个模拟工作流程之间的比较。
要使用图形用户界面进行多个模拟,请参见使用多个模拟面板配置和运行模拟。
要了解如何监视模拟并查看结果,请参见Analyze Data from Multiple Simulations。
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®会议并稍后访问批处理作业。
这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
目的
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
和postimfcn
函数分别。当您使用时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.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:
数据以垫子文件登录以数据集格式记录
A
Simulink.SimulationData.DatasetRef
object is created for each Dataset element (for example,登录
)对于每个仿真
您可以使用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