Number of semi-random combinations / permutations given a set of constraints

Background:

There are around 60 students at the boarding school I work for. The counselor asked my colleague and me to come up with a better way to come up with seating arrangements for dinner than by hand. He would like assignments for the rest of the school year. He also asked us to try to solve some of the issues he has hearing about from students and faculty.

Constraints:

  • Most of the students are not from the US, so when they are surrounded by people of the same nationality (i.e., at the dinner table), they speak the language they are fluent in, instead of practicing English,
  • Complaints are made when students have sat at a certain table “too many” times overall,
  • or if they sit at the same table more than twice in a row,
  • and some of the students do not get along, so they cannot sit together.

Input:

At run time, the program is supplied with:

  • A set of people,
  • A set of tables, and
  • Each table has a different number of seats (repetition is allowed)

The size of both sets, and the size of each table does not change between each assignment.

Tests:

I am using 18 people of different nationalities, and 4 tables of size 3 through 6, inclusive. I picked numbers that I thought made sense for that data set:

  • No more than 3 people of the same nationality can sit together at a time
  • No person can sit at a table more than 4 times

Results:

I have run the generator around 15 times without changing the input data. Each time, it comes with anywhere from 6 to 12 “weeks” of assignments.

Questions:

(least to most important)

  1. Why do I get a different number of generated assignments every time I run the program? The data set isn’t changing between runs.
  2. How do I find the…
    • minimum number of people of the same nationality that can sit at a given table,
    • minimum number of overall times they sit at a given table, all while
    • maximizing the number of generated assignments?
  3. How do I guarantee that these actually are the correct numbers?

Edit:

Each time I generate a new assignment, I call Collections.shuffle(List) on the list of people to randomize their order. I then pass the list of tables and people to a backtracking method based off of kapilid’s eight queens implementation on github to assign people to tables.

2

Update:

I realized I didn’t directly answer your questions. I suppose it helps to read all of the question before firing off an answer…

  1. You don’t specify what algorithm you’re using to generate the seating arrangements. Presumably there is some element of variability / randomness in order to create different assignments for the duration of the term. That randomness is most likely the reason why you’re getting differing results on each run. I’d mark that as working as designed instead of a bug.

  2. a. You don’t specify the algorithm, so we don’t really know. We also don’t know the counts for each nationality. By simple logic, 0 or 1 would be the absolute minimum at a table, but I suspect that’s not very helpful to you. Ultimately it depends upon the number of each nationality and how they populate the other tables.
    b. Run your program, throw the results in a database or spreadsheet and have it count for you. Or alter the program to keep track of those things.
    c. The answer here is going to be dependent upon the number of each nationality and the other constraints you supplied. Table size will also affect it. The answer to this portion is really just a multiplication of the number of potential permutations. Fortunately (for me) this is a site about programming, not statistics.

  3. You have two issues to contend with here. First is validating that your constraints accurately reflect the reality of the situation. Talk to the counselor to verify your constraints are correct. Second is verifying your results fulfill your constraints. Write some methods that check the returned seating charts for the constraints you provided. And / or manually inspect the charts to verify they are okay.


This SO Question has a similar question and suggests that this is equivalent to the bin packing problem or the knapsack problem

This SO Question Seat guests based on prioritized parameters seems to address exactly what you’re looking for.

This SO Question discusses problems the author had in solving this problem using the bin-packing algorithm. I’d suggest reading the answers to get a better insight in how to work around them.

And for the obligatory xkcd reference, here’s a link from their forums discussing seating plan optimization and using a modified genetic algorithm to solve the problem.

If this is a real scenario, then best of luck. And if this is just homework then you’ve got more than enough material to move you forward with.

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật