Recently I have this problem at work that I've been looking and reading some solutions for. I would like to get some others ideas and thoughts on this to have them going through my mind to hopefully come up with a good solution that could be implemented into the system.
The Problem:
We have X amount of people that need to be put into Y amount of rooms. Each room can hold a certain amount of people, and can be different per room. I need to automatically assign these people to rooms.
General Rules:
- Certain groups of people can only room with their group.
- There can not be more than a ± 2 year age difference in room mates.
- You can only room with the people of the same gender.
- People can request a roommate (can assume this room mate already fits the rules as above), system should attempt to fulfill roommate requests, but it doesn't have too if can't.
So far I currently have a prototype solution working though I feel it does not really come up with an optimal solution, as I am getting a lot of rooms that only get one person rooming in them.
Currently I am just dividing everyone that can be roomed with each other into groups. Then for each person inside of each group I just assign them the next available room. This just feels too "greedy" I guess and I don't think I can rely on this to come up with an optimal solution (not in terms of time complexity, but in terms of a not having a lot of people rooming with each other).
So I was wondering what are some ideas others may have had. I am looking for some ideas to talk it out really. I am not looking for code solutions. Small pseudo code solutions at the most.
Thanks for any ideas anyone may have.