KRONOS is an AI-driven decision support platform designed to solve the complex nightly fleet scheduling problem for the Kochi Metro. This repository contains the complete backend simulation engine, which is capable of running a full 30-day operational simulation, reacting to dynamic scenarios, and using a machine learning model to inform its optimization logic.
Core Architecture: Predict-then-Optimize
Predict Phase (AI Model): t analyzes factors like train health, component wear, and weather to output a data-driven risk score. This is handled by retrain_ai_model.py.
Optimize Phase (Solver): The core optimization engine, built with Google OR-Tools, takes these AI-predicted risk scores as dynamic cost inputs. It then solves for the optimal fleet deployment that minimizes total cost while respecting all safety and operational constraints. This is handled by run_simulation.py.
This hybrid approach ensures that our strategic decisions are not based on fixed guesses but on nuanced, learned patterns from data.
AI-Driven Risk Assessment: Uses a trained Random Forest model to predict the daily operational risk cost for each train, making the optimization smarter and more data-driven. Multi-Objective Optimization: Finds the lowest-cost daily plan while proactively balancing month-end targets for mileage equalization and branding SLAs. Dynamic Scenario Engine: Automatically adapts its strategy for real-time conditions like heavy monsoons and passenger surges, ensuring resilient and safe operations. Predictive Health Management: A dynamic Health Score tracks train wear, fatigue, and faults to intelligently automate and prioritize the daily maintenance schedule. Resilient Solver: Built with "soft constraints" to ensure it always produces a feasible (even if sub-optimal) plan, even on days with extreme operational challenges.
Backend & Simulation: Python Data Manipulation: Pandas Mathematical Optimization: Google OR-Tools (CP-SAT Solver) Machine Learning (AI Predictor): Scikit-Learn (RandomForestRegressor) Model Persistence: Joblib
The project uses a multi-step workflow. Please follow these steps in order.
Step 1: Install Dependencies
First, set up a Python virtual environment and install the required packages from the requirements.txt file. Create and activate a virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
Install packages pip install -r requirements.txt
Step 2: (Re)Train the AI Weight Predictor Model
Before running a new simulation, you must train the AI model on the historical data. This script reads historical_data_retrain.csv and produces the weight_predictor_model.joblib file. python train_weight_predictor.py
Step 3: Initialize the Monthly Fleet Status
This script reads the master fleet_data.csv template and creates the starting fleet_status.csv file for Day 1 of the simulation. Run this script once at the beginning of each new monthly simulation. python initialize_month.py
Step 4: Run the Full Monthly Simulation
This is the main script. It will loop through 30 days, using the trained AI model and the OR-Tools optimizer to generate a daily plan and update the fleet's status. python new_log_solver.py
To run the chatbot :
Step 1: Run api_server.py Step 2: Open index.html
The script will print the daily plan and costs to the console. At the end, it will display a full summary of the fleet's status after 30 days of optimized operations.