For the following problem I'm wondering if there is a known algorithm already as I don't want to reinvent the wheel.
In this case it's about hotel rooms, but I think that is rather irrelevant:
name | max guests | min guests
1p | 1 | 1
2p | 2 | 2
3p | 3 | 2
4p | 4 | 3
I'm trying to distribute a certain amount of guests over available rooms, but the distribution has to satisfy the 'min guests' criteria of the rooms. Also, the rooms need to be used as efficiently as possible.
Let's take 7 guests for example. I wouldn't want this combination:
3 x 3p ( 1 x 3 guests, 2 x 2 guests )
.. this would satisfy the minimum criteria, but would be inefficient. Rather I'm looking for combinations such as:
1 x 3p and 1 x 4p
3 x 2p and 1 x 1p
etc...
I would think this is a familiar problem. Is there any known algorithm already to solve this problem?
To clarify:
By efficient I mean, distribute guests in such a way that rooms are filled up as much as possible (guests preferences are of secondary concern here, and are not important for the algorithm I'm looking for).
I do want all permutations that satisfy this efficiency criteria though. So in above example 7 x 1p
would be fine as well.
So in summary:
Is there a known algorithm that is able to distribute items as efficiently as possible over slots with a min
and max
capacity, always satisfying the min
criteria and trying to satisfy the max
criteria as much as possible.