P is for Practical | |
PerlMonks |
Re: Assign guests to hotel roomsby QM (Parson) |
on Sep 15, 2005 at 15:47 UTC ( [id://492293]=note: print w/replies, xml ) | Need Help?? |
Also without getting into specific algorithms, it seems you need to do something along the following: 1) Generate combinations of people-room tuples (perhaps using an iterator instead of all at once). 2) Write a scoring function that returns a value showing how good the match is on each tuple. 2a) You may also want a scoring function that looks at overall efficiency, such as wasted space and empty rooms. 3) Iterate through the combinations, keeping track of which solutions have the highest totals. Depending on the size of the problem set, you may need to optimize this by pruning the search space. You need to ask yourself if you want a pretty good solution, or the optimal. Optimal may take a long time to find, while pretty good could be an order of magnitude quicker. -QM
In Section
Seekers of Perl Wisdom
|
|