comparison between multiple simulation workflows -凯发k8网页登录

main content

comparison between multiple simulation workflows

when running a set of multiple simulations, you can run them in parallel on multiple matlab® workers in a parallel pool. to run multiple simulations, you can use parsim, parsim with 'runinbackground' option turned on, or batchsim.

the flow chart shows how running multiple simulations with parsim, parsim with runinbackground and batchsim differ.

the parsim and batchsim commands use the parallel computing toolbox™ license to run the simulations in parallel. parsim runs the simulations in serial if a parallel pool cannot be created or if the parallel computing toolbox license is not available. batchsim commands cannot run without parallel computing toolbox license.

parsim workflow

using parsim command with parallel computing toolbox to run multiple simulations sets up a parallel pool automatically and runs simulations in parallel. the client is always tied to the matlab workers.

basic parsim workflow

  1. create an array of objects, in, to specify changes to the model.

  2. specify one-time setup required for running multiple simulations. you can use setupfcn and transferbaseworkspacevariables to perform setup on the parallel workers.

  3. run parsim(in) to execute these multiple simulations in parallel. if a parallel pool does not exist, parsim creates it. parsim uses default settings.

  4. you can open simulation manager by setting the 'simulationmanager' argument to 'on' with parsim, parsim(in,'simulationmanager','on'). simulation manager enables you to monitor the simulations as they are running and gives you access to outputs of the simulations when they are ready. simulation manager provides you with information about the simulations running on the workers. for more information, see simulation manager.

  5. once all the simulations are complete, you get an array of simulink.simulationoutput objects.

limitations

  • closing the matlab session terminates simulations on the workers, disabling retrieval of partial results.

parsim with runinbackground workflow

  1. create an array of objects, in, to specify changes to the model.

  2. specify one-time setup required for running multiple simulations. you can use setupfcn and transferbaseworkspacevariables to perform setup on the parallel workers.

  3. run parsim with runinbackground option set to 'on': parsim(in,'runinbackground','on'). setting the 'runinbackground' option to 'on' runs the simulations asynchronously. this keeps the matlab command prompt available enabling you to work on other tasks.

  4. with 'runinbackground' option set to 'on', parsim returns a simulink.simulation.future object. you can poll this object to check the status of simulations, fetch the outputs of simulations when they are completed, or cancel simulations. for more information, see .

limitations

  • closing the matlab session terminates simulations on the workers, disabling retrieval of partial results. if the future object is cleaned, you are subsequently unable to access the results of the simulations.

  • using a fetchnext method loop on future objects, along with simulation manager causes them to compete for retrieval of future objects. use either a fetchnext method loop or simulation manager to get the outputs of completed simulations.

batchsim workflow

a batch workflow typically means submitting jobs to run simulations on matlab workers and subsequently accessing the results of those simulations. when you run simulations in batches, you offload the execution of simulations onto a compute cluster. to learn more about batch processing, see (parallel computing toolbox).

  1. create an array of objects, in, to specify changes to the model.

  2. specify one-time setup required for running multiple simulations. you can use setupfcn and transferbaseworkspacevariables to perform setup on the parallel workers.

  3. to run on a cluster or desktop background, call batchsim to offload the execution of simulations. with batchsim, you can use most of the arguments that are compatible with parsim and batch commands. for more information, see batchsim.

    using batchsim, you offload simulations to a matlab worker. to run the batch job on multiple workers, specify a pool size, n, that is an integer specifying the number of workers to make into a parallel pool for the job: batchsim(in, 'pool', n). there must be at least n 1 workers available on the cluster. if the pool size is not specified, batchsim(in) runs the simulations on a single worker in the cluster specified by the default cluster profile.

    note

    batchsim errors out when used with a pool size if parallel computing toolbox license is not available.

  4. batchsim offloads simulations to the compute cluster, enabling you to carry out other tasks while the batch job is processing, or close the client matlab and access the batch job later.

  5. on submitting a batch job, batchsim returns a job object containing a job id and other information that you can use to access the batch job at a later time. access this job again to check the progress of simulations.

limitations

  • because the client session is not tied to the workers, you cannot access the outputs unless the job is finished.

  • batchsim does not give you the ability to monitor simulations with simulation manager. for batch jobs, you can use a batch job monitor that tells you if the job is queued, in progress, or completed. for more information, see (parallel computing toolbox)

see also

functions

  • | | (parallel computing toolbox) | (parallel computing toolbox) |

classes

  • | |

tools

related topics

网站地图