Back to Matching

How It Works - Detailed Guide

Understanding the matching algorithm with examples

🧮The Hungarian Algorithm

The Hungarian Algorithm solves the assignment problem: Given N officers and N positions, find the optimal one-to-one assignment that maximizes total satisfaction.

Why Use This?

  • Optimal: Best possible outcome
  • Fair: Considers all preferences
  • Fast: Handles 100+ officers instantly
  • Proven: Used in economics & logistics

Builds a "reward matrix" where each cell = how good a pairing would be, then finds the assignment that maximizes total reward.

🎯Scoring System

Each officer-position pairing gets a reward score:

🥇 1st Choice (Officer/Position)+3
🥈 2nd Choice+2
🥉 3rd Choice+1
Not Listed0
🏢 Org Bonus/Penalty-3 to +3
🔄 Current Position-99

⚠️ The -99 penalty ensures officers rotate to new roles instead of staying in place.

📝Basic Example: 3 Officers, 3 Positions

Input Data

Officer Preferences

OfficerCurrentWants
AliceAB,C,A
BobBC,A,B
CarolCA,B,C

Position Preferences

PositionWants
Pos ACarol,Bob,Alice
Pos BAlice,Carol,Bob
Pos CBob,Alice,Carol

✨ Result

Alice → B+6
Bob → C+6
Carol → A+6
Total:18

Everyone got 1st choice!

Reward Matrix (How Scores Are Calculated)

OfficerPos APos BPos C
Alice-99
current
6
both 1st
4
both 2nd
Bob4
both 2nd
-99
current
6
both 1st
Carol6
both 1st
4
both 2nd
-99
current

Algorithm picks assignments with highest scores while ensuring each officer gets exactly one position.

🔧Org Preferences Example

Use org bonuses to influence assignments for strategic reasons:

Scenario: Succession Planning

Groom David for leadership by assigning to Manager (Finance).

OfficerPositionBonus
DavidMgr (Finance)+3

Impact on Scoring

Without:

+2 (David 2nd)

+1 (Pos 3rd)

+0 (org)

= 3 pts

With Bonus:

+2 (David 2nd)

+1 (Pos 3rd)

+3 (org) ⭐

= 6 pts

Result: Bonus doubles the score, making this assignment much more likely!

⚠️Edge Cases

1.More Officers than Positions

10 officers, 8 positions → 2 officers unassigned

Fix: Add positions or keep some in current roles

2.More Positions than Officers

8 officers, 10 positions → 2 positions vacant

Fix: Recruit or consolidate positions

3.Everyone Wants Same Position

All 5 officers want "Manager (Finance)"

How resolved: Position preferences break the tie

4.No Mutual Preferences

Officer and position don't prefer each other

Result: Score = 0. Use org bonuses to guide

💡Best Practices

DO

  • • Collect honest preferences
  • • Use org bonuses sparingly
  • • Review and iterate
  • • Communicate the process
  • • Keep names consistent

DON'T

  • • Override all preferences
  • • Use extreme bonuses carelessly
  • • Forget positions in file
  • • Have duplicate names
  • • Ignore results blindly

🔄Iterative Approach

  1. 1.Run with basic prefs
  2. 2.Review results
  3. 3.Add org bonuses
  4. 4.Run again & compare
  5. 5.Repeat until satisfied