A hybrid scheduling + optimization system that detects infeasible university timetables and automatically generates feasible schedules using Google OR-Tools CP-SAT and Large Neighborhood Search (LNS).
This targets real operational constraints (room capacity, student clashes, hybrid delivery) and produces a decision-support JSON output with diagnostics + recommendations.
- Infeasibility Detection: Identifies room-capacity bottlenecks in physical-only schedules.
- Hybrid Optimization: Automatically generates feasible schedules by balancing in-person, online, and hybrid delivery.
- Stability-Aware Repair: Minimizes timetable "churn" and disruption during re-optimization.
- Lexicographic Solver: Multi-objective CP-SAT formulation (Electives > Mode > Clashes > Evening).
- Interactive Analytics: Full diagnostic dashboard for room utilization and student conflict analysis.
Modern entry point for uploading ITC-2019 instances and initiating the optimization pipeline.
The core engine: detecting 0% physical feasibility and automatically repairing it to 100% hybrid feasibility.
Granular student-level validation ensuring zero clashes and respecting individual delivery preferences.
Real-time tracking of the 5-tier objective stack and precise room occupancy heatmaps.
Automated risk assessment and ranked recommendations for infrastructure planning.
Searchable, filtered view of the final optimized schedule with direct links to student diagnostics.
ITC-2019 XML Input
↓
Parser & Normalization
↓
CP-SAT Optimization Model
↓
Large Neighborhood Search (LNS)
↓
Validation & Diagnostics
↓
Interactive Dashboard + JSON Output
flowchart TD
A[ITC-2019 XML instance] --> B[itc2019_parser.py]
B --> C[CP-SAT model + solve]
C --> D[LNS improvement loop]
D --> E[Validation + Diagnostics]
E --> F[Solution JSON]
F --> G[index.html dashboard]
pip install -r requirements.txtRequires: ortools, numpy (optional for visualization)
# Solve ITC-2019 XML instance
python -m src.run_solver instances/itc2019/wbg-fal10.xml
# With custom output path
python -m src.run_solver instances/itc2019/wbg-fal10.xml my_solution.jsonexport BASE_TIME=10.0 # Max solve time (seconds)
export LNS_ITERS=5 # LNS iterations
export LNS_TIME=1.0 # Time per LNS iteration
export LNS_DESTROY=0.2 # Destroy fraction (20%)
export LNS_SEED=0 # Random seed
export NUM_WORKERS=8 # CP-SAT parallel workers
export ENABLE_ONLINE=1 # 1 = hybrid/online enabled, 0 = strict physical-only (pure ITC)
export RELAX_ON_INFEASIBLE=1 # Retry with relaxation if strict model is infeasible
export RELAX_MAX_OVERLAP=5 # Relaxed max classes per student at same time
export RELAX_ROOM_OVERCAP=200 # Relaxed extra in-person seats allowed per class
python -m src.run_solver instances/itc2019/wbg-fal10.xml# Start local server
python -m http.server 8000
# Open http://localhost:8000/index.htmlThe dashboard auto-loads full_solution.json and displays:
- Solution status and objective values (z1-z5)
- Room utilization statistics
- Class occupancy charts
- Interactive timetable table (main class-wise schedule)
- Student detail modal (class list and weekly schedule grid inside modal)
- Student-focused controls (
Select Student,Students,Download) - Diagnostics panel (input risk, violations, recommendations)
Solver status contract from run_solver.py:
OPTIMALFEASIBLEINFEASIBLE(with explanatory message)UNKNOWN(timeout/partial warning)
windsurf-project-2/
├── src/
│ ├── run_solver.py # Entry point
│ └── timetabling/
│ ├── solver_cp_sat.py # CP-SAT solver + LNS (~800 lines)
│ └── itc2019_parser.py # XML parser (~280 lines)
├── instances/
│ └── itc2019/
│ └── wbg-fal10.xml # Sample dataset
├── docs/uml/
│ ├── class_diagram_v2.puml # UML diagrams (8 total)
│ ├── sequence_diagram_v2.puml
│ └── ...
├── index.html # Web dashboard
├── requirements.txt # Python dependencies
└── full_solution.json # Sample output
- Feasibility repair: Detects infeasibility drivers (e.g., demand > room capacity) and generates a workable hybrid schedule.
- Optimization under constraints: Multi-objective CP-SAT formulation plus an LNS improvement loop.
- Decision support output: Diagnostics + ranked recommendations designed to be acted on.
The full variable / constraint breakdown is in docs/technical_notes.md.
Located in docs/uml/ (v2 versions are corrected and accurate):
- Class Diagram: Shows actual modules and data structures
- Sequence Diagram: Solver execution flow
- Activity Diagram: Workflow from XML to solution
- Use Case Diagram: System capabilities
- Collaboration Diagram: Component interactions
- Component Diagram: File structure and dependencies
- Object Diagram: Runtime data structures
- Deployment Diagram: System architecture
{
"status": "OPTIMAL",
"input_risk": "MEDIUM",
"pre_warnings": [
{
"severity": "HIGH",
"message": "High risk: demand exceeds class capacity by 40%",
"suggestions": [
"Add 2 more class sections for overloaded modules."
]
}
],
"objectives": {
"z1_electives": 245,
"z2_mode": 12,
"relaxation_penalty": 0,
"z4_online": 45,
"z5_late": 8
},
"schedule": {
"c1": {"room": "R1", "time": 0, "mode": "hybrid"},
"c2": {"room": "R2", "time": 1, "mode": "in_person"}
},
"students": {
"s1": {
"taken_modules": ["m1", "m2"],
"attended": {"c1": {"in_person": 1, "online": 0}}
}
},
"violations": {
"student_overlaps": 0,
"room_overflow": 0
},
"constraint_metrics": {
"conflict_hotspots": [],
"preference_violations": {"total": 12}
},
"recommendations": [
{
"issue": "Preference violations",
"severity": "MEDIUM",
"suggestions": [
"Tune mode preferences and objective weights for better preference satisfaction."
]
}
],
"solution_quality": 88,
"baseline_runtime": 8.5,
"lns_runtime": 12.3,
"baseline_objectives": {...},
"lns_objectives": {...}
}recommendations are ranked by severity (CRITICAL, HIGH, MEDIUM) so the output can be used directly for decision support.
- Solver: Google OR-Tools CP-SAT (Constraint Programming SAT solver)
- Heuristic: Large Neighborhood Search (LNS) for local improvement
- Benchmark: ITC-2019 (International Timetabling Competition)
- Format: UniTime XML schema
- Optimization: Lexicographic multi-objective (5 levels)
This repository is intended as an engineering project demonstration. If you reuse parts of it, keep attribution and validate constraints for your environment.





