Skip to main content

A NumPy/SciPy-based microscopic traffic simulator

Project description

Fast Traffic Simulator

A NumPy/SciPy-based microscopic traffic simulator for directed road networks.

We develop this package at @fbk-most, a research unit at Fondazione Bruno Kessler.

The simulator models individual vehicles travelling from an origin node to a destination node across a directed graph of road edges. Shortest-path routing is computed via Dijkstra's algorithm and can be refreshed periodically to reflect current congestion. Vehicle behaviour on links follows Newell's simplified car-following model: each vehicle moves as fast as possible while respecting the road speed limit and keeping a safe distance from the vehicle ahead. This reproduces queue formation and congestion without explicit capacity constraints. Nodes are treated as dimensionless transfer points — travel time accrues only on links — and each edge supports multiple independent lanes.

Note: this package is currently in an early development stage. APIs may change without notice between releases.

Installation

pip install fast-traffic-simulator

Or, for development (requires uv):

git clone https://github.com/fbk-most/FastTrafficSimulator
cd FastTrafficSimulator
uv sync

Quick start

import pandas as pd
from fts import Simulator

# Build a minimal two-edge graph: 0 → 1 → 2
edges = pd.DataFrame({
    'from':   [0, 1],
    'to':     [1, 2],
    'length': [100.0, 150.0],
    'speed':  [10.0, 15.0],
    'lanes':  [1, 1],
})

# One vehicle travelling from node 0 to node 2, departing at step 0
vehicles = pd.DataFrame({
    'origin':      [0],
    'destination': [2],
    'start':       [0],
})

simulator, _ = Simulator.build(edges=edges, vehicles=vehicles)

while True:
    simulator.step()
    arrived = (simulator.vehicles.status == Simulator.VehicleStatus.ARRIVED.value).sum()
    if arrived == len(vehicles):
        break

print(f"Vehicle arrived at step {simulator.vehicles.arrival_time[0]}")

Main contributors

Marco Pistore: design and implementation.

Acknowledgements

This software has been developed in the scope of the Bologna Digital Twin project, and partially supported by the following projects:

  • NRR ICSC National Research Centre for High Performance Computing, Big Data and Quantum Computing (CN00000013), under the NRRP MUR program funded by the NextGenerationEU.
  • European Structural and Investment Funds, as part of the National Program for Metropolitan Cities and Medium-Sized Cities South 2021-2027, Priority 1 Digital Agenda and Urban Innovation,Action 1.1.2.1 Metropolitan Digital Agenda, Project BO1.1.2.1.a "DIGITAL TWIN: GOVERNANCE AND ENHANCEMENT OF DATA ASSETS"

License

Copyright 2025-2026 Fondazione Bruno Kessler

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_traffic_simulator-0.1.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fast_traffic_simulator-0.1.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file fast_traffic_simulator-0.1.0.tar.gz.

File metadata

  • Download URL: fast_traffic_simulator-0.1.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fast_traffic_simulator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 004b0ee6890104529cc1a7719ad9e9d37aeb9de2bba7a5b8ce535cbfa120874a
MD5 e7e14776c236dc95eb2af369a4e5ad1c
BLAKE2b-256 5bafd045c35a58d8d7d576317978f76f9c7b7eed59a19172709931f7f5e14c62

See more details on using hashes here.

File details

Details for the file fast_traffic_simulator-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fast_traffic_simulator-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fast_traffic_simulator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17166362a3fc3518448d6a8fa8446e824e1fcae2eefcb25f59656e59c0ed4720
MD5 812624d1315d74dba52617f7153bb047
BLAKE2b-256 acfcf09607cbdd3aebdc1101cb7a01a767ded7ef21ff36b14c458d154ef426c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page