MixingPool#

class MixingPool(pars=None, **kwargs)[source]#

Bases: Route

Define a single mixing pool; can be used as a drop-in replacement for a network.

Parameters:
  • diseases (str) – the diseases that transmit via this mixing pool

  • src (inds) – source agents; can be AgeGroup(), ss.uids(), or lambda(sim); None indicates all alive agents

  • dst (inds) – destination agents; as above

  • beta (float) – overall transmission (note: use a float, not a TimePar; the time component is usually handled by the disease beta)

  • contacts (Dist) – the number of effective contacts of the destination agents

Example:

import starsim as ss

# Set the parameters
mp_pars = dict(
    src = lambda sim: sim.people.male, # only males are infectious
    dst = None, # all agents are susceptible
    beta = 0.2,
    contacts = ss.poisson(lam=4),
)

# Seed 5% of the male population
def p_init(self, sim, uids):
    return 0.05*sim.people.male

# Create and run the sim
sis = ss.SIS(init_prev=p_init)
mp = ss.MixingPool(mp_pars)
sim = ss.Sim(diseases=sis, networks=mp)
sim.run()
sim.plot()

Attributes

now

Shortcut to self.t.now()

states

Return a flat list of all states

statesdict

Return a flat dictionary (objdict) of all states

ti

Get the current module timestep

timevec

Shortcut to self.t.timevec

Methods

remove_uids(uids)[source]#

If UIDs are supplied explicitly, remove them if people die

compute_transmission(rel_sus, rel_trans, disease_beta)[source]#

Calculate transmission

This is called from Infection.infect() together with network transmission.

Parameters:
  • rel_sus (float) – Relative susceptibility

  • rel_trans (float) – Relative infectiousness

  • disease_beta (float) – The beta value for the disease. This is typically calculated as a pair of values as networks are bidirectional, however, only the first value is used because mixing pools are unidirectional.

Returns:

UIDs of agents who acquired the disease at this step