Main Content

Use Parallel Computing for Sensitivity Analysis

Configure Your System for Parallel Computing

To perform global sensitivity analysis, you sample the model parameters and states, define a cost function by creating a design requirement on the model signals, and evaluate the cost function for each sample. Evaluating the model for many samples can be time consuming. You can speed up evaluation in theSensitivity Analyzer, or at the command line, using parallel computing on multicore processors or multiprocessor networks.

When you evaluate the cost function with the parallel computing option enabled, the software uses the available parallel pool. If none is available, andAutomatically create a parallel poolis selected in your Parallel Computing Toolbox™ preferences, the software starts a parallel pool using the settings in those preferences. To open a parallel pool that uses a specific cluster profile, use:

parpool(MyProfile);

MyProfileis the name of a cluster profile.

For information regarding creating a cluster profile, seeAdd and Modify Cluster Profiles(Parallel Computing Toolbox).

Model Dependencies

Model dependenciesare any referenced models, data such as model variables, S-functions, or additional files necessary to run the model. Before starting the parallel model evaluation, verify that the model dependencies are complete. Otherwise, you may get unexpected results.

Making Model Dependencies Accessible to Remote Workers

When you use parallel computing, the金宝app®Design Optimization™software helps you identify model dependencies. To do so, the software uses the Dependency Analyzer. The dependency analysis may not find all the files required by your model. To learn more, seeDependency Analyzer Scope and Limitations. If your model has dependencies that are undetected or inaccessible by the parallel pool workers, then add them to the list of model dependencies.

The dependencies are made accessible to the parallel pool workers by specifying one of the following:

  • File dependencies: the model dependency files are copied to the parallel pool workers.

  • Path dependencies: the paths to the model dependencies are added to the paths of the parallel pool workers. If you are working in a multi-platform scenario, ensure that the paths are compatible across platforms.

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 dependent files on the local computer.

Perform Sensitivity Analysis Using Parallel Computing (GUI)

To perform sensitivity analysis using parallel computing in theSensitivity Analyzer:

  1. Ensure that the software can access parallel pool workers that use the appropriate cluster profile.

    For more information, seeConfigure Your System for Parallel Computing.

  2. Open theSensitivity Analyzerfor the Simulink model.

  3. Specify the parameter set, generate parameter samples, and specify the requirements for sensitivity analysis. For example, seeDesign Exploration Using Parameter Sampling (GUI)andIdentify Key Parameters for Estimation (GUI).

  4. On theSensitivity Analysistab, clickOptionsto open theEvaluation Optionsdialog box.

  5. Select theParallel Optionstab.

  6. Select theUse the parallel pool during evaluationcheck box.

    This option checks for dependencies in your Simulink model. The file dependencies are displayed in theModel file dependencieslist box, and corresponding path to the files inModel path dependencies. The files listed inModel file dependenciesare copied to the remote workers.

    Note

    The automatic dependencies check may not detect all the dependencies in your model.

    For more information, seeModel Dependencies. In this case, add the undetected dependencies manually.

  7. Add any file dependencies that the automatic check does not detect.

    Specify the files in theModel file dependencieslist box separated by semicolons or on separate lines.

    Alternatively, clickAdd file dependencyto open a dialog box, and select the file to add.

    Note

    If you do not want to copy the files to the remote workers, delete all entries in theModel file dependencieslist box. Populate theModel path dependencieslist box by clicking theSync path dependencies from model, and add any undetected path dependencies. In addition, in the list box, update the paths on local drives to make them accessible to remote workers. For example, changeC:\to\\\\hostname\\C$\\.

  8. If you modify the Simulink model, resync the dependencies to ensure that any new dependencies are detected. ClickSync file dependencies from modelin theParallel Optionstab to rerun the automatic dependency check for your model.

    This action updates theModel file dependencieslist box with any new file dependency found in the model.

  9. ClickOK.

  10. In theSensitivity Analyzer, clickEvaluate使用并行com进行灵敏度分析puting. The design requirements are evaluated for each combination of parameter values in your parameter set.

This functionality is not supported inSimulink Online™.

Perform Sensitivity Analysis Using Parallel Computing (Code)

To evaluate a model using parallel computing:

  1. Ensure that the software can access parallel pool workers that use the appropriate cluster profile.

    For more information, seeConfigure Your System for Parallel Computing.

  2. Open the model.

  3. Specify the cost function and generate parameter samples for sensitivity analysis. For example, seeDesign Exploration Using Parameter Sampling (Code).

  4. Enable parallel computing using an evaluation option set.

    opt = sdo.EvaluateOptions; opt.UseParallel = true;
  5. Find the model dependencies.

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

    Note

    sdo.getModelDependenciesmay not detect all the dependencies in your model. For more information, seeModel Dependencies. In this case, add the undetected dependencies manually.

  6. Modifyfilesto include any file dependencies thatsdo.getModelDependenciesdoes not detect.

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

    Note

    If you do not want to copy the files to the remote workers, add any undetected path dependencies todirsand update the paths on local drives to make them accessible to remote workers. Seesdo.getModelDependenciesfor more details.

  7. Add the file dependencies for evaluation.

    opt.ParallelFileDependencies = files;
  8. Specify the name of the model to be evaluated in parallel.

    opt.EvaluatedModel = modelname;
  9. Evaluate the model.

    [pOpt, opt_info] = sdo.evaluate (fcn,样本,选择);

Troubleshooting

Why Don’t I See the Evaluation Speed up I Expected Using Parallel Computing?

When you evaluate a model that does not require a large number of evaluations or does not take long to simulate, you might not see a speedup in the evaluation time. In such cases, the overhead associated with creating and distributing the parallel tasks outweighs the benefits of running the evaluation in parallel.

See Also

|||(Parallel Computing Toolbox)

Related Topics