Skip to content

OpenRailAssociation/dac-migration-dss-popupsim

PopUpSim - DAC Migration Simulation Tool

Badge Stage 1 License Python Backend

PopUpSim is a microscopic simulation system for optimizing Pop-Up retrofitting sites during the European freight rail industry's transition to Digital Automatic Couplers (DAC). The tool simulates the complex logistics of retrofitting approximately 500,000 freight wagons during the critical 3-week "Big Bang" migration period (2029-2034).

Overview

PopUpSim helps railway operators:

  • Test workshop configurations - Develop and validate standardized Pop-Up workshop designs
  • Estimate throughput - Calculate maximum wagon processing capacity
  • Import infrastructure data - Use existing railway infrastructure data (CSV/JSON)
  • Identify bottlenecks - Optimize resource allocation before real-world implementation
  • Assess capacity - Validate if planned workshops meet migration targets

Key Features

  • Microscopic Simulation - Track individual wagons and resources through workshop operations
  • SimPy-based Engine - Deterministic discrete event simulation for reproducible results
  • File-based Configuration - Easy-to-edit JSON/CSV configuration files
  • Comprehensive Analysis - Throughput metrics, utilization statistics, bottleneck identification
  • Open Source - Apache 2.0 licensed for cross-company collaboration

Quick Start

Prerequisites

  • Python 3.13 or higher
  • uv package manager

If uv is used, the necessary Python version will be automatically installed during installation of PopUpSim. For different ways of installing uv can be found in Step 1 of the installation guide.

Installation

A more detailed description of the installation process can be found in the installation guide

Option 1: Using Git (Recommended)

If you have a git client installed:

# Clone repository
git clone https://github.com/OpenRailAssociation/dac-migration-dss-popupsim.git
cd dac-migration-dss-popupsim

# Install dependencies
uv sync

# Run example simulation
uv run python popupsim/backend/src/main.py --scenario Data/examples/demo/ --output output/

Option 2: Download ZIP Archive

If you don't have git installed:

  1. Download the latest release as ZIP:

  2. Extract the archive to your desired location

  3. Open a terminal/command prompt and navigate to the extracted folder:

    cd dac-migration-dss-popupsim-main
    
    # Install dependencies
    uv sync
    
    # Run example simulation
    uv run python popupsim/backend/src/main.py --scenario Data/examples/demo/ --output output/

Running PopUpSim

After installation, run simulations with:

# Navigate to project directory (if not already there)
cd dac-migration-dss-popupsim

# Run with baseline scenario
uv run python popupsim/backend/src/main.py --scenario Data/examples/ten_trains_two_days_baseline/ --output output/

# Or run a variant scenario
uv run python popupsim/backend/src/main.py --scenario Data/examples/ten_trains_two_days_var1/ --output output/var1/

Viewing Results with Dashboard

PopUpSim includes a web-based dashboard for visualizing simulation results:

Windows:

run_dashboard.bat

Linux/macOS:

uv run streamlit run popupsim/frontend/streamlit_dashboard.py

The dashboard will open in your browser at http://localhost:8501

Dashboard Features:

  • Overview - KPIs, wagon flow, locomotive activity, workshop utilization
  • Wagon Flow - Individual wagon journeys, status distribution, track occupancy over time
  • Workshop Performance - Utilization, throughput, comparison between workshops
  • Locomotive Operations - Activity breakdown, utilization percentages
  • Track Capacity - Track utilization, capacity analysis
  • Rejected Wagons - Rejection reasons and details
  • Event Log - Searchable simulation events
  • Process Log - Detailed process execution log

Note: Run the dashboard in a separate terminal window so you can continue running simulations.

Example Scenarios

Seven ready-to-use scenarios are included (10 trains, 224 wagons over 2 days):

  • Baseline - 2 locomotives, 2 collection tracks, 2 workshops (2 bays each), 1 retrofit track, 1 retrofitted track
  • Variant 1 - 1 locomotive (bottleneck), 3 collection tracks, 2 workshops (2 bays each)
  • Variant 2 - 1 locomotive, 3 collection tracks, 2 workshops (2 bays each), 2 retrofit tracks
  • Variant 3 - 2 locomotives, 3 collection tracks, 2 workshops (2 bays each)
  • Variant 4 - 2 locomotives, 3 collection tracks, 2 workshops (4 bays each - increased capacity)
  • Variant 5 - 4 locomotives, 3 collection tracks, 2 workshops (4 bays each), 2 retrofitted tracks
  • Variant 6 - Same as Variant 5 but with opportunistic parking strategy

Known Limitations:

  • ⚠️ Multiple retrofitted tracks: Currently not fully stable - use single retrofitted track for production scenarios
  • ⚠️ Smart accumulation parking strategy: May cause simulation deadlock if threshold is not reached at end of simulation - use opportunistic strategy for reliability

Architecture

PopUpSim MVP uses a 3-context architecture:

  1. Configuration Context - Input validation & parsing (Pydantic)
  2. Workshop Operations Context - Simulation execution & analysis (SimPy)
  3. Analysis & Reporting Context - Orchestration & output (Matplotlib, CSV)

For detailed architecture documentation, see docs/mvp/architecture/.

Documentation

Development

Setup Development Environment

# Install with development dependencies
uv sync --all-extras --dev

# Install pre-commit hooks
uv pip install pre-commit
pre-commit install
uv run ./setup/dev/set_commit_msg_hooks.py

Development Commands

# Run all quality checks
uv run ruff format . && uv run ruff check . && uv run mypy popupsim/backend/src/ && uv run pylint popupsim/backend/src/ && uv run pytest

# Individual commands
uv run pytest                          # Run tests
uv run ruff format .                   # Format code
uv run ruff check .                    # Lint code
uv run mypy popupsim/backend/src/      # Type checking
uv run pylint popupsim/backend/src/    # Code quality analysis

Code Quality Standards

  • Type hints mandatory - All functions/methods must have explicit type annotations
  • MyPy strict mode - disallow_untyped_defs = true
  • Ruff formatting - Consistent code style
  • Pytest - Comprehensive test coverage
  • Pylint - Static code analysis and linting

Technology Stack

  • Python 3.13+ - Latest stable Python with improved type system
  • SimPy - Discrete event simulation framework
  • Pydantic 2.0+ - Data validation and settings management
  • Matplotlib - Visualization and chart generation
  • Pandas - CSV data processing
  • uv - Fast, reliable Python package manager

Project Status

Current Phase: MVP Implementation and code stabilization

Contributing

We welcome contributions from the railway industry and open source community!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Make your changes following code quality standards
  4. Run all quality checks
  5. Commit your changes (git commit -m 'Add feature')
  6. Push to the branch (git push origin feature/your-feature)
  7. Open a Pull Request

See CONTRIBUTING.md for detailed guidelines.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Acknowledgments

  • Open Rail Association - Project governance and cross-company collaboration
  • 3-Länderhack 2024 - Initial prototype development with ÖBB, DB, and SBB
  • DB Cargo Migration Team - Domain expertise and requirements
  • Skydeck Accelerator (DB Systel GmbH) - Project support

Contact & Support


Note: PopUpSim is under active development. The MVP focuses on desktop simulation with file-based configuration. Future versions will include e.g. a web interface.

About

PopUp-Sim: Simulation of the migration to the digital automatic coupler

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages