How to optimize events scheduling with unknown future events?

83 Views Asked by At

Scenario:

I need to give users opportunity to book different times for the service. Caveat is that i dont have bookings in advance but i need to fill them as they come in.

Bookings can be represented as keyvalue pairs:

[startTime, duration]

So, for example, [9,3] would mean event starts at 9 o’clock and has duration of 3 hours.

Rules:

  • users come in one by one, there is never a batch of users requests
  • no bookings can overlap
  • service is available 24/7 so no need to worry about “working time”
  • users choose duration on their own
  • obviously, once user chooses&confirms his booking we cannot shuffle it anymore
  • we dont want gaps to be lesser than some amount of time. this one is based on probability that future users will fill in the gap. for example, if distribution of durations over users bookings is such that probability for future users filling the gap shorter than x hours is less than p then we want a rule that gap cannot be shorter than x. (for purpose of this question, we can assume x being hardcoded, here i just explain reasons)
  • the goal is to have service-busy-duration maximized

My thinking so far...

  1. I keep the list of bookings made so far
  2. I also keep track of gaps (as they are potential slots for new users booking)
  3. When new user comes with his booking [startTime, duration] i first check for ideal case where gapLength = duration. if there is no such gaps, i find all slots (gaps) that satisfy condition gapLength - duration > minimumGapDuration and order them in descending order by that gapLength - duration value
  4. I assign user to the first gap with maximum value of gapLength - duration since that gives me highest probability that gap remaining after this booking will also get filled in future

Questions:

  1. Are there some problems with my approach that i am missing?

  2. Are there some algorithms solving this particular problem?

  3. Is there some usual approach (good starting point) which i could start with and optimize later? (i am actually trying to get enough infos to start but not making some critical mistake; optimizations can/should come later)

PS. From research so far it sounds this might be the case for constraint programming. I would like to avoid it if possible as i have no clue about it (maybe its simple, i just dont know) but if it makes a real difference, i will go for its benefits and implement it.

I went through stackoverflow for similar problems but didnt find one with unknown future events. If there is such and this is direct duplicate, please refer to it.

0

There are 0 best solutions below