Sales Territory Optimizer
Assign accounts to sales representatives optimizing for workload balance, travel efficiency, and revenue coverage. Upload your data, run optimization algorithms, or manually draw territories and compare outcomes.
OVERVIEW & APPROACH
Sales territory optimization is a classic operations research problem: partition a set of accounts among sales reps to maximize coverage while respecting constraints like workload capacity and travel limits.
Key Optimization Objectives
Distribute accounts so each rep has similar total potential (weighted by deal size, probability, etc.)
Minimize total distance reps must travel from their home base to assigned accounts
Match high-performing reps with high-potential accounts to maximize expected revenue
Create geographically contiguous territories that are easy to cover efficiently
Algorithms Available
- Balanced K-Means: Iteratively clusters accounts around rep locations, respecting capacity constraints. Fast and produces compact territories.
- Greedy Nearest Neighbor: Assigns each account to the nearest available rep. Simple baseline for comparison.
- Weighted Voronoi: Partitions space based on rep "influence" (location + capacity). Visual and intuitive.
🔬 Advanced: Algorithm Mathematics
1. Balanced K-Means Clustering
Business meaning: Groups accounts into natural clusters around each rep's home base, like drawing circles of influence. Best for: creating balanced, compact territories when reps are spread across the region.
What it optimizes:
Minimize the total "cost" of all assignments, where cost = distance × account value:
min Σᵢ Σⱼ∈Cᵢ ‖xⱼ - μᵢ‖² · wⱼ
Translation: Assign valuable accounts to nearby reps. Don't make reps drive far for big deals.
Example: Account worth $100K is 5 miles from Rep A and 8 miles from Rep B.
Cost if assigned to A: 5² × $100K = $2.5M cost units
Cost if assigned to B: 8² × $100K = $6.4M cost units
→ Algorithm prefers assigning to Rep A (lower cost)
The constraint that makes it "balanced":
|Cᵢ| ≤ max_accounts_i for each rep i
Each rep has a capacity limit. Once full, accounts go to the next-nearest available rep.
Example: Rep A (capacity 20) is nearest to 25 accounts.
First 20 accounts → assigned to Rep A
Remaining 5 accounts → assigned to next-nearest rep with capacity
How it works (step by step):
- Start: Place cluster centers at each rep's home location
- Assign: Each account goes to the nearest rep with available capacity
- Recenter: Move each cluster center to the average location of its assigned accounts
- Repeat: Go back to step 2. Stop when assignments don't change (typically 5-15 iterations)
Why recentering helps: After initial assignment, Rep A's accounts might cluster in the northeast corner of their territory. Moving the "center" there means the next round might reassign some southwest accounts to a closer rep, improving overall efficiency.
Speed: O(n × k × iterations) — handles 100 accounts × 5 reps in milliseconds
2. Greedy Nearest Neighbor
Business meaning: Processes accounts one at a time, always picking the closest available rep. Simple and intuitive—like how you might manually assign accounts. Best for: quick baseline comparisons or when simplicity matters more than optimality.
The simple rule:
assign(account) = nearest rep who still has capacity
Example: Account "Acme Corp" at (40.75, -73.99)
Rep A is 3 miles away (capacity: 5 remaining) ✓
Rep B is 7 miles away (capacity: 12 remaining)
Rep C is 2 miles away (capacity: 0 remaining) ✗ full
→ Assign to Rep A (nearest with capacity)
Processing order matters:
Accounts are sorted by expected value (potential × probability) and processed highest-first:
priority = annual_potential × close_probability
Why this order? Your $200K account with 60% close rate (priority = $120K) gets first pick of reps. Your $30K account with 20% rate (priority = $6K) takes whatever capacity remains.
Step by step:
- Sort all accounts by priority (highest value first)
- For the top account: find the nearest rep with available capacity
- Assign that account, reduce that rep's remaining capacity by 1
- Repeat for next account until all assigned
Trade-offs:
Pro: Fast, intuitive, easy to explain to stakeholders.
Con: "Greedy" means it doesn't look ahead. Assigning Account #1 to Rep A might force Account #50 to go to a rep 30 miles away, when a smarter initial choice would have been better overall.
Speed: O(n × k) — extremely fast, good for real-time previews
3. Weighted Voronoi Tessellation
Business meaning: Draws invisible "force fields" around each rep—bigger capacity = bigger sphere of influence. Accounts fall into whichever field they're inside. Best for: creating visually clean, contiguous territories that respect capacity differences.
The core concept: Power Distance
Instead of plain distance, we use "power distance" that accounts for rep capacity:
power_distance(account, rep) = distance² - weight
Higher-capacity reps get a larger weight, effectively "pulling" more accounts toward them.
Example: Account is 10 miles from Rep A (weight=50) and 8 miles from Rep B (weight=10).
Power distance to A: 10² - 50 = 100 - 50 = 50
Power distance to B: 8² - 10 = 64 - 10 = 54
→ Assign to Rep A (lower power distance), even though B is physically closer!
This happens because A has more capacity and can "pull" accounts from further away.
How weights are calculated:
weightᵢ = (rep_capacity / total_capacity) × scaling_factor
Example: 3 reps with capacities 30, 20, 10 (total = 60)
Rep A weight: (30/60) × 100 = 50
Rep B weight: (20/60) × 100 = 33
Rep C weight: (10/60) × 100 = 17
→ Rep A's territory extends further from their home base
The result: Territory "cells"
Each rep ends up with a Voronoi cell—a region where they're the "most influential" rep:
Territoryᵢ = { all locations where rep i has lowest power distance }
Visual intuition: Standard Voronoi creates equal-sized cells (like a honeycomb). Weighted Voronoi lets high-capacity reps have larger cells. The boundaries curve rather than being straight lines.
Overflow handling:
If a cell contains more accounts than the rep's capacity, excess accounts are reassigned to the next-nearest rep with space.
Properties that matter for managers:
- Creates visually clean, contiguous territories (no "Swiss cheese")
- Respects that some reps can handle more accounts than others
- Territory boundaries follow natural geographic breaks
How Scoring Works
Each territory is scored on four dimensions:
- Balance (CV): Coefficient of variation of workload across reps. Lower = more balanced.
- Travel: Average miles from rep home to assigned accounts. Lower = more efficient.
- Revenue Alignment: Correlation between rep effectiveness and territory potential. Higher = better matching.
- Compactness: Ratio of territory area to convex hull. Higher = tighter clustering.
🔬 Advanced: Scoring Mathematics
Balance Score (Workload Equity)
Business meaning: Are all reps carrying a fair share of the work? Unbalanced territories lead to burnout (overloaded reps) and underperformance (underutilized reps).
Step 1: Calculate each rep's workload
Workload isn't just account count—it's the weighted value of assigned accounts:
Wᵢ = Σⱼ∈Cᵢ (potentialⱼ × probabilityⱼ)
Example: Rep Sarah has 3 accounts worth $100K×50%, $80K×60%, $120K×40% → W = $50K + $48K + $48K = $146K
Step 2: Measure variation using CV
The Coefficient of Variation (CV) measures spread relative to the mean:
CV = σ(W) / μ(W) = standard deviation ÷ average
Example: 4 reps with workloads $146K, $152K, $148K, $154K → mean=$150K, σ=$3.4K → CV = 0.023 (very balanced!)
Bad example: Workloads $80K, $180K, $120K, $220K → mean=$150K, σ=$60K → CV = 0.40 (poorly balanced)
Step 3: Convert to 0-100% score
Balance = max(0, 100 × (1 - CV))
CV of 0.023 → 97.7% balance score ✓ | CV of 0.40 → 60% balance score ✗
Travel Efficiency Score
Business meaning: How much "windshield time" will reps spend? Every hour driving is an hour not selling. Also affects vehicle costs, rep satisfaction, and ability to respond quickly to customers.
Step 1: Calculate distance to each account
We use the Haversine formula (accounts for Earth's curvature):
d = 2R × arcsin(√[sin²(Δlat/2) + cos(lat₁)cos(lat₂)sin²(Δlng/2)])
Where R = 3,959 miles (Earth's radius). This gives "as the crow flies" distance.
In practice: Real-world implementations often use actual driving distances or travel times from mapping APIs (Google Maps, HERE, etc.). Driving time accounts for highways vs. local roads, traffic patterns, and geographic barriers like rivers or mountains. A 10-mile straight-line distance might be 15 minutes on a highway or 45 minutes through city traffic—which matters a lot for territory efficiency!
Step 2: Sum distances per rep
Dᵢ = Σⱼ∈Cᵢ distance(rep_homeᵢ, accountⱼ)
Example: Rep Mike has 4 accounts at 5mi, 8mi, 12mi, 15mi from home → D = 40 miles total
Step 3: Compare to maximum allowed
Travel Score = 100 × max(0, 1 - (avg_distance / max_travel))
If max_travel = 30mi and avg account distance = 10mi → Score = 100 × (1 - 10/30) = 67%
If avg distance = 5mi → Score = 100 × (1 - 5/30) = 83% (better!)
Revenue Alignment Score
Business meaning: Are your best closers working your biggest opportunities? A 120% effectiveness rep should be assigned high-value accounts, not low-hanging fruit that anyone could close.
Step 1: Calculate territory value per rep
Vᵢ = Σⱼ∈Cᵢ (potentialⱼ × probabilityⱼ)
This is the same as workload—the expected value of the territory.
Step 2: Correlate effectiveness with territory value
We want high-effectiveness reps paired with high-value territories. Pearson correlation measures this:
r = Σ(eᵢ - ē)(Vᵢ - V̄) / √[Σ(eᵢ - ē)² × Σ(Vᵢ - V̄)²]
r ranges from -1 (worst performers get best accounts) to +1 (best performers get best accounts)
Example: 3 reps with effectiveness [120%, 100%, 80%] and territory values [$200K, $150K, $100K]
→ Positive correlation! r ≈ +1.0 (perfect alignment)
Bad example: Effectiveness [120%, 100%, 80%] with values [$100K, $150K, $200K]
→ Negative correlation! r ≈ -1.0 (your worst rep got your best accounts)
Step 3: Convert to 0-100% score
Revenue = 50 × (1 + r)
r = +1 → 100% | r = 0 → 50% (random assignment) | r = -1 → 0%
Compactness Score
Business meaning: Can a rep efficiently route through their territory? Compact territories allow for multi-stop days. Scattered "Swiss cheese" territories mean backtracking and wasted time.
Step 1: Find the territory's geographic center
Calculate the centroid (average lat/lng) of all accounts in the territory.
Step 2: Measure how spread out accounts are
dispersionᵢ = avg_distance_to_centroid / hull_radius
hull_radius = distance from centroid to the farthest account
Compact example: 5 accounts all within 2-3 miles of center → low dispersion ✓
Scattered example: 5 accounts at 1mi, 2mi, 8mi, 15mi, 20mi from center → high dispersion ✗
Step 3: Convert to 0-100% score
Compactness = 100 × (1 - avg_dispersion)
Alternative metric (for reference)
The Isoperimetric Quotient measures shape efficiency:
Q = 4πA / P²
A circle has Q=1 (most compact). A long, thin sliver has Q→0.
Overall Score
Business meaning: A single number to compare territory designs. But beware—the weights matter! A 75% overall could be 90% balance + 60% travel, or vice versa.
Weighted average of all four metrics:
Overall = w₁×Balance + w₂×Travel + w₃×Revenue + w₄×Compactness
Default: equal weights (0.25 each). Adjust via the Scoring Weights sliders based on your priorities.
Example trade-off:
Design A: Balance=95%, Travel=60%, Revenue=70%, Compactness=75% → Overall = 75%
Design B: Balance=70%, Travel=90%, Revenue=80%, Compactness=80% → Overall = 80%
Is B better? Depends on whether you prioritize fairness (choose A) or efficiency (choose B).
DATA INPUT MODE
Explore pre-built marketing scenarios with realistic account and rep data.
MARKETING SCENARIOS
TERRITORY MAP
Load data to see territories