A fair and balanced duty scheduling system for schools using the Hungarian Algorithm (Munkres).
Students take turns performing small duties ("Ämter") on a 2-week rotation schedule. This program automatically assigns duties to students while:
- Ensuring fair distribution (everyone gets equal free time)
- Matching student profiles with duty requirements
- Avoiding unnecessary repetitions
The program calculates individual costs for each student-duty combination based on profile compatibility and past assignments, then finds the optimal assignment with minimum total cost.
- Node.js - Download from nodejs.org
No installation required. Simply ensure Node.js is installed on your system.
Create profile files from the Excel spreadsheet provided:
Student profile file with student name and attributes:
Name Gender Grade Color
MaximilianB J P2 G
Maja M P1 O
...
Columns:
- Name (unique, no separators allowed)
- Gender:
J(boy) orM(girl) - Grade:
P1,P2(primary),S1,S2(secondary) - Color:
G(green),O(orange)
Valid separators: Tab, Space, Comma, Semicolon
Duty requirements with profile specifications:
Duty Name Requirement 1 Requirement 2 ...
Materialräume 1/P1/P2 1/S1/S2
Terrasse_Eingang 1/K
Geschirrspüler#1 2/S1/S2
Geschirrspüler#2 2/P1/P2
Format: [Count]/[Profile1]/[Profile2]/...
Special Profiles:
K- Any student (equivalent to all profiles)#1,#2- Alternate weeks (e.g., for separating groups)
Examples:
1/P1/P2- 1 student from P1 or P22/S1/S2- 2 students from S1 or S2
Run the program in the duty folder:
node .\aemter.js [YEAR] [WEEKS]node .\aemter.js 2023_2024 20Output:
** aemter.js
67 students read from kinder_2023_2024.txt
78 duties read from aemter_2023_2024.txt
20-week plan written to plan_2023_2024.txt
plan_[YEAR].txt - Weekly schedule:
--- Week 1 (#1) ---
Free_Primary: Karl Aurelia ClaraB AnikaF
Free_Secondary: LeonardK MaximilianL Markus Milo
Toilet: MarlenM GabrielKS
...
--- Week 2 (#2) ---
Free_Primary: Nino Simon MaximilianB Emma
Free_Secondary: Paulina Noel Chiara Leona
Toilet: ClaraB Finn
...
- Excess students: If there are more students than duty slots, extras are assigned to a "Reserve" duty.
- Planning failures: If you see "Plan cannot be fulfilled!", there are likely too few suitable students for the duties or contradictory assignments. Check for hidden spaces in student names.
Uses the Hungarian Algorithm (Munkres method) to solve the assignment problem optimally, ensuring fair and balanced duty distribution.
Created by Bardo Mueller ([email protected])