Σ
λ
[]

University Timetabling Solver

Hybrid CP-SAT + Large Neighbourhood Search optimizer for detecting infeasible university timetables, generating feasible schedules, and improving timetable quality.

OR-ToolsCP-SATFastAPIPythonLNS
SYSTEM METRICS & ABSTRACTION LAYERS
Backend Layer
Python Solver Pipeline
Core Solver
OR-Tools CP-SAT
Constraint Model
Discrete Constraint Model
Deployment
Render Cloud Deployment
CI/CD Pipeline
GitHub Actions
01 / Challenge

The timetabling solver gap

University timetabling solver constraints grow exponentially with rooms, students, and courses. Manual scheduling is prone to clashes, room capacity overflows, and scheduling inefficiencies.

University Timetabling Solver focuses on constraint programming, automated infeasibility detection, and timetable optimization through Large Neighbourhood Search.

02 / Goals

Project Objectives

01

Formulate university scheduling as a Constraint Programming problem

02

Detect and repair infeasible timetables automatically

03

Evaluate included ITC-2019 instances and document solution quality

04

Expose configurable solve and LNS budgets for instances of different sizes

05

Build a live interactive dashboard for results visualization

06

Expose the solver through a FastAPI wrapper for programmatic access

03 / Architecture

System Design

Browser ClientITC-2019 XML upload & dashboard
ITC-2019 ParserXML validation & data extraction
FastAPI WrapperSolver configuration & API boundary
CP-SAT SolverLexicographic optimization engine
LNS OptimizerIterative schedule repair & improvement
Dashboard & AnalyticsSolution visualization & metrics

Browser Client

  • ITC-2019 XML upload
  • Constraint diagnostics visualization
  • Solver configuration controls
  • Schedule and analytics dashboards

ITC-2019 Parser

  • XML instance validation
  • Course and room extraction
  • Student enrollment mapping
  • Constraint preprocessing

FastAPI Wrapper

  • XML parser boundary
  • Solver parameter configuration
  • Timeout-bounded subprocess execution
  • JSON artifact formatting

CP-SAT Solver

  • Multi-objective scoring and candidate evaluation
  • Hard constraints validation
  • Solve time budget handling
  • Feasible incumbent search

LNS Optimizer

  • Destruction neighborhood sizes
  • Incremental repairs search
  • Intermediate quality logging
  • Solve continuation paths
04 / Pipeline

Data Flow Steps

01

ITC-2019 XML Input

Parses standard instances: rooms, courses, students, time slots, and hard constraints

02

Infeasibility Detection

Identifies room-capacity bottlenecks and student clash hotspots before solving

03

CP-SAT Model

Formulates scheduling as CSP with multi-objective scoring and candidate evaluation

04

LNS Improvement

Large Neighbourhood Search iteratively destroys and repairs solution fragments

05

Validation

Validates zero student clashes and generates ranked diagnostic recommendations

06

JSON Output + Dashboard

Structured output consumed by interactive GitHub Pages dashboard

05 / Solver Features

Solver Features

01

Multi-objective scoring system

02

CP-SAT optimization engine

03

Large Neighbourhood Search improvement phase

04

ITC-2019 benchmark compatibility

05

FastAPI execution wrapper

06 / Simulator

Solver Run Simulation

Interactive Solver Simulator

Run the hybrid CP-SAT + LNS optimization sequence live

1. Model Initialization0%
2. Constraint Mapping0%
3. CP-SAT Core Engine0%
4. LNS Local Search Optimization0%
Click "Run Solver Simulation" above to initialize logging.
Live Allocation Grid (Mon-Fri & Periods 1-4)Empty Grid
Mon
-
-
-
-
Tue
-
-
-
-
Wed
-
-
-
-
Thu
-
-
-
-
Fri
-
-
-
-
07 / Benchmarks

Solver Results

The solver successfully generates optimized schedules verifying all ITC-2019 rules.

0
Student Clashes
0
Quality Score
0
Objective Tiers
ITC-0
Compatible
Analytics
Room Utilization

Note: Quality Score 100 is instance-specific (based on included sample files) and does not guarantee optimal performance on all ITC-2019 instances.

