Symbolic Modelling of Highway Traffic Networks with METANET
sym-metanet is a Python package to model traffic networks with the METANET framework, a collection of tools to mathematically model the macroscopic behaviour of traffic in highway systems (see [1] and [2] for more details).
Installation
To install the package, run
pip install sym-metanet
sym-metanet has the following dependencies
- Python 3.8 or higher
- NetworkX
and optionally
For playing around with the source code instead, run
git clone https://github.com/FilippoAiraldi/sym-metanet.git
Usage
In METANET, a highway network is represented as a directed graph whose edges are stretches of highways, a.k.a. links. Each link bridges between nodes (that have no physical meaning), which in turn can host origins (sources of traffic flow) and destinations (sinks of flow). For instance, to create a very simple network consisting of a single link connecting an origin to a destination, we can do as follows:
import sym_metanet as metanet
...
N1 = metanet.Node(name="N1")
N2 = metanet.Node(name="N2")
L1 = metanet.Link(segments, lanes, L, rho_max, rho_crit, v_free, a, name="L1")
O1 = metanet.Origin(C[0], name="O1")
D3 = metanet.Destination(name="D3")
net = metanet.Network().add_path(origin=O1, path=(N1, L1, N2, L2, N3), destination=D3)
Once the network is built, we can validate it and use, e.g., CasADi, to symbolically construct a function that represents the dynamics governing this network (according to METANET).
net.is_valid(raises=True)
T = 10 / 3600 # sampling time
metanet.engines.use("casadi", sym_type="SX")
F = metanet.engine.to_function(net=net, T=T)
Function F can be then used to simulate the state transitions of the network in the context of, e.g., highway traffic control (see [2] for more details).
Examples
Our examples folder contains an example on how to get started with this package.
Extensions
This code is symbolic-engine-agnostic, in the sense that it does not rely on a particular implementation of the underlying engine for symbolic computations. In other words, it is relatively easy to create a new engine for modelling networks with a new specific symbolic library (e.g., SimPy) by implementing the abstract class sym_metanet.engines.core.EngineBase. An engine implemented in CasADi is already shipped but requires the symbolic library to be installed. Additionally, the engine is also implemented in NumPy (does not allow symbolic computations though).
License
The repository is provided under the MIT License. See the LICENSE file included with this repository.
Author
Filippo Airaldi, PhD Candidate [f.airaldi@tudelft.nl | filippoairaldi@gmail.com]
Delft Center for Systems and Control in Delft University of Technology
Copyright (c) 2023 Filippo Airaldi.
Copyright notice: Technische Universiteit Delft hereby disclaims all copyright interest in the program “sym-metanet” (Symbolic Modelling of Highway Traffic Networks with METANET) written by the Author(s). Prof. Dr. Ir. Fred van Keulen, Dean of 3mE.
References
[1] A. Messmer and Papageorgiou, “METANET: a macroscopic simulation program for motorway networks,” Traffic Engineering and Control, vol. 31, pp. 466–470, 1990.
[2] Hegyi, A., 2004. Model predictive control for integrating traffic control measures. Netherlands TRAIL Research School.
Metadata
Release files for sym-metanet 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sym_metanet-1.1.2.tar.gz | 37.9 kB | Without provenance | Details for sym_metanet-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sym_metanet-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for sym_metanet-1.1.2-py3-none-any.whl |
Total release size: 73.3 kB
Release files / sym_metanet-1.1.2.tar.gz
| Download URL | sym_metanet-1.1.2.tar.gz |
|---|---|
| Size | 37.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2c6c3c044fbfa258de09bd60ee3ea5aba4479ea026b6b4336b81c07457bfd85
|
|
BLAKE2b-256 checksum How to use checksums |
a306db5dc0454344abe48096ef7fd5e423cccf02c0b50d1f44e022836325e904
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.22
|
Release files / sym_metanet-1.1.2-py3-none-any.whl
| Download URL | sym_metanet-1.1.2-py3-none-any.whl |
|---|---|
| Size | 35.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73b9979a818cca8244b6ec2386bf03abffd592b7f7c7864ffa6f6a0d570280c3
|
|
BLAKE2b-256 checksum How to use checksums |
c22d20639fa15611f06356d1c71013eb7277da16c7a9d3d19b27039cdbcc3102
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.22
|
Security for sym-metanet 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.