Mesacat Documentation¶
Module contents¶
-
class
mesacat.EvacuationModel(hazard, output_path, domain=None, target_types=('school', ), network=None, targets=None, target_capacity=100, agents=None, seed=None)¶ Bases:
mesa.model.ModelA Mesa ABM model to simulate evacuation during a flood
- Parameters
hazard (
GeoDataFrame) – Spatial table of flood hazard zones in WGS84output_path (
str) – Path to output files without extensiondomain (
Optional[Polygon]) – Polygon used to select OSM data, required if the graph, agents or targets are not specifiedtarget_types (
Iterable[str]) – List of OSM amenity values to use as targets, defaults to schoolnetwork (
Optional[Graph]) – Undirected network generated from OSM road networktargets (
Optional[GeoDataFrame]) – Spatial table of OSM amenitiestarget_capacity (
int) – The number of agents that can be evacuated to each targetagents (
Optional[GeoDataFrame]) – Spatial table of agent starting locationsseed (
Optional[int]) – Seed value for random number generation
-
output_path¶ Path to output files without extension
- Type
str
-
schedule¶ Scheduler which activates each agent once per step, in random order, with the order reshuffled every step
- Type
RandomActivation
-
hazard¶ Spatial table of flood hazard zones in WGS84
- Type
GeoDataFrame
-
G¶ Undirected network generated from OSM road network
- Type
Graph
-
nodes¶ Spatial table of nodes in G
- Type
GeoDataFrame
-
edges¶ Spatial table edges in G
- Type
GeoDataFrame
-
grid¶ Network grid for agents to travel around based on G
- Type
NetworkGrid
-
data_collector¶ Stores the model state at each time step
- Type
DataCollector
-
target_nodes¶ Series of nodes to evacuate to
- Type
Series
-
target_capacity¶ The number of agents that can be evacuated to each target
- Type
int
-
igraph¶ Duplicate of G as an igraph object to speed up routing
-
run(steps)¶ Runs the model for the given number of steps`
- Parameters
steps (
int) – number of steps to run the model for- Returns
the agent vars dataframe
- Return type
DataFrame
-
step()¶ Advances the model by one step and then stores the current state in data_collector
-
class
mesacat.EvacuationAgent(unique_id, evacuation_model)¶ Bases:
mesa.agent.AgentA person who is evacuating at a given speed
- Parameters
unique_id (
int) – an identifier for the agentevacuation_model (
EvacuationModel) – the parent EvacuationModel
-
route¶ a list of node IDs that the agent is traversing
- Type
typing.List[int]
-
route_index¶ the number of nodes that the agent has passed along the route
- Type
int
-
speed¶ the speed at which the agent is travelling (km/hr)
- Type
float
-
distance_along_edge¶ the distance that the agent has travelled from the most recent node
- Type
float
-
pos¶ the ID of the most recent node that has been passed
- Type
int
-
distance_to_next_node()¶ Finds the distance to the next node along the route
-
step()¶ Moves the agent towards the target node by 10 seconds
-
update_location()¶
-
update_route()¶ Updates the agent’s route to the target node
-
mesacat.create_movie(in_path, out_path, fps=5)¶ Generates an MP4 video of all model steps using FFmpeg (https://www.ffmpeg.org/)
- Parameters
in_path (
str) – path to model output files without extensionout_path (
str) – path to movie filefps (
int) – frames per second of the video