Timetable constraints

Soft constraints: how penalties and weights shape timetable quality

Preferences the solver trades against each other, the penalty model behind them, and how to tune weights without chasing noise.

Juho Isola, Smootables founder

Soft constraints define quality. They are preferences with a price: the solver can violate them, and each violation adds penalty cost the solver works to minimise. The result is a trade, not a promise.

The standard soft set covers spreading a subject across the week, core subjects in the morning, minimising teacher gaps, capping consecutive and daily periods, keeping teacher days compact, and avoiding certain last-period subjects.

This guide covers the penalty model and weight tuning. The feasibility rules that the solver must satisfy first are in hard constraints.

Key takeaways

  • Soft constraints are goals with penalty costs, never guarantees.
  • The solver minimises total penalty, so weights decide which preference loses a conflict.
  • Equal weights on everything is the same as no priorities at all.
  • Some solvers treat soft rules as hard and relax them when stuck; know which yours does.

The penalty model

Every soft violation carries a cost, and the solver minimises the total. That single sentence explains most solver behaviour that looks mysterious: a preference was violated because honouring it cost more elsewhere.

It also explains why soft constraints are goals rather than guarantees. The output to review is not whether violations exist; it is whether the violations that exist are the cheap ones.

The standard soft set

These recur across schools; the weights differ by policy.

  • Spread a subject's lessons across the week
  • Core subjects in morning periods
  • Minimise teacher gaps and idle periods
  • Cap consecutive teaching periods and daily totals
  • Keep teacher days compact
  • Avoid named subjects in the last period

Tuning weights without chasing noise

Tune to policy first, then to evidence.

  1. Write down which preferences the school ranks above which; that ordering is the policy.
  2. Set weights to match the ordering, with real gaps between tiers.
  3. Run, then review violations by cost: are the expensive preferences intact?
  4. Adjust one weight per iteration; parallel changes hide causality.
  5. Stop when remaining violations are ones the school accepts, and record that acceptance.
  6. Re-tune when policy changes, not when one loud complaint arrives.

How to do this in Smootables: six weights from 0 to 200

Weights are policy made explicit: the ratio between them decides who wins a conflict.

Solver Settings holds six weighted preferences: Student Gaps, Teacher Gaps, Student Daily Balance, Teacher Daily Balance, Subject Spread, and Morning Preference. Each runs 0 to 200, a weight of 0 disables the constraint, and the built-in guidance reads 50 as low, 100 as medium, 200 as high priority. By default only Morning Preference is enabled; the other five start at 0, so a balance or gap preference counts only once you weight it.

The weights drive the solver's second phase: hard constraints are satisfied first, then the soft preferences are optimised. Placement-level wishes (specific weekdays, morning or afternoon, all lessons on the same day) are set per placement under Schedule preferences rather than school-wide.

Equal penalties, unreadable results

When every preference carries the same weight, the solver still trades, but the trades stop meaning anything. Review becomes archaeology: nobody can say whether a violated preference lost fairly or was never really ranked.

Sourced practice notes one more pattern: some solvers treat soft constraints as hard and relax them only when stuck. Know which behaviour your tool has before you interpret its output. How gaps and balance land on individual teachers is covered in fair distribution; the recipe-level walkthrough for the gap weight is minimising teacher gaps, and for spread it is spreading lessons across the week.

Questions planners ask about soft constraints

Why did the solver ignore a preference we set?

It did not ignore it; it priced it. Some other combination of preferences cost less to satisfy. If the preference should win those trades, raise its weight. If it must always win, it may belong in the hard set.

Should every preference get a weight?

Only the ones the school actually holds. A preference nobody defends still steers the solver away from grids someone might have preferred. Fewer, deliberate weights make results easier to explain.

Whose preferences win when teachers and students conflict?

Whoever the weights say. Teacher-gap minimisation and student daily balance can pull in opposite directions, and the weight ratio decides the trade. That is a policy choice to make openly, not a solver default to discover later.

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.