single_run#

single_run(sim, ind=0, reseed=True, shrink=True, run_args=None, sim_args=None, verbose=None, do_run=True, **kwargs)[source]#

Convenience function to perform a single simulation run. Mostly used for parallelization, but can also be used directly.

Parameters:
  • sim (Sim) – the sim instance to be run

  • ind (int) – the index of this sim

  • reseed (bool) – whether to generate a fresh seed for each run

  • noise (float) – the amount of noise to add to each run

  • noisepar (str) – the name of the parameter to add noise to

  • 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, e.g. ‘n_infected’

  • verbose (int) – detail to print

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

  • kwargs (dict) – also passed to the sim

Returns:

a single sim object with results

Return type:

sim (Sim)

Example:

import starsim as ss
sim = ss.Sim() # Create a default simulation
sim = ss.single_run(sim) # Run it, equivalent(ish) to sim.run()