开发者

Best Fit Scheduling Algorithm for Accommodation / Day Pass Problem?

I have a scheduling problem I'm trying to figure out a best fit algorithm to use.

A hotel owns a theme park and is a highlight for visitors staying at the hotel. However, the hotel has more rooms than day passes for visitors wanting to go to the theme park. So during the peak months, there is a possibility that some will not get to go to the theme park.

We want to have every visitor given at least 1 chance to visit the theme park.

If there is contention, we would want to favour giving the day开发者_高级运维 pass to visitors who stay longer at the hotel.

Can anyone point me in the right direction on which algorithm will fit the problem best?

No this is not homework. :)

Thanks in advance.


You can use Priority Queue (PQ). Every day you put customers in your (PQ) computing the priority as p = 1/r where r is the number of remaining days for that guest in your hotel. In this way, every day you give away your n passes to the n customers who have fewer days to stay at your hotel (if a customer has just 1 more day to stay, she/he must have the highest priority in getting the pass, because there just one possibility). If you have several customers with equal p then you choose among them by looking at the total number of days that they stay at your hotel, and you favour those customers staying longer.


You can assign each guest a weight, or priority, according to length of stay (and maybe the number of days the guy's been a guest already without a pass) and then sort the guests by priority. Then it should be easy to give out passes just starting at the top of the sorted list.


You can use a priority queue for this. The priority queue has to be arranged based on the number of chances and number of days the visitors are staying.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