Skip to content
This repository was archived by the owner on Nov 23, 2018. It is now read-only.

Matching algorithm

Tim Oram edited this page Aug 14, 2014 · 3 revisions

Step 1 - Matching

For the parent and the therapist do the intersection between the available times for each.

Step 2 - Partitioning

The time ranges are partitioned into contiguous ranges. For example, if we had the following times for Monday 7:00 a.m. - 7:59 a.m., 8:00 a.m. - 8:59 a.m., 10:00 a.m. - 10:59 a.m., 11:00 a.m. - 11:59 a.m., 12:00 p.m. - 12:59 p.m., and 3:00 p.m. - 3:59 p.m. they would be partitioned into 7:00 a.m. - 8:59 a.m., 10:00 a.m. - 12:59 p.m., and 3:00 p.m. - 3:59 p.m. Partitions do not span days.

Side note: discard minimal partitions*.

Calculating the score

Score = SUM(Sn), where Sn = {0, t < a; t2, a ≤ t ≤ b, a > b; b2 + (t - b), t > b}

Where Sn is the score for partition n, t is the number of time slots in Sn, a is the desired minimum duration, b is the desired maximum duration.

Caching

The matching and partitioning steps might be slow so the final score should be cached. Table would be something like:

| id | parent_id | therapist_id | score | date |

Clone this wiki locally