pandemia.world.region¶
Module Contents¶
Classes¶
Represents a region, for example a country or an administrative division, consisting of |
|
Represents a region, for example a country or an administrative division, in vector |
Attributes¶
- pandemia.world.region.log¶
- class pandemia.world.region.Region(id: int, name: str, activities: list[str], agents: list[pandemia.world.agent.Agent], locations: list[pandemia.world.location.Location])¶
Represents a region, for example a country or an administrative division, consisting of agents, locations and activities.
Parameters:¶
- idint
An integer identifier for this region.
- namestr
The name of the region. For example, if the region represents a country, this could be the country code in ISO 3166-1 alpha-2 format.
- activities: list[str]
A list of all activities performed by agents in this region.
- agents: list[Agent]
A list of all agents in this region.
- locations: list[Location]
A list of all locations in this region.
- id¶
An integer identifier for this region (int).
- name¶
The name of the region (str). For example, if the region represents a country, this could be the country code in ISO 3166-1 alpha-2 format.
- other_name¶
Another name of the region (Union[None, str])). For example, if the region represents a country, this could be the country code in ISO 3166-1 alpha-3 format.
- super_region¶
The group of regions to which this region belongs (Union[None, str])). For example, if the regions represents a country, its super region might be the continent to which it belongs.
- activities¶
A list of all activities performed by agents in this region (str).
- agents¶
A list of all agents in this region (list[Agent]).
- locations¶
A list of all locations in this region (list[Location]).
- coordinates¶
Used to render the region as polygons (Union[None, list]). If provided, the list should be of the format:
[[points_0], [points_1], …, [points_N]]
with each points_n a list of 2-tuples of floats. A list points_n represents the x, y coordinates of each point along the border of a connected piece of the region.
- region_coordinates¶
Used to render the region as grid squares (Union[None, list]). If provided, the list should be a list of 2-tuples of floats, representing the x, y coordinates of each grid square.
- vectorize_region()¶
Converts the object of type Region to an object of type VectorRegion. The latter objects are vectorized versions of the former, consisting mainly of numpy arrays.
- Returns:
vector_region – A vector representation of the region.
- Return type:
VectorRegion
- class pandemia.world.region.VectorRegion(id: int, name: str, ticks_in_week: int, number_of_activities: int, number_of_agents: int, number_of_locations: int, max_num_activity_locations: int)¶
Represents a region, for example a country or an administrative division, in vector format. Agents, locations and activities are now represented as integers, with various arrays used to store their attributes. Further attributes, in addition to the ones below, may be added to the vector world by simulation components, where necessary.
Parameters:¶
- idint
An integer identifier for this region. This will be determined by the world factory.
- namestr
A name for this region. For example, if the region represents a country, this could be the country code in ISO 3166-1 alpha-2 format.
- ticks_in_weekint
The number of clock ticks in the week.
- number_of_agents: int
The number of agents in this region.
- number_of_activities: int
The number of activities performed by agents in this region.
- number_of_locations: int
The number of locations in this region.
- max_num_activity_locations: int
The maximum number of locations at which it is possible to perform an activity (int). This maximum is taken accross all agents and all activities in this region.
- id¶
An integer identifier for this region (int). This will be determined by the world factory.
- name¶
A name for this region (str). For example, if the region represents a country, this could be the country code in ISO 3166-1 alpha-2 format.
- other_name¶
Another name of this region (Union[None, str]). For example, if the region represents a country, this could be the country code in ISO 3166-1 alpha-3 format.
- super_region¶
The group of regions to which this region belongs (Union[None, str]). For example, if the regions represents a country, its super region might be the continent to which it belongs.
- random_state¶
A pair of 64-bit integers (Union[None, np.ndarray]). This pair is the random seed to be used by the prng inside the C libraries. This is an numpy array of length 2, consisting of two integers of type numpy.uint64. Each region gets it own random state, to preserve determinism when parallelizing.
- prng¶
An instance of the Random class for this region (Union[None, Random]). Each region gets it own instance of the Random class, to preserve determinism when parallelizing.
- number_of_agents¶
The number of agents in this region (int).
- number_of_locations¶
The number of locations in this region (int).
- number_of_activities¶
The number of activities performed by agents in this region (int).
- age¶
An array of length number_of_agents recording the age of each agent (np.ndarray).
- weekly_routines¶
For each agent, a sequence of integers of length ticks_in_week, indicating which activities (represented as integers) are performed each tick (np.ndarray).
- num_activity_locations¶
For each agent, for each activity, the number of locations at which that agent can perform that activity (np.ndarray).
- activity_locations¶
For each agent, for each activity, the locations (represented as integers) at which the agent can perform that activity (np.ndarray). The number of locations at which agents perform activities may be variable, as recorded by num_activity_locations, but should be bounded above by max_num_activity_locations. This array is not a jagged array, the entries between num_activity_locations and max_num_activity_locations being padding.
- activity_location_weights¶
For each agent, for each activity, the weights for each location at which the agent can perform that activity (np.ndarray). The weights need not sum to one, with these weights being only relavent upto num_activity_locations. This array is not a jagged array, the entries between num_activity_locations and max_num_activity_locations being padding.
- max_num_activity_locations¶
The maximum number of locations at which it is possible to perform an activity (int). This maximum is taken accross all agents and all activities in this region.
- activity_strings¶
The list of activities for this region (list[str]). If an activity is represented by the integer a, then the corresponding string will be activity_strings[a], for example “Home”.
- location_typ_strings¶
If a location is represented by the integer l, then location_typ_strings[l] gives the type of location l, for example “House” (list[str]).
- location_x_coords¶
The x coordinates of all locations in this region (np.ndarray).
- location_y_coords¶
The y coordinates of all locations in this region (np.ndarray).
- coordinates¶
Used to render the region as polygons (Union[None, list]). If provided, the list should be of the format:
[[points_0], [points_1], …, [points_N]]
with each points_n a list of 2-tuples of floats. A list points_n represents the x, y coordinates of each point along the border of a connected piece of the region.
- region_coordinates¶
Used to render the region as grid squares (Union[None, list]). If provided, the list should be a list of 2-tuples of floats, representing the x, y coordinates of each grid square.