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

get_value_config(line)[source]

Gets the value between the brackets <> in a line of the vd config file.

Parameters

line (str) – A single line of string

Returns

Value of the entry in the config file.

Return type

str

read_parameter_file(filename)[source]

Reads and saves the parameters from the parameters.json file.

Parameters

filename (str) – Name of the json file containing the parameters

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

read_files_list()[source]

Reads the files list file and generates a list containing all the files

Return type

None

class BaseReadFile[source]

Base class for reading agents, locations, interactions and events from a file.

get_value(line)[source]

Takes a single line and clips the backslash n element

Parameters

line – A string line

Returns

A string line without the backslash n element

Return type

str

class ReadAgents(filename, config_obj)[source]

Class for reading and storing agent information from the agents file. Inherits BaseReadFile class.

Parameters
read_agents_file()[source]

Reads the agents file (either a txt or csv file) and generates a dictionary mapping agent indices to Agent objects with the information from the file.

Return type

None

create_info_dict(info_list)[source]

Creates a dictionary of information regarding an agent.

Parameters

info_list (List[str]) – List of values for all the parameter keys of an agent.

Returns

Information dictionary of the agent.

Return type

Dict[str, str]

class ReadInteractions(filename, config_obj, agents_obj)[source]

Class for reading and storing individual interaction information from the interactions file. Inherits BaseReadFile class.

Parameters
read_interactions_file()[source]

Reads the interaction file (either a txt or csv file) and adds contact information from the interactions file to the Agent objects.

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 BaseReadFile class.

Parameters
read_locations_file()[source]

Reads the locations file (a txt file) and adds the information from the file to the Agent objects.

Return type

None

create_info_dict(info_list)[source]

Creates a dictionary containing information of a single location.

Parameters

info_list (List[str]) – List of values for all the parameter keys of a location.

Returns

Information dictionary of the location.

Return type

Dict[str, str]

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 BaseReadFile class.

Parameters
read_events_file()[source]

Reads the events file (a txt file) and adds the information from the file to the Location objects.

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 ReadEvents class.

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
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 BaseReadFile class.

Parameters
read_prob_interactions_file()[source]

Reads the probabilistic interaction file (a txt file) and adds contact information from the file to the Agent objects.

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]]]