episimmer.read_file
Reading Configuration Files API
- class ReadConfiguration(filename)[source]
Class for reading the simulation configuration file
- Parameters
filename (str) – Name of the directory containing simulation files
- read_config_file()[source]
Reads the config.txt file and populates the class with the parameters passed
- Return type
None
- get_value_config(line)[source]
Gets the value between the brackets <> in a line of the config file.
- Parameters
line (str) – A single line of string
- Returns
Value of the entry in the config file.
- Return type
str
- get_file_paths(example_path)[source]
Gets the paths of the agents file, interactions files, events files, locations file, one time event file, and probabilistic interactions files from the config file.
- Parameters
example_path (str) – Path of the directory containing the simulation files.
- Returns
Tuple containing paths of the agents file, interactions files, events files, locations file, one time event file and probabilistic interactions files.
- Return type
Tuple[str, List[str], List[str], str, str, List[str]]
- get_file_names_list(example_path, interactions_files_list_filename, events_files_list_filename, probabilistic_interactions_files_list_filename)[source]
Gets the lists of all the paths to the interaction files, events files and probabilistic interaction files.
- Parameters
example_path (str) – Path of the directory containing simulation files
interactions_files_list_filename (List[str]) – List of path names of all the interactions files
events_files_list_filename (List[str]) – List of path names of all the events files
probabilistic_interactions_files_list_filename (List[str]) – List of path names of all the probabilistic interactions files
- Returns
Tuple containing list of interaction files, list of events files, and list of probabilistic interaction files.
- Return type
Tuple[List[List[str]], List[List[str]], List[List[str]]]
- class ReadVDConfiguration(filename)[source]
Class for reading the Vulnerability Detection configuration file
- Parameters
filename (str) – Name of the directory containing simulation files
- read_vd_config_file()[source]
Reads the vd_config.txt file and populates the class with the parameters passed
- Return type
None
Reading Single Files API
- class ReadFilesList(filename)[source]
Reads and saves the list of file names from the files list file
- Parameters
filename (str) – Name of the files list file
- class BaseReadFile[source]
Base class for reading agents, locations, interactions and events from a file.
- class ReadAgents(filename, config_obj)[source]
Class for reading and storing agent information from the agents file. Inherits
BaseReadFileclass.- Parameters
filename (str) – Name of the file containing agent information.
config_obj (episimmer.read_file.ReadConfiguration) – An object of class
ReadConfigurationcontaining the simulation configurations.
- class ReadInteractions(filename, config_obj, agents_obj)[source]
Class for reading and storing individual interaction information from the interactions file. Inherits
BaseReadFileclass.- Parameters
filename (str) – Name of the file containing individual interaction information.
config_obj (episimmer.read_file.ReadConfiguration) – An object of class
ReadConfigurationcontaining the simulation configurations.agents_obj (episimmer.read_file.ReadAgents) – An object of class
ReadAgentscontaining agent information
- read_interactions_file()[source]
Reads the interaction file (either a txt or csv file) and adds contact information from the interactions file to the
Agentobjects.- Return type
None
- get_interaction(parameter_list)[source]
Creates a dictionary containing information of a single interaction.
- Parameters
parameter_list (List[str]) – List of values for all the parameter keys of an interaction.
- Returns
Information dictionary of the interaction.
- Return type
Tuple[Optional[str], Optional[Dict[str, str]]]
- class ReadLocations(filename, config_obj)[source]
Class for reading and storing location information from the locations file. Inherits
BaseReadFileclass.- Parameters
filename (str) – Name of the file containing location information.
config_obj (episimmer.read_file.ReadConfiguration) – An object of class
ReadConfigurationcontaining the simulation configurations.
- class ReadEvents(filename, config_obj=None, locations_obj=None, agents_obj=None)[source]
Class for reading and storing simple event information from the events file. Inherits
BaseReadFileclass.- Parameters
filename (str) – Name of the file containing event information.
config_obj (Optional[episimmer.read_file.ReadConfiguration]) – An object of class
ReadConfigurationcontaining the simulation configurations.locations_obj (Optional[episimmer.read_file.ReadLocations]) – An object of class
ReadLocationscontaining location informationagents_obj (Optional[episimmer.read_file.ReadAgents]) – An object of class
ReadAgentscontaining agent information
- read_events_file()[source]
Reads the events file (a txt file) and adds the information from the file to the
Locationobjects.- Return type
None
- get_event(parameter_list)[source]
Creates a dictionary containing information of a single event.
- Parameters
parameter_list (List[str]) – List of values for all the parameter keys of an event.
- Returns
Information dictionary of the event.
- Return type
Tuple[Optional[str], Optional[Dict[str, Union[float, str, List[str]]]]]
- class ReadOneTimeEvents(filename)[source]
Class for reading and storing one time event information from the one time event file. Inherits
ReadEventsclass.- Parameters
filename (str) – Name of the file containing one time event information.
- read_one_time_events_file()[source]
Reads the one time events file (a txt file) and populates a dictionary mapping from time step to event information
- Return type
None
- populate_one_time_events(config_obj, locations_obj, agents_obj, time_step)[source]
Populates the locations objects with one time events at the current time step
- Parameters
config_obj (episimmer.read_file.ReadConfiguration) – An object of class
ReadConfigurationcontaining the simulation configurations.locations_obj (episimmer.read_file.ReadLocations) – An object of class
ReadLocationscontaining location informationagents_obj (episimmer.read_file.ReadAgents) – An object of class
ReadAgentscontaining agent informationtime_step (int) – current time step
- Return type
None
- class ReadProbabilisticInteractions(filename, config_obj, agents_obj)[source]
Class for reading and storing probabilistic interaction information from the probabilistic interactions file. Inherits
BaseReadFileclass.- Parameters
filename (str) – Name of the file containing probabilistic interaction information.
config_obj (episimmer.read_file.ReadConfiguration) – An object of class
ReadConfigurationcontaining the simulation configurations.agents_obj (episimmer.read_file.ReadAgents) – An object of class
ReadAgentscontaining agent information
- read_prob_interactions_file()[source]
Reads the probabilistic interaction file (a txt file) and adds contact information from the file to the
Agentobjects.- Return type
None
- get_interactions(parameter_list)[source]
Generates the interactions using probability values and agent indices given in the probabilistic interactions file.
- Parameters
parameter_list (List[str]) – List containing probability of interaction and agent indices associated with that probability.
- Returns
Interaction list consisting of tuples of agent index and interaction information (as a dictionary).
- Return type
List[Tuple[str, Dict[str, str]]]