parameters

parameters

Set parameters

Classes

Name Description
Pars Dict-like container of parameters
SimPars Create the parameters for the simulation. Typically, this function is used

Pars

parameters.Pars(self, pars=None, **kwargs)

Dict-like container of parameters

Acts like an sc.objdict(), except that adding new keys are disallowed by default, and auto-updates known types.

Methods

Name Description
check_key_mismatch Check whether additional keys are being added to the dictionary
dict_update Redefine default dict.update(), since overwritten in this class; should not usually be used
to_json Convert to JSON representation
update Update internal dict with new pars.
check_key_mismatch
parameters.Pars.check_key_mismatch(pars)

Check whether additional keys are being added to the dictionary

dict_update
parameters.Pars.dict_update(*args, **kwargs)

Redefine default dict.update(), since overwritten in this class; should not usually be used

to_json
parameters.Pars.to_json(**kwargs)

Convert to JSON representation

update
parameters.Pars.update(pars=None, create=False, **kwargs)

Update internal dict with new pars.

Parameters
Name Type Description Default
pars dict the parameters to update (if None, do nothing) None
create bool if create is False, then raise a KeyNotFoundError if the key does not already exist False
kwargs dict merged with pars {}

SimPars

parameters.SimPars(self, pars=None, create=True, **kwargs)

Create the parameters for the simulation. Typically, this function is used internally rather than called by the user; e.g. typical use would be to do sim = ss.Sim() and then inspect sim.pars, rather than calling this function directly.

Parameters

Name Type Description Default
label str The name of the simulation required
n_agents int / float The number of agents to run (default 10,000) required
total_pop int / float If provided, scale the agents to this effective population size required
pop_scale float If provided, use this agent-to-population scale factor (total_pop = n_agents*pop_scale) required
unit str The time unit for the simulation (default ‘year’; other choices are ‘day’, ‘week’, ‘month’) required
start float / str / date The starting date for the simulation (default 2000); can be a year or date required
stop float / str / date If provided, the ending date for the simulation (if not provided, calculate from “dur”) required
dur int How many timesteps to simulate, if “stop” is not provided (default 50) required
dt float The timestep, in units of “unit” (default 1.0) required
rand_seed int The overall random seed for the simulation (used to set module-specific random seeds) required
birth_rate float If provided, include births with this rate (per 1000 people per year) required
death_rate float If provided, include deaths with this rate (per 1000 people per year) required
use_aging bool Specify whether agents age (by default, agents age if and only if births and/or deaths are included) required
people People If provided, use a pre-existing People object rather than creating one (in which case n_agents will be ignored) required
networks str / list / Module The network module(s); can be a string, single module (i.e. Network), or list required
demographics str / list / Module As above required
diseases str / list / Module As above required
connectors str / list / Module As above required
interventions str / list / Module As above required
analyzers str / list / Module As above required
verbose float How much detail to print (1 = every timestep, 0.1 = every 10 timesteps, etc.) required

Methods

Name Description
convert_modules Convert different types of representations for modules into a
is_default Check if the provided value matches the default
validate Call parameter validation methods
validate_agents Check that n_agents is supplied and convert to an integer
validate_demographics Validate demographics-related input parameters
validate_modules Validate modules passed in pars
validate_networks Validate networks
validate_sim_pars Validate each of the parameter values
validate_total_pop Ensure one but not both of total_pop and pop_scale are defined
validate_verbose Validate verbosity
convert_modules
parameters.SimPars.convert_modules()

Convert different types of representations for modules into a standardized object representation that can be parsed and used by a Sim object

is_default
parameters.SimPars.is_default(key)

Check if the provided value matches the default

validate
parameters.SimPars.validate()

Call parameter validation methods

validate_agents
parameters.SimPars.validate_agents()

Check that n_agents is supplied and convert to an integer

validate_demographics
parameters.SimPars.validate_demographics()

Validate demographics-related input parameters

validate_modules
parameters.SimPars.validate_modules()

Validate modules passed in pars

validate_networks
parameters.SimPars.validate_networks()

Validate networks

validate_sim_pars
parameters.SimPars.validate_sim_pars()

Validate each of the parameter values

validate_total_pop
parameters.SimPars.validate_total_pop()

Ensure one but not both of total_pop and pop_scale are defined

validate_verbose
parameters.SimPars.validate_verbose()

Validate verbosity