Reputation: 15221
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:
duration
on their owndurations
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)My thinking so far...
[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
valuegapLength - duration
since that gives me highest probability that gap remaining after this booking will also get filled in futureQuestions:
Are there some problems with my approach that i am missing?
Are there some algorithms solving this particular problem?
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