The following data model represents tables with seats and guests, in an app that makes the user a table and seats , Using Blind HTML5.
// data model var data = {guest: [], // id, name, tag table: [], // id, seat seats: [], // id, guest Tags: [] // id, name}; Guests have tags (types of categories) attached. These tags can be prioritized and can be set to work as a "group" or "imbalance" parameter, the user then clicks on "seat", and the guests sit (seemingly randomly) , While priority standards are respected.
Fully developed example: (search for "solution goes here" in JS panel)
The question is: How do I implement a function While sitting on the table, while keeping in mind that some guests are sitting next to each other and others should be seated, apart from each other to make one of the best maritime configurations? The number of guests can be more than 1000, but not 2000. Real life example, to illustrate the problem
Let's assume that we have 3 tables and they have 4 seats. We also say that to fill 9 tables with us There are 9 guests for They are as follows:
- Guest from America 1, Jewish,
- From guest 2, Jewish, UK
- Guest 3, Christian,
- From guest 4, Christian, Britain
- From guest 5, Christian, Sweden
- Guest 6, atheist, from UK
- Guest <
Now, the user gives priority to such parameters, first of all is the most important.
- I want them to be separated from each other by the same religion
- I want them to sit next to each other with the same geographical position Table 1: Guests: 1, 3, 7, 8
- Table 2: Guests: 2, this is OK:
4, 6, 9
- Table 3: Guests: 5
Update may be a solution minimum integration algorithm. It will calculate one point for each possibility and present the best found solution (found later, 10 seconds of calculation). Algorithm Who I need help with, will definitely need to make decisions for implementation which only I can do. "post-text" itemprop = "text">
There is no best answer to this question, because there is no good arrangement - in fact, I will argue that the system He says that he is fine, very bad - if you are forced to use three tables, and you can sit up to a maximum of 4 on the table, you should probably get three seats in each table so that nobody can Do not sit. It is neat-picking, however, and avoids the basis of the question.
There are some algorithms that I can imagine.
First of all, you can treat each "tag" in an en-dimensional space in a dimension (it seems as complicated as it is). For example in the field dimension, you can assign an integer value to each country, and in the dimensions of your regional space, each of these integers will be in the form of possible values. Then, place each guest as a point in this en-dimensional space, and select those guests who are closest to those places for each table. You can support priorities by ignoring some features during the construction of space - that is, if you do not want to do grouping with religion, do not include religion while creating space, or if you are actively 'identical' If you want to differentiate between people, then you can modify your distance calculation to have inverse relationships in that dimension. This algorithm can have a good performance based on the number of features (i.e. dimension) and the number of digits - essentially how they make the recommendation engine.
If you wanted something simple but slow, you can use a brutal force algorithm: i.e. for each guest, consider it on each table that is a member on it, if it Members are not desirable for your preferences, sitting on a fresh table if there is no fresh table, then select the table with at least undesirable members. It's probably as easy as you can go!
Finally, you can pre-process your guests, and count: how many areas are from x, how many religions are from y ... So, you have these statistics once, You can make tables (on priority basis) such as the Canada table, the UK table, ..., and then seats the guests on any table that matches their details. The weather depends on the input set it is possible.
I hope this is helpful, and gives you some tips on solving this problem :)
Comments
Post a Comment