june.simulator.Simulator

class june.simulator.Simulator(world: june.world.World, interaction: june.interaction.interaction.Interaction, timer: june.time.Timer, activity_manager: june.activity.activity_manager.ActivityManager, infection_selector: june.infection.infection_selector.InfectionSelector = None, infection_seed: Optional[InfectionSeed] = None, record: Optional[Record] = None, checkpoint_dates: List[datetime.date] = None, checkpoint_path: str = None)

Class to run an epidemic spread simulation on the world.

world:

instance of World class

class ActivityManager(world, policies, timer, all_activities, activity_to_super_groups: dict, leisure: Optional[june.groups.leisure.leisure.Leisure] = None, travel: Optional[june.groups.travel.travel.Travel] = None)
__init__(world, policies, timer, all_activities, activity_to_super_groups: dict, leisure: Optional[june.groups.leisure.leisure.Leisure] = None, travel: Optional[june.groups.travel.travel.Travel] = None)

Initialize self. See help(type(self)) for accurate signature.

activities_to_super_groups(activities: List[str]) → List[str]

Converts activities into Supergroups, the interaction will run over these Groups.

activities:

list of activities that take place at a given time step

List of groups that are active.

static apply_activity_hierarchy(activities: List[str]) → List[str]

Returns a list of activities with the right order, obeying the permanent activity hierarcy and shuflling the random one.

activities:

list of activities that take place at a given time step

Ordered list of activities according to hierarchy

do_timestep()
move_people_to_active_subgroups(activities: List[str], date: datetime.datetime = datetime.datetime(2020, 2, 2, 0, 0), days_from_start=0)

Sends every person to one subgroup. If a person has a mild illness, they stay at home

move_to_active_subgroup(activities: List[str], person: june.demography.person.Person, to_send_abroad=None) → Optional[june.groups.group.subgroup.Subgroup]

Given the hierarchy of activities and a person, decide what subgroup should they go to

activities:

list of activities that take place at a given time step

person:

person that is looking for a subgroup to go to

Subgroup to which person has to go, given the hierarchy of activities

send_and_receive_people_from_abroad(movable_people)

Deal with the MPI comms.

property active_super_groups
property all_super_groups
__init__(world: june.world.World, interaction: june.interaction.interaction.Interaction, timer: june.time.Timer, activity_manager: june.activity.activity_manager.ActivityManager, infection_selector: june.infection.infection_selector.InfectionSelector = None, infection_seed: Optional[InfectionSeed] = None, record: Optional[Record] = None, checkpoint_dates: List[datetime.date] = None, checkpoint_path: str = None)

Class to run an epidemic spread simulation on the world.

world:

instance of World class

bury_the_dead(world: june.world.World, person: june.demography.person.Person)

When someone dies, send them to cemetery. ZOMBIE ALERT!!

time person:

person to send to cemetery

static check_inputs(time_config: dict)

Check that the iput time configuration is correct, i.e., activities are among allowed activities and days have 24 hours.

time_config:

dictionary with time steps configuration

clear_world()

Removes everyone from all possible groups, and sets everyone’s busy attribute to False.

do_timestep()

Perform a time step in the simulation. First, ActivityManager is called to send people to the corresponding subgroups according to the current daytime. Then we iterate over all the groups and create an InteractiveGroup object, which extracts the relevant information of each group to carry the interaction in it. We then pass the interactive group to the interaction module, which returns the ids of the people who got infected. We record the infection locations, update the health status of the population, and distribute scores among the infectors to calculate R0.

classmethod from_checkpoint(world: june.world.World, checkpoint_path: str, interaction: june.interaction.interaction.Interaction, infection_selector=None, policies: Optional[june.policy.policy.Policies] = None, infection_seed: Optional[june.infection_seed.infection_seed.InfectionSeed] = None, leisure: Optional[june.groups.leisure.leisure.Leisure] = None, travel: Optional[june.groups.travel.travel.Travel] = None, config_filename: str = PosixPath('/home/sadie/JUNE/configs/config_example.yaml'), record: Optional[Record] = None)
classmethod from_file(world: june.world.World, interaction: june.interaction.interaction.Interaction, infection_selector=None, policies: Optional[june.policy.policy.Policies] = None, infection_seed: Optional[june.infection_seed.infection_seed.InfectionSeed] = None, leisure: Optional[june.groups.leisure.leisure.Leisure] = None, travel: Optional[june.groups.travel.travel.Travel] = None, config_filename: str = PosixPath('/home/sadie/JUNE/configs/config_example.yaml'), checkpoint_path: str = None, record: Optional[Record] = None)Simulator

Load config for simulator from world.yaml

leisure infection_seed policies interaction world config_filename

The path to the world yaml configuration

comment

A brief description of the purpose of the run(s)

A Simulator

infect_people(infected_ids, people_from_abroad_dict)

Given a list of infected ids, it initialises an infection object for them and sets it to person.infection. For the people who do not live in this domain a dictionary with their ids and domains is prepared to be sent through MPI.

recover(person: june.demography.person.Person)

When someone recovers, erase the health information they carry and change their susceptibility.

person:

person to recover

time:

time (in days), at which the person recovers

run()

Run simulation with n_seed initial infections

save_checkpoint(saving_date)
tell_domains_to_infect(infect_in_domains)

Sends information about the people who got infected in this domain to the other domains.

update_health_status(time: float, duration: float)

Update symptoms and health status of infected people. Send them to hospital if necessary, or bury them if they have died.

time:

time now

duration:

duration of time step