问题描述
我正在开发一个摩托车租赁网站。我的问题是如何有效地解决将客人分配到摩托车的问题。我知道如何以愚蠢的方式进行操作,但是我想知道是否存在解决此类问题的经典算法。这与将客人分配到酒店房间的问题相同。在最后一个示例中,目标是通过不因调度效率低而拒绝预订来达到最大的占用率。
I'm developing a motorcycle hire website. The problem I have is how to solve the problem of assignment a guest to a motorcycle in an efficient way. I know how to do it in a "silly" way, but I want to know if there is a classical algorithm that solves this kind of problem. It's the same problem as the assignment of a guest to rooms in a hotel. In this last example, the goal is to achive maximum occupancy by never rejecting a reservation due to inefficient scheduling.
我很确定这个问题一定很经典具有已知解决方案的问题。
I'm pretty sure that this problem has to be a classic problem that has a known solution.
非常感谢。
推荐答案
您感兴趣的称为。假设所有保留都具有相同的权重(没有任何保留比任何其他保留更受青睐),则您需要一个贪婪的算法。
What you're interested in is called Interval Scheduling. Assuming all reservations have the same weight (none are favored over any other), you'd want a greedy algorithm.
是关于该主题的一些很好的幻灯片。
Here (pdf) are some good slides about the topic.
基本上,您想先安排最早的预订。
Basically, you want to schedule the earliest-ending reservations first.
这篇关于资源调度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!