实现一个算法的桌席分配客人算法、客人、分配

2023-09-11 23:02:04 作者:爱我要趁早

可能重复:   基于优先级的参数座上嘉宾

Possible Duplicate: Seat guests based on prioritized parameters

我一直在苦苦挣扎,而现在这个问题。我只是不能换我的头周围。将不胜感激,如果有人认为是聪明或者有更多的算法和/或数学洞察力可以解释给我,我应该如何进行。

I've been struggling for a while now with this problem. I just can't wrap my head around it. Would be very grateful if someone that's smarter or has more algorithmic and/or mathematical insight could explain to me how I should proceed.

客户端被安排坐在活动,从餐馆到大型的舞台不同。我的客户端软件的目标是提供客人使用短信/电子邮件/文件票证到达事件时说,那里的客人应该坐下。座位(其中客人应该坐在哪里)必须手动控制,一些表是VIP等我工作​​的一种算法,可以让他确定一些参数,比如哪些公司客属和帮助用户该语言的客人可以发言。如今,休息过程在大白板,手工制作(一个部分的时间,如果该事件是1K +客人)。

The client is arranging sits at events, varying from restaurants to large arenas. The goal of my client's software is to provide the guests with an SMS/e-mail/paper ticket that says where the guest should be seated when arriving at the event. The seating (which guest should sit where) must be manually controlled, some tables are "VIP" etc. I'm working on an algorithm that can help the user by letting him determine some parameters, such as which company a guest belongs to and which language the guest can speak. Today, the seating process is made by hand at large whiteboards (one section at a time if the event is 1k+ guests).

我的工作就是这个自动化了一下,不完全是,但足够好。我建立的一个可以直观present的桌,椅(座椅)和嘉宾的应用程序。然而,最重要的功能是人仍下落不明;要能够分发客人到现有的表和座位,根据用户选择的参数。

My job is to automate this a bit, not entirely but "good-enough". I've built an application that can visually present the tables, chairs (seats) and guests. However, the most important functionality is still missing; to be able to distribute the guests to the existing tables and seats, based on the parameters that the user chooses.

该参数是在每个来宾的数据,如一个arbitary数:三九年来,男,Redwine公司,首席技术官,英语及;意大利。用户将这些(所有客人都具有相同的数据字段),并将它们按重要性排序。每个参数也必须设置为靠近或远离。因此,例如,用户可以控制所使用同一种语言客人应下一个坐彼此,但那些在同一家公司工作的应彼此分开就座。

The parameters are an arbitary number of data on each guest, such as: "39 years, Male, Redwine Corp, CTO, English & Italian". The user takes these (all guests have the same data fields) and sorts them in order of importance. Each parameter must also be set to "next to" or "apart from". So for example, the user can control that guests that are speaking the same language should sit next to each other, but those working at the same company should be seated apart from each other.

鉴于此,函数的定义,我要实现将是这样的:函数getGuestSeatings(表,座位,客人,参数)键,返回数组客人应在其席位就座。参数表格座位嘉宾包含您所选择的信息,但最重要的可能是的的X椅,Y 的。这种结合在什么台连接到椅子上,应该足以计算够用就好的客人坐的配置信息。当然,参数变量包含参数的优先级信息,如果它是一个座下,以 - 或座位分开,从-parameter

Given this, the function definition I'm about to implement would be something like this: function getGuestSeatings(tables, seats, guests, parameters) and return an array of which guests should be seated at which seats. The parameters tables, seats and guests contains your choice of information, but most important is probably the X, Y of chairs. That combined with information on what table the chair connected to, should be enough to calculate a "good-enough" guest sit configuration. Of course, the parameters variable contains information on the parameter's priority and if it's a "seat-next-to"- or a "seat-apart-from"-parameter.

我要问的问题是:什么算法可以用来提供一个解决方案,以及如何实现它?数学答案可能没有好处,所以为了安全起见,我建议code(JS / C / C#)或伪code。

The question I'm asking is: What algorithm can be used to provide a solution, and how do I implement it? A mathematical answer might do no good, so to be on the safe side I suggest code (JS/C/C#) or psuedo code.

我给你一些,可能会或可能不会填补空缺到解决方案的更多信息(我会与您的意见反馈补充在这里):

I'll give you some more info that may or may not fill any gaps to a solution (I'll complement with your comment feedback here):

在该表可以是椭圆形或长方形 如果没有符合条件(优先级参数),那么我还是希望有一个足够好的解决方案,座位配置,即使它不会是最好的 据我了解,调查所有的可能性可能会霸占内存 也许有些类型的延迟加载基于点的树系统可以足够了?只是调查正在寻找有前途的,而忽略其它路径的路径...?

下面是一个样机,让你的软件背后的想法:

Here is a mockup that gives you an idea behind the software:

推荐答案

模拟退火。

我们的想法是你有一个人的初始分配的座位,你有一个善的功能。 你想最大限度的善良功能。 说句不好听的,你做的方式是随机切换的人的座位,如果导致功能的一个较高的值,你再做一次从那里开始。 如果交换机导致善良功能的较低值,你可能仍然接受它随机,而且可以帮助你避免局部极值。 这就是所谓的大都市 - 黑斯廷斯。

The idea is you have an initial assignment of people to seats, and you have a "goodness" function. You want to maximize the goodness function. To put it crudely, the way you do it is to randomly switch people's seats, and if that results in a higher value of the function, you do it again starting from there. If the switch results in a lower value of the goodness function, you might still accept it randomly, and that can help you avoid local maxima. This is called Metropolis-Hastings.

您让这个运行数千次,看看你会得到什么。

You let this run thousands of times, and see what you get.