Feature: Smart grouping algorithm #5

Open
opened 2026-01-21 10:53:13 -08:00 by naomi · 0 comments
Owner

Summary

Implement an intelligent grouping algorithm that prioritizes pairing people who haven't met recently (or at all).

Algorithm Design

Scoring Function

For each potential grouping, calculate a "freshness score":

function calculateGroupingScore(groups: string[][], pairingHistory: Map<string, Date>): number {
  let score = 0;
  
  for (const group of groups) {
    // For each pair in the group
    for (let i = 0; i < group.length; i++) {
      for (let j = i + 1; j < group.length; j++) {
        const lastMet = pairingHistory.get(pairKey(group[i], group[j]));
        
        if (!lastMet) {
          score += 100; // Never met = highest score
        } else {
          const daysSince = daysBetween(lastMet, now);
          score += Math.min(daysSince, 30); // Cap at 30 days
        }
      }
    }
  }
  
  return score;
}

Optimization Approach

Finding the optimal grouping is computationally expensive (combinatorial explosion). Options:

  1. Random sampling - Generate N random groupings, pick the best
  2. Greedy construction - Build groups one at a time, always picking freshest pairs
  3. Simulated annealing - Start random, iteratively swap members to improve score

Recommend starting with random sampling (simple, fast) with N=1000 iterations.

Command Enhancement

Add [smart] boolean parameter to /breakout:

  • false (default): Random grouping (faster)
  • true: Smart grouping using history (requires DB)

Acceptance Criteria

  • Scoring function implemented
  • Algorithm generates groupings prioritizing fresh pairings
  • Performance acceptable (< 2 seconds for typical group sizes)
  • Falls back to random if no history exists

Dependencies

  • Requires #4 (Pairing history tracking)

This issue was created with help from Hikari~ 🌸

## Summary Implement an intelligent grouping algorithm that prioritizes pairing people who haven't met recently (or at all). ## Algorithm Design ### Scoring Function For each potential grouping, calculate a "freshness score": ```typescript function calculateGroupingScore(groups: string[][], pairingHistory: Map<string, Date>): number { let score = 0; for (const group of groups) { // For each pair in the group for (let i = 0; i < group.length; i++) { for (let j = i + 1; j < group.length; j++) { const lastMet = pairingHistory.get(pairKey(group[i], group[j])); if (!lastMet) { score += 100; // Never met = highest score } else { const daysSince = daysBetween(lastMet, now); score += Math.min(daysSince, 30); // Cap at 30 days } } } } return score; } ``` ### Optimization Approach Finding the optimal grouping is computationally expensive (combinatorial explosion). Options: 1. **Random sampling** - Generate N random groupings, pick the best 2. **Greedy construction** - Build groups one at a time, always picking freshest pairs 3. **Simulated annealing** - Start random, iteratively swap members to improve score Recommend starting with **random sampling** (simple, fast) with N=1000 iterations. ### Command Enhancement Add `[smart]` boolean parameter to `/breakout`: - `false` (default): Random grouping (faster) - `true`: Smart grouping using history (requires DB) ## Acceptance Criteria - [ ] Scoring function implemented - [ ] Algorithm generates groupings prioritizing fresh pairings - [ ] Performance acceptable (< 2 seconds for typical group sizes) - [ ] Falls back to random if no history exists ## Dependencies - Requires #4 (Pairing history tracking) --- ✨ This issue was created with help from Hikari~ 🌸
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nhcarrigan/rondelle#5