Documentation

sdo.getModelDependencies

Package: sdo

List of model file and path dependencies

Syntax

[dirs,files] = sdo.getModelDependencies(modelname)

Description

[dirs,files] = sdo.getModelDependencies(modelname) returns dependencies of a Simulink® model. The dependencies are required for parallel computing of parameter estimation, response optimization, or sensitivity analysis tasks. The model must be open for the dependency analysis.

sdo.getModelDependencies may not return a complete list of model dependencies; some dependencies are undetectable. To learn more, see Scope of Dependency Analysis in the Simulink documentation. If your model has dependencies that are undetected or inaccessible by the parallel pool workers, then add them to the list of model dependencies.

Input Arguments

modelname

Simulink model name, specified as a string inside single quotes (' ').

Output Arguments

dirs

Cell array of paths that contain model dependencies.

The cell array is empty when the model does not have any dependencies or sdo.getModelDependencies does not detect any dependencies.

files

Cell array of files that are model dependencies.

The cell array is empty when the model does not have any dependencies or sdo.getModelDependencies does not detect any dependencies.

Examples

collapse all

List Model Dependencies Required for Parallel Computing

Copy Simulink model and boiler library to temporary folder.

pathToLib = boilerpressure_setup;

Add folder to search path and open model.

origPath = addpath(pathToLib);
boilerpressure_demo

Get model dependencies.

[dirs, files] = sdo.getModelDependencies('boilerpressure_demo');
dirs = 

    'C:/Users/username/AppData/Local/Temp/tpadb428f6_4dbc_4a22_86de_5ce364ba7eb5'

files = 

    'C:/Users/username/AppData/Local/Temp/tpadb428f6_4dbc_4a22_86de_5ce364ba7eb5/boilerpressure_demo.slx'
    'C:/Users/usertname/AppData/Local/Temp/tpadb428f6_4dbc_4a22_86de_5ce364ba7eb5/libsteam.slx'

The paths listed in dirs are the paths to all the file dependencies listed in files.

Enable parallel computing and add model dependencies.

opts = sdo.OptimizeOptions;
opts.UseParallel = 'always';
opts.ParallelFileDependencies = files;

Add Additional Files to Model File Dependency List

Copy Simulink model and boiler library to temporary folder.

pathToLib = boilerpressure_setup;

Add folder to search path and open model.

origPath = addpath(pathToLib);
boilerpressure_demo

Get model dependencies.

[dirs, files] = sdo.getModelDependencies('boilerpressure_demo');

Append an additional file, filename.m located in 'C:\matlab\work\'

files = vertcat(files,'C:\matlab\work\filename.m');

Enable parallel computing and add model dependencies.

opts = sdo.OptimizeOptions;
opts.UseParallel = 'always';
opts.ParallelFileDependencies = files;

Make Local Paths Accessible to Remote Workers

Using file dependencies is recommended, however, in some cases it can be better to choose path dependencies. For example, if parallel computing is set up on a local multi-core computer, using path dependencies is preferred as using file dependencies creates multiple copies of the dependency files on the local computer. This example shows how to use path dependencies for setting up parallel computing.

Copy Simulink model and boiler library to temporary folder.

pathToLib = boilerpressure_setup;

Add folder to search path and open model.

origPath = addpath(pathToLib);
boilerpressure_demo

Get model dependencies.

[dirs, files] = sdo.getModelDependencies('boilerpressure_demo');

Add undetected path dependencies.

dirs = vertcat(dirs,'//hostname/C$/matlab/work');

Replace C:/ with valid network path accessible to remote workers.

dirs = regexprep(dirs,'C:/','////hostname//C$//');

Enable parallel computing and add model dependencies.

opts = sdo.OptimizeOptions;
opts.UseParallel = 'always';
opts.ParallelPathDependencies = dirs;

Related Examples

More About

collapse all

Tips

  • files lists the model dependencies, and dirs lists the corresponding paths to these dependencies.

    The model dependencies are required during parallel computing and are made accessible to the parallel pool workers by specifying one of the following:

  • Modify files and dirs to include dependencies that sdo.getModelDependencies cannot detect.

  • Using file dependencies is recommended, however, in some cases it can be better to choose path dependencies. For example, if parallel computing is set up on a local multi-core computer, using path dependencies is preferred as using file dependencies creates multiple copies of the dependency files on the local computer.

Was this topic helpful?