The business problem
A service centre needs enough people at busy times without paying for too much unused capacity. It also needs supervisors, suitable days off and enough rest between shifts. Changing one shift can create a gap elsewhere.
Working example 02 Genetic algorithm
“Every change to the schedule creates a problem somewhere else.”
A service centre open 06:00–22:00, seven days a week, must match staff to an uneven demand curve while respecting contracts, rest rules, availability and supervisor cover.
The business context
A service centre needs enough people at busy times without paying for too much unused capacity. It also needs supervisors, suitable days off and enough rest between shifts. Changing one shift can create a gap elsewhere.
The solution tries many weekly rotas, keeps the better ones and combines or adjusts them to search for improvements. It scores shortages, excess cover and broken rules so you can see the trade-offs. A lower score is better, but the search does not guarantee the best possible rota or that every rule will be satisfied.
Explore the evidence
Two synthetic tables describe hourly demand and the team. Shifts last eight hours and start at 06:00, 08:00, 10:00, 12:00 or 14:00. Each person should work five days, with 11 hours of rest between consecutive days’ shifts. The demo checks rest within the week, not across the Sunday-to-Monday boundary. One supervisor should cover every open hour. Changing team size updates the staff table; the controls below set search and scoring preferences.
All records are illustrative and generated in your browser. Browse every row using the table controls. Displayed decimals are rounded; calculations use full precision.
How it works
genes = staff × 7 days, values ∈ {off, 06, 08, 10, 12, 14}penalty = 10·under + w·over + 60·rest + 60·contract + 30·supervisor + 60·availabilitypopulation 120 · up to 600 generations · elitism 2Try it
Run the algorithm and watch the roster improve.
Penalty of the best roster in each generation.
Rostered staff minus required staff, by day and hour.
Shift start and end times for each person.
| Staff | Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|
Interpretation
The hand-built roster is reasonable on paper — fixed shifts, fair patterns — yet misses demand peaks and breaks rest rules. The algorithm finds arrangements of the same people that no planner would think to try, and makes the trade-off between service and idle time explicit through the penalty weights.