Timetable constraints

Hard constraints in school timetabling: the rules that decide feasibility

What belongs in the hard set, why the correct answer to an impossible set is infeasibility, and how to keep preferences out of it.

Juho Isola, Smootables founder

A hard constraint is a feasibility rule: if the timetable breaks it, the timetable is unusable. No teacher in two places, no class in two lessons, no room double-booked, every required lesson scheduled, teacher unavailability honoured, everything inside the teaching day.

The defining behaviour is what happens when the set cannot be satisfied. A correct generator reports no feasible solution; it does not quietly place a lesson that breaks a rule. Infeasibility is information.

This guide covers what belongs in the hard set and the discipline of keeping preferences out of it. The other half of the model is in soft constraints.

Key takeaways

  • Hard constraints define feasibility; a single violation makes the timetable unusable.
  • The standard set: teacher, class, and room clashes, required lessons, unavailability, the teaching day.
  • An impossible hard set should surface as infeasibility, never as a hidden violation.
  • Rank rules hard, firm, or soft before telling a solver everything is mandatory.

The standard hard set

Six rules recur in almost every school timetable: no teacher clash, no class clash, no room clash, every required lesson scheduled, teacher unavailability honoured, and all activities inside the teaching day. Each one is binary. There is no such thing as a slightly double-booked teacher.

Everything else starts life as a preference. That is the working default: a rule enters the hard set only when someone can say what breaks if it is violated.

Infeasibility is the correct answer

When the hard set cannot be satisfied, the useful generator says so. An infeasibility report tells you which commitments collide; a silently bent rule tells you nothing until a teacher finds the clash in week one.

This is why hard constraints are a contract, not a wish. If you would accept the rule being broken under pressure, it was never hard. Move it to the soft set with a penalty and let it be traded openly.

Classify before you generate

The sourced practice is to rank rules hard, firm, or soft rather than declaring everything mandatory.

  1. List every rule anyone has asked the timetable to respect.
  2. Mark as hard only the rules whose violation makes the grid unusable.
  3. Mark as firm the rules the school would bend in a named emergency, and record who decides.
  4. Everything else is soft: give it a penalty weight instead of a veto.
  5. Check the hard set for joint impossibility before the first run.
  6. Revisit the classification when the school's commitments change, not mid-crisis.

How to do this in Smootables: rules the solver will not break

A hard rule made visible: the clash is named before the move lands.

The Smootables solver treats clashes and availability as hard: its first phase searches for a grid that satisfies the hard rules, and only then does a second phase improve quality. If the hard set cannot be satisfied, generation fails with a report naming the conflict causes and suggested actions, rather than returning a broken grid.

Hard availability is entered under Availability in Resources: full-day date blocks and repeating weekly in-day rules, for teachers and rooms. Manual edits get the same guardrail at a different strength: dropping a lesson where it clashes opens a conflicts dialog naming what would collide, and proceeding records the conflict instead of hiding it.

Over-hardening: the usual failure

The common modelling mistake is promoting preferences into the hard set: instructor time requests, no-theory-last-period wishes, favourite rooms. Each promotion shrinks the feasible space, and enough of them make it empty. The failure then arrives as unexplained infeasibility, pointing at nothing in particular.

When a run reports infeasible, audit the hard set first: which of these rules is actually a preference wearing a veto? The checks that catch this before generation are covered in constraint validation; what to check in the data itself is in checking timetable data.

Questions planners ask about hard constraints

What happens if we mark every rule as mandatory?

If the set is jointly impossible, the sourced warning applies: the solver's trade-offs become unpredictable, because you gave it no ranking to trade with. Rank constraints hard, firm, or soft instead, and the trade-offs become yours.

Is a student clash hard or soft?

By policy, either. Some schools treat any student clash as infeasible; others accept a scored violation in narrow cases. The point is that it is a decision to record, not a default to inherit.

Why would a feasible timetable still be bad?

Because hard constraints only guarantee legality. Quality (gaps, spread, compact days) lives in the soft set. A grid can satisfy every hard rule and still be a bad week for everyone in it.

More guides on this topic

See how Smootables fits your school

Book a walkthrough and we will map Smootables to your planning, workload, and timetabling process.