How-to
Generating a school timetable: the generator, the gap solver and the improvement loop
A timetable is not generated once. It is generated, measured, polished and measured again. This guide walks through that loop the way a timetabler in a secondary school meets it — afternoons, a short Friday, teachers who come for two hours and go home — and says which setting answers which complaint.
Three stages, and you may stop after any of them
You enter the facts of the school once: subjects, who teaches them, which classes attend, which rooms exist. The program then places every lesson on a day and an hour.
- The generator places every lesson. It is fast, and it never breaks a hard rule: nobody is in two places at once, every lesson has a room that carries what it needs, nothing lies outside the working hours.
- The gap solver then polishes the week for as many minutes as you give it. It moves lessons to close holes in the classes' and the teachers' days, keeps afternoons within the limit you set and gives teachers whole free days where it can. It never breaks a rule the generator kept, and it always keeps the best week it has found — stopping it loses nothing.
- Publishing makes the result visible to pupils, teachers and parents, on the web and in the app.
What a hole is, and what it costs
A hole is an empty hour between two lessons of the same class or the same teacher on the same day. Free hours at the start or the end of a day are not holes. The solver prices everything in one unit, the hole-hour: one hour a teacher waits between two lessons. A hole for the pupils is counted a thousand times heavier, so the solver will sacrifice a great deal of teacher comfort before it leaves a class waiting.
Everything else — a teacher's one-hour day, a long day, a lesson outside the teacher's own classroom, an elective in the middle of the class's day — has a price in the same unit, and the settings below are those prices.
A first run in ten minutes
With the data entered, this is the shortest path to a timetable you can look at.
Switch the polishing on
Settings › Miscellaneous (F2), tab Generate: tick Run gap optimisation and set Duration (min) to 10.
Describe the school's rhythm
Press Gap optimisation settings … and fill in the left column: Afternoon starts at hour (the school hour from which a lesson counts as afternoon — 10 in a school with 14 hours a day), Afternoon days per class and week (1 gives every class at most one afternoon), Min teacher hours per day (2: nobody comes in for a single lesson) and Max teacher hours per day (soft) (5 or 6). Confirm both windows.
Set the last hour of each day
On the Generate tab, Last hour of the day has one field per weekday. The number is a school hour counted from the start of the working hours, not a clock time: a Friday that ends after the ninth lesson is 9, the other days 14. It is a hard rule of the gap solver, so keep the polishing switched on when you rely on it.
Generate
Press the Generate button (the alarm-clock icon in the toolbar), answer Yes to the warning — unlocked lessons are placed anew, so lock what you placed by hand — tick the programmes and years in the window that follows and press Start. The generator places the week; the gap solver polishes it for ten minutes.
Read the numbers
Ctrl + B opens the week statistics: lessons without a room, class holes, afternoon days above the cap, lessons past the day's last hour, teacher-days, hole-hours, one-hour days and long days. Write them down — every later change is judged against them.
The improvement loop
The solver improves fast at first and slowly later. The efficient way to work is a ladder of run times: the shortest run that can answer the question you have.
The rule of thumb: never run longer than ten minutes while you are still changing settings, and change one setting at a time — if you change three, you will not know which one helped. Measure, change one thing, run a short polish, measure again; keep the change if the numbers improved, undo it if they did not. Stop when two successive twenty-minute runs improve nothing, or when what remains is something you can live with. A timetable with three teacher holes is a good timetable; the last holes are usually caused by the data — a teacher who can only come on Monday and Thursday — not by the solver.
- One or two minutes — "did this setting break something obvious?" Every time you change a setting.
- Five minutes — "is this direction better than the last?" The standard step of the loop.
- Ten to twenty minutes — "how good can this configuration get?" When the five-minute runs stop changing anything.
- Thirty to sixty minutes — a candidate for publication.
- Several hours or overnight — only for the final version, with every setting settled.
Which setting answers which complaint
The complaints a timetabler hears, and the setting in the Gap optimisation window that answers each.
- "My class has lessons in the afternoon three times a week." — Afternoon days per class and week. A hard rule: the solver moves lessons until it holds.
- "I come to school for one lesson." — Min teacher hours per day, and a higher Value of a teacher's day of presence: the solver then prefers to add an hour to that day or to empty it.
- "My days are too long." — Max teacher hours per day (soft); the hard daily maximum stays on the Generate tab.
- "I want whole free days, not short days every day." — untick Teachers come every working day and raise the day value; the generator then fills the days a teacher already works first.
- "The pupils who do not take the elective sit around in the middle of the day." — Electives at the edge of the day.
- "I never teach in my own classroom." — Teacher's home room – weight; the room has to carry what the lesson needs, too.
- "Some lessons have no room." — data first: room properties and seats, then a slightly wider extended working time. A lesson without a room counts as not placed; the solver cannot invent a room.
When the numbers stop moving
It is rarely stuck; it is working on the hardest cases, and it is normal that the last few holes take longer than all the others. If the statistics have not changed for twenty minutes, stop — the best week is saved — relax one rule, and run again. If nothing helps, the cause is almost always in the data: a teacher available on two days, a room every lab needs, a class with more lessons than the morning holds — preparing a school for timetable generation lists the mistakes we see most often.
Every field in the Gap optimisation window has a ? button with a longer explanation, the valid range and the default measured on real schools. The complete book — preparation, every parameter, the loop, an extensive troubleshooting part and recipes for typical schools — is on the documentation page as a PDF.
Want to see this working?
Book a 45-minute online presentation and we will walk through it against your institution's own scheduling problem.