0.0.4 • Published 5 years ago

mc-matching v0.0.4

Weekly downloads
12
License
MIT
Repository
-
Last release
5 years ago

TODO

  • [] add types
  • [] add benchmarks
  • [] optimize
    • [] performance (in addition to doing more work in a single loop, maybe make webworker friendly)
    • [] memory (maybe generators/iterators for large sets?)

Overview

// Step 0 - Have students and mentors
type Student = { id: any, ...attributes };
type Mentor = { id: any, ...attributes };

students = Student[]
mentors = Mentor[]

// STEP 1 - For each student, rank each mentor
type RankedCandidate = { id: (Student | Mentor).id, score: number }
type Weights = { string: number } // { major: -5, hobbies: -3 }
type Required = [keyof Weight] // ['major'] if required is passed, majors MUST match between student and mentor
{
  students: (Student & { RankedCandidate[] })[],
  mentors: (Mentor & { RankedCandidate[] })[]
} = rank({ students, mentors, weights, required }) // <- returns sorted lowest score to highest (lowest is best)

// STEP 2 - Format for matching (strip score)
type Picks = {
  [Student.id]: Array<Mentor.id>;
  [Mentor.id]: Array<Student.id>;
}
studentsPicks: Picks  = students.map(({id}) => id)
mentorsPicks: Picks = mentors.map(({id}) => id)

// STEP 2.5
// if we want even distribution across mentors (i.e. don't fill mentors up to capacity immediately),
// we can split the remaining steps into multiple passes.
// instead of having mentor with capacity 3, we triplicate that mentor with capacity 1.
// if 3 is the maximum capcity (across all mentors), we do 3 runs with no duplicate mentors in each run.
// we pass the remaining, unmatched students from the 1st run to the 2nd run and from the 2nd run to the 3rd run.

// STEP 3 - Format Mentor capacities
type Capacities = { [Mentor.id]: number }
const capacities: Capacities = { 100: 1, 101: 2, 102: 2, 103: 2 };

// STEP 4 - match
// take best matches - see algo https://github.com/sammynave/mc-matching/blob/main/src/match.ts

// STEP 5 - format to present to user?
0.0.3

5 years ago

0.0.4

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago