Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

wang-boyu/agents-and-networks-in-python

Repository files navigation

!!Repository Archived!!

  • This model has been merged into the mesa-examples repository under its gis/ folder: new location.
  • No further updates will be made here.

Agents and Networks Model in Python

Summary

This is an implementation of the GMU-Social Model in Python, using Mesa and Mesa-Geo.

In this model, buildings are randomly assigned to agents as their home and work places, and the buildings' nearest road vertices are used as their entrances. Agents' commute routes can be found as the shortest path between entrances of their home and work places. These commute routes are segmented according to agents' walking speed. In this way, the movements of agents are constrained on the road network.

GeoSpace

The GeoSpace contains multiple vector layers, including buildings, lakes, and a road network. More specifically, the road network is constructed from the polyline data and implemented by two underlying data structures: a topological network and a k-d tree. First, by treating road vertices as nodes and line segments as links, a topological network is created using the NetworkX and momepy libraries. NetworkX also provides several methods for shortest path computations (e.g., Dijkstra, A-star). Second, a k-d tree is built for all road vertices through the Scikit-learn library for the purpose of nearest vertex searches.

GeoAgent

The commuters are the GeoAgents.

How to run

First install the dependencies:

python3 -m pip install -r requirements.txt

Then run the model:

python3 scripts/run.py --campus ub

Change ub to gmu for a different campus map.

Open your browser to http://127.0.0.1:8521/ and press Start.