I don’t know how Netflix decides what to send to whom. Here’s how I might do it:
- Process the incoming mail: update each title’s availability data and each customer’s Demand (subscription quota minus discs out).
- (X) For each customer, put a Claim on the first Demand title(s) in the Request Queue which that customer has not already claimed today. (A customer may have multiple Claims on the same title.)
- For each available title, prioritize the Claimants (ignoring those whose Demand is zero): first by the date of their oldest Claim, then second oldest and so on; then by other criteria, perhaps including proximity to an available copy. Send each available disc to the leading Claimant (if any); erase that customer’s Claims on it; reduce that customer’s Demand by one.
- If any customer still has positive Demand, loop to (X).
I have not decided whether or not to cancel Claims when the customer rearranges the Request Queue.
In rare circumstances, this procedure could send your second choice even when your first choice is available and otherwise unclaimed, if the second title happens to be processed first. (2006 Mar 04: Pondering it now, I don’t see how that’s possible.)
It’s interesting to note that this procedure requires delivery times to be quantized. Suppose on the contrary that discs can instantly be checked in or out at any time of day. Then when you turn in a disc your first choice is likely not to be available, and when it comes in you’re not entitled to it (because then your Demand is again zero). So: when N*Delay has passed since a disc came in, send whichever is first available of the customer’s N+Demand top selections. (This calls for a more object-oriented implementation.) The customer sets Delay; short for those who like surprises, long for those to whom sequence is important, e.g. those watching all 39 discs of Buffy the Vampire Slayer in order.
See http://dvd-rent-test.dreamhost.com/ for a discussion of NetFlix’s priority allocation algorithm.
I run Technical Video Rental, which has a similar business model to Netflix. FWIW, I use an algorithm similar to the one you lay out above when
Imy custom back-end code figures out what to mail to whom.