episimmer.simulate

class Simulate(config_obj, model, policy_list, agents_obj, locations_obj)[source]

Class for handling a simulation. It takes care of all the steps throughout a simulation run.

Parameters
on_start_simulation()[source]

Function to initialize agent states, reset policies and initialize the state list and history,

Return type

None

on_start_time_step(interaction_files_list_of_list, event_files_list_of_list, probabilistic_interaction_files_list_of_list, one_time_event_obj)[source]

Function to reset agents and locations for a new time step, to load all the types of interactions from their respective files and to run policies. Policies are run in two steps here. First, the policies that are independent of all the interactions and events present are run with the enact_policy method and the policies that do depend on them are run with post_policy method. After the policy is finished running, all types of events are handled by saving the probability of infection for each agent.

Parameters
  • interaction_files_list_of_list (List[List[str]]) – List of path names of all the interactions files

  • event_files_list_of_list (List[List[str]]) – List of path names of all the events files

  • probabilistic_interaction_files_list_of_list (List[List[str]]) – List of path names of all the probabilistic interactions files

  • one_time_event_obj (episimmer.read_file.ReadOneTimeEvents) – An object of class ReadOneTimeEvents

Return type

None

handle_time_step_for_all_agents()[source]

Find the next state and save it for every agent, and then convert each agent’s current state to the saved next state.

Return type

None

handle_time_step_as_agent(agent)[source]

Finds the next state and save it for the agent

Args:

agent: Agent whose next state is to be set

Parameters

agent (episimmer.agent.Agent) –

Return type

None

end_time_step()[source]

Stores the state of the simulation at the end of the time step.

Return type

None

valid_interaction(agent, c_dict)[source]

Checks whether the contact of an agent will interact with the agent. If the current agent is under the protection of a vaccine, the contact is said to not occur. Other factors include variables set by lockdown (restriction) policies that change the probability of the current agent locking himself down. This is done with the can_contribute_infection and can_receive_infection variables.

Parameters
  • agent (episimmer.agent.Agent) – The current agent

  • c_dict (Dict[str, str]) – Contact dictionary of the agent

Returns

Boolean representing whether the interaction will take place or not.

Return type

bool

store_event_lists(event_info)[source]

Checks whether agents part of an event can contribute infection to the event or receive infection from the event or both. This function saves the agents that can do either in the event_info dictionary,

Parameters
  • event_info (Dict[str, Union[float, str, List[str]]]) – A dictionary containing event information at a location that contains all the agents part of

  • event. (the) –

Return type

None

save_valid_interactions_events()[source]

Saves all the valid interactions and events in the current time step of the simulation.

Return type

None

end_simulation()[source]

Returns the state history at the end of the simulation.

Return type

Dict[str, List[int]]

store_state()[source]

Stores the number of agents in each state in the state history at each time step.

Return type

None

convert_state(agent)[source]

Updates the state list when an agent transitions from one state to another.

Parameters

agent (episimmer.agent.Agent) – Agent whose next state is to be set

Return type

None