08 / Endpoints

API Design

Programmatic access to the CP-SAT and LNS solver wrapper

MethodEndpointResponsibility
GET/Service identification and status check
GET/healthLightweight health status endpoint
POST/solveAccepts an ITC-2019 XML file upload, executes the solver in a timeout-bounded subprocess, and returns the solution JSON
GET/docsInteractive API documentation generated by FastAPI
09 / Rationale

Key Decisions

CP-SAT over heuristic-only solver

OR-Tools CP-SAT can return feasible incumbents under a time limit and prove optimality when the search completes

LNS as improvement layer

Pure CP-SAT on large instances is slow; LNS improves solution quality incrementally without full re-solve

ITC-2019 benchmark format

A recognized instance format makes parser behavior and constraint inputs easier to inspect and reproduce

FastAPI wrapper

A thin HTTP boundary reuses the CLI solver path and makes XML-to-JSON execution available to other clients

10 / Screenshots

Visual Showcase

Landing Screen
fig.01 — Upload page with constraint diagnosticsUI
Feasibility Analysis
fig.02 — Feasibility comparison: Physical vs Hybrid modeFEASIBILITY
Solver Summary
fig.03 — Solution summary and room utilization statisticsANALYTICS
Diagnostics & Occupancy
fig.04 — Pre-solve constraint diagnostics and class enrollmentDIAGNOSTICS
Timetable Schedule
fig.05 — Generated student timetabling solution tableSCHEDULE
11 / Complexity

Engineering Challenges

01

Modeling timetable constraints without exponential variable growth

Problem

Naive representation of slots (Room x Time x Class) creates millions of binary variables, causing solver memory exhaustion.

Solution

Formulated constraints using integer variables for time slots and room indices instead of sparse binary matrices.

Result

Reduced total decision variables, allowing the solver to generate timetables from structured academic inputs.

02

Detecting infeasible schedules before optimization

Problem

Oversubscribed schedules (e.g., more classes than total room hours) caused solver to search indefinitely for non-existent solutions.

Solution

Built a pre-solve diagnostic checker that counts pigeonhole limits and conflicts before launching OR-Tools CP-SAT.

Result

Instantly flags impossible bounds, returning descriptive bottleneck logs to user without initiating solver run.

03

Balancing solution quality against solver runtime

Problem

Getting a mathematically optimal schedule took hours, while users expected interactive feedback within seconds.

Solution

Configured the CP-SAT solver with search limits and configured solver time limits and tiered attempts, accepting feasible candidate schedules within the configured time budget.

Result

Good quality schedules returned within the configured solver time limit.

04

Designing effective destruction and repair neighborhoods for LNS

Problem

Standard Large Neighborhood Search (LNS) randomly deleted variables, failing to escape deep local minima on highly constrained datasets.

Solution

Designed custom heuristics that selectively destroy classes in over-utilized rooms and repair them using time-slack priority.

Result

Achieved improved objective scores compared to generic solver runs within the same time limit.

05

Maintaining schedule validity during iterative optimization

Problem

Multi-phase scheduling could yield invalid intermediate states that violate hard constraint rules like teacher availability.

Solution

Modeled all state updates as transaction-like modifications validated via CP-SAT's internal constraint checker at every iteration.

Result

validated generated outputs against hard constraint rules.

12 / Limits & Takeaways

Boundaries & Learnings

Limitations

  • Solve time grows with instance size and depends on the configured time budget
  • Hybrid mode (online/physical) adds constraint complexity not in base ITC-2019
  • No live database integration — inputs are file-based XML
  • Dashboard is read-only — no drag-and-drop manual adjustment
  • Room preference soft constraints are approximated, not exact

Key Learnings

  • Constraint Programming formulation for NP-hard combinatorial problems
  • OR-Tools CP-SAT API — variable domains, constraints, and objective functions
  • Large Neighbourhood Search design patterns for local improvement
  • ITC-2019 problem format and evaluation criteria
  • FastAPI wrapper design and file-upload handling
  • Translating optimization outputs into actionable scheduling insights