Elevator Simulator
Brief
A comprehensive C++ application that realistically models elevator systems in multi-story buildings, featuring robust real-time simulation of elevator movements with advanced scheduling algorithms.
The Elevator Control Simulator provides a detailed simulation environment that accurately reflects the complexity of managing elevator systems in high-rise buildings, focusing on efficiency, safety, and performance optimization.
My Contribution
As the sole developer for this project, I designed and implemented the entire system with emphasis on:
- Designed a multi-threaded elevator system in C++, implementing advanced scheduling algorithms (FCFS, SCAN, LOOK) and distributed processing techniques for real-time request handling and optimal passenger flow.
- Developed sophisticated thread synchronization mechanisms using mutexes and semaphores to ensure safe concurrent operations and prevent race conditions.
- Created a comprehensive logging and monitoring system using PostgreSQL to track elevator performance metrics including wait times, throughput, and energy efficiency.
- Set up CI/CD pipelines with GitHub Actions for automated testing, ensuring code quality and reliability through continuous integration.
Problem
Elevator systems in high-rise buildings face complex scheduling challenges when handling multiple concurrent requests across different floors. Traditional sequential programming approaches fail to model the parallel nature of these systems effectively.
Additionally, ensuring thread safety and preventing deadlocks while maintaining optimal performance presents significant technical challenges.
System Architecture
Core Components
- Elevator Controller: Central management system that receives requests and dispatches them to individual elevators
- Elevator Threads: Independent threads for each elevator car, capable of processing requests autonomously
- Scheduler: Implements various algorithms (FCFS, SCAN, LOOK) to optimize elevator movements
- Synchronization Manager: Handles mutex locks and semaphores to prevent race conditions
- Metrics Database: PostgreSQL database for storing performance data and system logs
Key Features
Advanced Scheduling
Implemented multiple scheduling algorithms (First-Come-First-Served, SCAN, LOOK) that can be dynamically selected based on traffic patterns. The system evaluates and chooses the most efficient algorithm for current conditions.
Thread Synchronization
Developed a sophisticated synchronization system using mutex locks and semaphores to prevent data corruption and ensure thread safety while maintaining high throughput.
Performance Monitoring
Created a real-time monitoring dashboard that displays key performance metrics such as average wait time, throughput, and energy efficiency.
Technical Challenges
- Deadlock Prevention: Implemented a resource hierarchy approach to prevent deadlocks when multiple elevators compete for resources.
- Optimization: Balanced the trade-off between wait time, travel time, and energy consumption through extensive algorithm tuning.
- Scalability: Designed the system to dynamically adjust to varying loads, from low-traffic periods to rush-hour scenarios.
Takeaways
This project provided valuable experience in concurrent programming, thread synchronization, and scheduling algorithm design. The techniques learned are applicable to many real-world parallel processing scenarios beyond elevator systems.
Additionally, designing for fault tolerance and graceful degradation taught important lessons about building robust systems that can handle unexpected conditions.