tlt
tlt

Reputation: 15221

How to optimize events scheduling with unknown future events?

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:

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.

Upvotes: 1

Views: 112

Answers (0)

Related Questions