Hard and soft constraints in school timetabling, explained

4 min read

Every timetable is a long list of rules. Some of those rules can never be broken: a teacher can't be in two rooms at once. Others are things you'd like to happen but can live without: it would be nice if Year 11 didn't have double maths last thing on a Friday.

Timetablers call these hard constraints and soft constraints. Knowing which is which is the single most useful habit in timetabling, whether you build by hand or with software.

Hard constraints: the rules that can never break

A hard constraint is a rule where any breach makes the timetable unusable. If a timetable breaks one, it isn't a worse timetable. It simply isn't a timetable.

Typical hard constraints in a school or college are:

  • No teacher double-booked. Each teacher teaches at most one class at a time.
  • No room double-booked. Each room hosts at most one class at a time.
  • Qualified staff only. Every class is taught by someone who can teach that subject.
  • Classes fit their rooms. A group of 30 doesn't go in a room for 20, and a chemistry practical goes in a lab.
  • Staff availability is respected. Part-time staff, and anyone with fixed commitments, aren't timetabled when they're not in.
  • Lessons fit the school day. A double lesson can't start in the last period.
  • Every enrolled student gets their lessons. Each class is scheduled the number of times its curriculum requires.

Soft constraints: what makes a timetable good

Once every hard rule is met, there are usually still thousands of valid timetables. Soft constraints decide which of those is best. They are goals rather than rules, and each one can be traded off against the others.

Common soft constraints include:

  • Fewer gaps for students. A free period stranded in the middle of the day is wasted time, especially for sixth-formers and college learners.
  • Fewer gaps for teachers. Teachers would rather have their non-contact time grouped usefully than scattered across the week.
  • Compact weeks. Part-time learners and staff often prefer to come in on fewer days.
  • Staggered lunch. Spreading lunch breaks out keeps canteens and corridors moving.
  • Balanced subjects across the week. Five maths lessons shouldn't all land on Monday and Tuesday.

Why the difference matters

It stops impossible timetables before you start

Most timetabling pain comes from treating a soft preference as a hard rule. If every part-time teacher's preferred day off is locked in as a hard constraint, the timetable may have no solution at all, and you won't find out until you're deep into August.

Before you build, go through every request and ask: would breaking this make the timetable unusable, or just less pleasant? Only the first kind should be hard.

It lets you weigh one goal against another

Soft constraints compete. Compressing students into fewer days can create more gaps within those days. Staggering lunch can push lessons later. You can't maximise everything at once, so decide what matters most to your school and weight it accordingly.

It makes problems explainable

When a timetable can't be built, the cause is always the hard constraints. There aren't enough qualified teachers, rooms or periods to meet them all. Keeping that list short and honest means that when something doesn't fit, you can see why and decide what to change: hire, share a room, relax a rule or adjust availability.

How Timez uses them

Timez treats the rules above exactly this way. It will only ever return a timetable that meets every hard constraint. If that's impossible with the staff and rooms you have, it tells you, rather than handing back something that quietly breaks a rule.

Among the timetables that do work, it searches for the one that scores best on the soft goals, including fewer student gaps, fewer teacher gaps, compact weeks and staggered lunch. Then it reports how well it did, so you can see the trade-offs and run it again with different settings if you'd rather balance them another way.

A quick checklist before your next timetable

  1. List every rule and request you've been given for next year.
  2. Mark each one hard or soft. Be strict: if in doubt, it's soft.
  3. Check the hard constraints add up. Do you have enough qualified teacher periods and suitable rooms for every class?
  4. Rank the soft constraints so you know what to give up first.
  5. Build, review the result against your ranking, and adjust.

More from the blog