Intro to GeNet: Network Scenario Generator
Our new open-source tool for programmatically modifying transport network representations
Kasia is a data scientist working with agent-based models in Arup’s City Modelling Lab.
In Arup’s City Modelling Lab, we build agent-based models to help cities, regions, and nations plan for more sustainable, equitable, and healthier futures. Every time we build a new model, we need to build a network to represent the ways people travel. When we consider future scenarios, we have to modify the existing network.
We built GeNet (Network Scenario Generator) to help. And we have made it open source because we believe that decisions that impact the public need to be transparent. We also hope there are collaborators out there who want to build on this project — so that network generation becomes a simple process for everyone.
GeNet is used to represent multimodal transport networks, in memory, to aid use, modification, validation and visualisation of such networks.
Who is this for?
Right now, the tool is most useful for creating scenarios using existing MATSim networks. MATSim is an open-source software for implementing agent-based transport simulations. We are still developing GeNet — one day we would like to see other formats supported. GeNet features methods to generate road networks from OSM and public transit (PT) schedules from GTFS. There is on-going development to provide the functionality to snap and route the schedules on the network, thus completing a network generation process.
Motivation
The networks that we work with within the City Modelling Lab are big and complicated. This tool gives us a simple python interface to interact with networks. The main motivation for this work was to make modifications to networks easier and any changes traceable. GeNet keeps a change log which records edits to the network. We allow changes, like removing or adding infrastructure. Once a change is applied, we want to check that our network is still valid — GeNet includes methods to validate the graph, public transit schedule and the routing of the schedule on the network graph. Another, important, part of validating the network is actually looking at it. We added methods which generate multiple geojson and shape file outputs to streamline the network evaluation process.
GeNet Network
By a multimodal transport network we mean a network graph that has different modes stored on the edges, like walk, bike, rail, bus as well as car or driving, and there is a public transit schedule associated with that graph. In GeNet we have two major classes: genet.Network which includes information about the graph, which can have multiple edges between the same pair of nodes, the indexing of links which uniquely index each of those possibly multiple edges, and a reference to a genet.Schedule which consists of genet.Services. A Service corresponds to a specific transit line, for example the Piccadilly London Underground line. Each Service will have a number of genet.Routes which are characterised by an ordered sequence of genet.Stops. For a network to be a valid multimodal network each genet.Route needs to have a valid reference to genet.Network links which defines the movements of the PT vehicles.
Features
Below we share a few examples of how we use GeNet. Full feature and usage details can be found in GeNet’s wiki pages and example jupyter notebooks.
Using a GeNet Network
Being able to load up a network and access the data stored on nodes and link comes in very handy when we want to generate road pricing information that complements the network. It defines the tolls that should be paid by agents in the model if they choose to travel on those roads. We query Open Street Map (OSM) data stored on the links to find out whether they should be tolled.
Modification
The biggest motivation behind GeNet was making a quick job of generating network scenarios. GeNet lets you add, remove and change any data already stored on the links. Coupling this with extracting links of interest based on user-defined conditions makes for a flexible and powerful tool. This allows us to test how the agents in our models will behave if there is a road closure for example. Any changes you make to the network using GeNet’s class methods will be tracked in a change log.
Validation
There are two main validation streams in GeNet. If you have a Google Directions API key you may like to have a go at using our methods to extract Google speeds for the links in your network. You can compare them with the speeds you have assigned to your links, or replace them with the Google speeds altogether. If you are thinking about replacing the speeds, be sure to harvest the Google speeds in the middle of the night to prevent polluting your network with traffic conditions — let’s leave that one to the model ;).
The second validation method is more pragmatic. It’s a suite of tests that prevents us from making mistakes we made in the past when running simulations in MATSim with home-cooked networks. The tests include: assessing strong-connectivity of the modal subgraphs of the network, checking the validity of the public transit Schedule, and checking the relationship between the network links and the routing of all of the public transit services.
Visualisation
Each GeNet class has a quick plot method, but our favourite is a method to generate standard outputs that automate some of our workflow. This is a bundle of standard geojsons, shapefiles, and CSVs containing high-level Schedule stats. These can be used to share the network with non-technical stakeholders and evidence that the network has been properly built. This method allows us to quickly generate outputs we need whenever we generate or modify a network.
Conclusions
For now GeNet caters mainly to MATSim networks. It would be great to extend it beyond this one simulation paradigm by writing extra read and write methods and ironing out some of the inevitable wrinkles that made their way inside GeNet. If you work with other networks and have enjoyed reading this post, checkout GeNet on github. We would appreciate any comments or suggestions you may have, and would be more than happy to see people get involved and contribute their code and/or experience to the project — here is a link to the contribution guide with some ideas on how you could contribute.