Skip to content

Atrex198/SIH

Repository files navigation

🚄 AI-Powered Railway Traffic Control System

Python PyTorch Flask License

An advanced AI-powered railway traffic control system that combines Graph Neural Networks (GNN), Reinforcement Learning (RL), and Operations Research (OR) to optimize train scheduling, routing, and real-time decision making for Indian railway networks.

🎯 Key Features

🧠 Hybrid AI Architecture

  • Graph Neural Networks (GNN): Models complex railway network relationships
  • Reinforcement Learning (PPO): Learns optimal policies through simulation
  • Operations Research: Validates AI decisions with safety constraints
  • Hybrid Decision Making: "AI Proposes, OR Disposes" methodology

🚆 Real-time Operations

  • Live Train Tracking: Real-time position and status monitoring
  • Dynamic Scheduling: Adaptive scheduling based on current conditions
  • Conflict Resolution: Automatic detection and resolution of scheduling conflicts
  • Performance Optimization: Speed, fuel efficiency, and delay minimization

📊 Advanced Analytics

  • Performance Metrics: On-time performance, throughput, safety violations
  • Real-time Dashboard: Web-based monitoring and control interface
  • Predictive Analytics: Delay prediction and route optimization
  • Data Visualization: Interactive network and performance visualizations

🏗️ System Architecture

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Web Frontend  │    │   Flask API     │    │  AI Controller  │
│                 │◄──►│                 │◄──►│                 │
│ • Dashboard     │    │ • REST Endpoints│    │ • GNN + RL + OR │
│ • Visualization │    │ • Real-time Data│    │ • Decision Engine│
└─────────────────┘    └─────────────────┘    └─────────────────┘
                                │
                                ▼
                       ┌─────────────────┐
                       │  Railway Env    │
                       │                 │
                       │ • Train Sim     │
                       │ • Network Model │
                       │ • Physics Engine│
                       └─────────────────┘

🚀 Quick Start

Prerequisites

  • Python 3.8+
  • PyTorch 2.0+
  • CUDA (optional, for GPU acceleration)

Installation

  1. Clone the repository
git clone https://github.com/your-username/ai-railway-control.git
cd ai-railway-control
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Run the system
python live_railway_ai_simulation.py
  1. Access the dashboard
http://localhost:5003

📁 Project Structure

ai-railway-control/
├── 📂 src/                     # Core source code
│   ├── 🧠 agents/              # RL agents (PPO)
│   ├── 🔗 models/              # GNN and data models
│   ├── 🎮 simulation/          # Railway environment
│   ├── 🔧 integration/         # Data integration
│   └── 🌐 web_interface/       # Web components
├── 📂 configs/                 # Configuration files
├── 📂 data/                    # Data files (ignored)
├── 📂 models/                  # Trained models (ignored)
├── 📂 docs/                    # Documentation
├── 📂 tests/                   # Test suite
├── 🚄 live_railway_ai_simulation.py  # Main application
├── 🎯 train_agent.py          # RL training script
├── 🌐 railway_dashboard.py    # Web dashboard
└── 📋 requirements.txt        # Dependencies

🎮 Usage

Running the Main System

# Start the complete AI system
python live_railway_ai_simulation.py

# Access web dashboard
open http://localhost:5003

Training RL Agent

# Train new RL agent
python train_agent.py --episodes 1000

# Train with hyperparameter tuning
python train_agent.py --tune-hyperparams --tune-trials 20

# Resume training from checkpoint
python train_agent.py --load-model models/checkpoint_500.pt

Web Dashboard

# Launch dashboard only
python railway_dashboard.py

# Launch enhanced GUI
python launch_enhanced_gui.py

🎯 API Endpoints

System Status

  • GET /api/hybrid-ai-stats - AI system status and performance
  • GET /api/trains - Current train positions and status
  • GET /api/stations - Railway network stations

Controls

  • POST /api/emergency-stop - Emergency stop all trains
  • POST /api/train/{id}/action - Send action to specific train

🧪 Testing

# Run all tests
python -m pytest tests/

# Run specific test
python -m pytest tests/test_rl_agent.py

# Run with coverage
python -m pytest --cov=src tests/

📊 Performance Metrics

The system achieves:

  • Decision Speed: ~270 decisions/second
  • Success Rate: 100% (6,222+ decisions without rejection)
  • Response Time: <1.2ms average decision time
  • Throughput: 100+ concurrent trains
  • Accuracy: Real-time conflict resolution

🔧 Configuration

Environment Variables

# Optional configuration
export RAILWAY_ENV=production
export LOG_LEVEL=info
export CUDA_VISIBLE_DEVICES=0

Config Files

  • configs/default.yaml - Default system configuration
  • Modify parameters for different scenarios

🤝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

📝 License

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

🙏 Acknowledgments

  • Indian Railway network data
  • PyTorch Geometric for GNN implementation
  • OpenAI Gymnasium for RL environments
  • Flask for web framework

📞 Contact


Built with ❤️ for the future of railway transportation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages