Room Booking Algorithm

Status
Not open for further replies.
I am still searching stackoverflow about this, but I wonder if anyone has experience on designing a room booking algorithm.

Supposed:

Room 1 has booking from Mon to Wed
Room 2 has booking from Thu to Fri

If a new booking for Mon to Fri comes in, then the system will move the Thu to Fri booking to room #1, and slot in new booking into Room #2. The number of rooms I have to handle is low, and there is no restriction of any.
 

topham

Ars Legatus Legionis
13,756
Subscriptor
elty":66u4w4jb said:
I am still searching stackoverflow about this, but I wonder if anyone has experience on designing a room booking algorithm.

Supposed:

Room 1 has booking from Mon to Wed
Room 2 has booking from Thu to Fri

If a new booking for Mon to Fri comes in, then the system will move the Thu to Fri booking to room #1, and slot in new booking into Room #2. The number of rooms I have to handle is low, and there is no restriction of any.

Why does this sound like homework?
Oh, because the rules make no fucking sense.
 

technophile

Ars Legatus Legionis
23,768
TheEternalVortex":79i396s6 said:
This would be much easier if you booked the rooms optimally in the first place, i.e. they never got fragmented. Then you need only to pick the optimal room when booking, for which a greedy approach should work well (pick the smallest time frame that fits your meeting).
i.e., a packing algorithm. :p
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
Your problem is NP hard (and with full generality will be on any insert) the brute force to the optimal approach is actually pretty trivial to implement but will scale horribly, but that might be just fine for your needs if the problem space stays small.

If you cannot make a decent stab at the "test every possibility and pick the one with fewest rooms used" ignoring the problem of immovable bookings (assumption, once the room is in use you can't move it) then you need to consider if this is the right career/degree. Show some code you've tried and people are much more likely to help.

Others have already pointed out the critical phrase to google/ read up on, this is a type of packing problem.
 
Status
Not open for further replies.