Key takeaways
- A hard constraint is a feasibility rule. The timetable must satisfy it.
- Start with teacher, class, and room clashes, required lessons, teacher unavailability, and the teaching day.
- Do not use hard constraints for preferences that can be traded off with a penalty.
- If the hard set is impossible, the correct signal is infeasibility, not a hidden violation.
What belongs in the hard set?
Put a rule in the hard set when breaking it would make the timetable unusable. The standard examples are clashes, missing required lessons, teacher unavailability, and activities outside the teaching day.
This distinction matters because the solver treats hard rules differently from preferences. It must satisfy every hard rule. It can only optimise soft constraints after the hard set is feasible.
Common hard constraints
Use the local timetable policy, but check these hard constraints first.
- No teacher is scheduled in two places in the same period
- No class or student group is scheduled for two lessons in the same period
- No room is assigned to two activities at the same time
- Every required lesson is scheduled
- Teachers are not scheduled in unavailable periods
- All activities sit inside the teaching day
How to classify a hard constraint
Classify each rule by its effect on feasibility. Keep the question simple: can the timetable be used if this rule is broken?
- Write the rule in plain language.
- Check whether it prevents a teacher, class, or room clash.
- Check whether it protects a required lesson or an unavailable period.
- Check whether it keeps activities inside the teaching day.
- Move preferences such as spread or compact days into the soft set.
- Run the hard set and treat infeasibility as a signal to review the model.
Why over-hardening causes infeasibility
A hard constraint is not a strong preference. If too many preferences are made mandatory, the timetable may have no feasible solution. The solver has no permission to trade one hard rule against another.
Use hard constraints for rules that must never be broken. Use soft constraints for quality goals such as lesson spread, teacher gaps, compact days, or avoiding certain subjects in the last period.
Hard-set review checklist
Use this checklist before generation.
- Teacher, class, and room clash rules are present
- Required lessons are included in the model
- Teacher unavailable periods are marked as unavailable
- Teaching-day limits are present
- Preferences are not marked hard by habit
- Any infeasible result leads to model review before rule demotion
How hard and soft constraints work together
The first goal is feasibility: every hard rule must be satisfied. The second goal is quality: the solver minimises soft-constraint penalties.
This order helps planners explain a result. A timetable with all hard rules satisfied may still have poor spread or teacher gaps. Those are quality problems to tune through the soft set, not reasons to weaken the hard set.
Questions planners ask about hard constraints
What makes a timetable rule hard?
A hard rule is one the timetable must satisfy to be usable. If the rule can be broken at a penalty cost, it is a soft constraint instead.
Is teacher unavailability always hard?
Unavailable periods are hard because the teacher must not be scheduled then. Preferred free periods are soft because the solver may honour them only if the timetable allows it.
What should happen if the hard set cannot be solved?
The generator should report infeasible. Review the data and the hard set before turning a preference into a mandatory rule.