use parallel computing for sensitivity analysis -凯发k8网页登录

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 the sensitivity 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, and automatically create a parallel pool is 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);

myprofile is the name of a cluster profile.

for information regarding creating a cluster profile, see add and modify cluster profiles (parallel computing toolbox).

model dependencies

model dependencies are 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 simulink® 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, see . 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 the sensitivity analyzer:

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

    for more information, see configure your system for parallel computing.

  2. open the sensitivity analyzer for the simulink model.

  3. specify the parameter set, generate parameter samples, and specify the requirements for sensitivity analysis. for example, see design exploration using parameter sampling (gui) and identify key parameters for estimation (gui).

  4. on the sensitivity analysis tab, click options to open the evaluation options dialog box.

  5. select the parallel options tab.

  6. select the use the parallel pool during evaluation check box.

    this option checks for dependencies in your simulink model. the file dependencies are displayed in the model file dependencies list box, and corresponding path to the files in model path dependencies. the files listed in model file dependencies are copied to the remote workers.

    note

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

    for more information, see model 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 the model file dependencies list box separated by semicolons or on separate lines.

    alternatively, click add file dependency to 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 the model file dependencies list box. populate the model path dependencies list box by clicking the sync 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, change c:\ to \\\\hostname\\c$\\.

  8. if you modify the simulink model, resync the dependencies to ensure that any new dependencies are detected. click sync file dependencies from model in the parallel options tab to rerun the automatic dependency check for your model.

    this action updates the model file dependencies list box with any new file dependency found in the model.

  9. click ok.

  10. in the sensitivity analyzer, click evaluate to perform sensitivity analysis using parallel computing. the design requirements are evaluated for each combination of parameter values in your parameter set.

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, see configure your system for parallel computing.

  2. open the model.

  3. specify the cost function and generate parameter samples for sensitivity analysis. for example, see .

  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

    may not detect all the dependencies in your model. for more information, see model dependencies. in this case, add the undetected dependencies manually.

  6. modify files to include any file dependencies that sdo.getmodeldependencies does 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 to dirs and update the paths on local drives to make them accessible to remote workers. see for 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,samples,opt);

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

    网站地图