How the Algorithm Works
How the Algorithm Works
At its core, Shibutz solves a constraint satisfaction and optimization problem. Given a set of students, classrooms, and rules, the algorithm finds the arrangement that best satisfies all of your requirements while keeping every classroom as balanced as possible.
This page explains what the algorithm does and why, without diving into implementation details. The goal is to give educators confidence in how placements are determined.
What the Algorithm Optimizes
The algorithm considers multiple dimensions simultaneously when placing students into classrooms:
1. Friend Placement
When students or parents submit friend preferences, the algorithm tries to place those friends in the same classroom. It maximizes the number of honored requests while respecting all other constraints. Not every request can be fulfilled — especially when two students are also subject to a separation restriction — but the algorithm treats each preference as a goal to pursue.
2. Scale Balancing
Every student has four scale scores: social, emotional, behavioral, and learning. The algorithm distributes students so that the average score for each scale is as similar as possible across all classrooms. This prevents situations where one classroom ends up with a disproportionate concentration of students who need extra support in a particular area.
3. Gender Balance
The algorithm aims for an even boy/girl distribution in every classroom. If your cohort has 52% girls and 48% boys, each classroom should reflect roughly that same ratio rather than having one classroom skew heavily in either direction.
4. School Cohesion
When students come from multiple feeder schools or groups, the algorithm spreads them across classrooms so that no single classroom is dominated by students from one origin. This helps students from smaller schools feel included and encourages new social connections.
Hard Constraints vs. Soft Constraints
Not all rules carry the same weight. The algorithm distinguishes between two types:
- Hard constraints — these must always be respected. Student restrictions (e.g., "Student A and Student B must not be in the same classroom") and required placements are hard constraints. The algorithm will never violate them.
- Soft constraints — these are goals the algorithm tries to achieve as well as possible. Friend preferences, scale balance targets, and gender balance targets are soft constraints. The algorithm optimizes for them but may trade off one against another to find the best overall outcome.
How Required Placements Are Handled
If you have required placements to specific classrooms, those placements are locked in before the optimization begins. The algorithm then fills the remaining seats around those fixed students. Keep in mind that the more students you lock, the less flexibility the algorithm has to optimize balance across the remaining dimensions.
The Iterative Process
The algorithm doesn't simply drop students into classrooms one by one. Instead, it explores many different configurations, evaluating each one against all of your constraints and objectives. Through this iterative process, it converges on the arrangement that provides the best overall balance.
Because the algorithm tries many possibilities, running it multiple times may produce slightly different results. Each run is an opportunity to discover a configuration that better fits your priorities.
What "Best Balance" Means
Balancing classrooms involves trade-offs. Honoring every friend request might conflict with achieving perfect scale balance. Keeping gender ratios identical might limit how well origin schools can be distributed. The algorithm weighs all of these objectives together and finds the configuration where the combined outcome is as good as possible — even if no single dimension is perfectly optimized.
You can influence these trade-offs through your placement settings. Adjusting thresholds and priorities tells the algorithm which dimensions matter most to your school.
Designed for Educators
Shibutz's algorithm was built by engineers who work closely with educators and school administrators. Every optimization rule reflects real-world placement concerns — not abstract math. The goal is to save you hours of manual work while producing classroom lists that are fairer and more balanced than what's typically achievable by hand.
To see how well the algorithm performed on your data, visit the Understanding Results page after generating a placement.