multi_run#

multi_run(sim, n_runs=4, reseed=None, iterpars=None, shrink=None, run_args=None, sim_args=None, par_args=None, do_run=True, parallel=True, n_cpus=None, verbose=None, **kwargs)[source]#

For running multiple sims in parallel. If the first argument is a list of sims rather than a single sim, exactly these will be run and most other arguments will be ignored.

Parameters:
  • sim (Sim/list) – the sim instance to be run, or a list of sims.

  • n_runs (int) – the number of parallel runs

  • reseed (bool) – whether or not to generate a fresh seed for each run (default: true for single, false for list of sims)

  • iterpars (dict) – any other parameters to iterate over the runs; see sc.parallelize() for syntax

  • shrink (bool) – whether to shrink the sim after the sim run

  • run_args (dict) – arguments passed to sim.run()

  • sim_args (dict) – extra parameters to pass to the sim

  • par_args (dict) – arguments passed to sc.parallelize()

  • do_run (bool) – whether to actually run the sim (if not, just initialize it)

  • parallel (bool) – whether to run in parallel using multiprocessing (else, just run in a loop)

  • n_cpus (int) – the number of CPUs to run on (if blank, set automatically; otherwise, passed to par_args)

  • verbose (int) – detail to print

  • kwargs (dict) – also passed to the sim

Returns:

If combine is True, a single sim object with the combined results from each sim. Otherwise, a list of sim objects (default).

Example:

import starsim as ss
sim = ss.Sim()
sims = ss.multi_run(sim, n_runs=6)