가장 효율적인 좌석 배치 (Most efficient seating arrangement)


문제 설명

가장 효율적인 좌석 배치 (Most efficient seating arrangement)

n(n <1000)개의 친구 그룹이 있으며 그룹의 크기는 A[] (2 <= A[i] <1000). 테이블은 한 번에 r(r>2)명을 수용할 수 있도록 제공됩니다. 모든 사람이 앉는 데 필요한 최소 테이블 수는 얼마입니까? 모든 사람이 자신의 테이블에 앉을 수 있는 그룹의 다른 사람이 있어야 한다는 제약 조건이 있습니다.

제가 생각한 접근 방식은 다음과 같습니다. 모든 그룹을 2와 3의 크기로 나누고 이 문제를 해결하려고 시도하지만 숫자 n을 2와 3의 그룹으로 나누는 많은 방법이 있으며 모두가 최적이 아닐 수도 있습니다.


참조 솔루션

방법 1:

Does a Mixed Integer Programming model count?

enter image description here

Some notes on this formulation:

  • I used random data to form the groups.
  • x(i,j) is the number of people of group i sitting at table j.
  • x(i,j) is a semi‑integer variable, that is: it is an integer variable with values zero or between LO and UP. Not all MIP solvers offer semi‑continuous and semi‑integer variables but it may come handy. Here I use it to enforce that at least 2 persons from the same group need to sit at a table. If a solver does not offer these type of variables, we can formulate this construct using additional binary variables as well.
  • y(j) is a binary variable (0 or 1) indicating if a table is used.
  • the capacity equation is somewhat smart: if a table is not used (y(j)=0) its capacity is reduced to zero.
  • the option optcr=0 indicates we want to solve to optimality. For large, difficult problems we may want to stop say at 5%.
  • the order equation makes sure we start filling tables from table 1. This also reduces the symmetry of the problem and may speed up solution times.
  • the above model (with 200 groups and 200 potentially used tables) generates a MIP problem with 600 equations (rows) and 40k variables (columns). There are 37k integer variables. With a good MIP solver we find the proven optimal solution (with 150 tables used) in less than a minute.
  • Notice this is certainly not a knapsack problem (as suggested in another answer ‑‑ a knapsack problem has just one constraint) but it resembles a bin‑packing problem.

방법 2:

It is same problem as knapsack problem which is NP complete (see https://en.wikipedia.org/wiki/Bin_packing_problem ). So finding optimal solution is pretty hard.

A heuristic that works most of the time:

  1. Sort the groups according decreasing size.

  2. For each group put it in the table that has least amount of space, but still can accommodate this group.

방법 3:

Your approach is workable. If a solution exists for a given number of tables, then a solution exists where you've split every group into some number of twos and some number of threes. First, split a three off of every group of odd size. You're left with a bunch of groups of even size. Next, split twos off of every group whose size isn't divisible by six. And forget that it's one bigger group; split it into a bunch of groups of six.

At this point, you have split all of your groups into some number of twos, some number of threes, and some number of sixes. Give each table of odd size one three, splitting sixes as necessary; now all tables have even size. All remaining sixes can now be split into twos and seated arbitrarily.

(by SHBErwin KalvelagenElKaminatmyklebu)

참조 문서

  1. Most efficient seating arrangement (CC BY‑SA 2.5/3.0/4.0)

#dynamic-programming #greedy #mathematical-optimization #algorithm






관련 질문

나머지 숫자의 xor가 0인 부분 집합의 수를 찾습니다. (Find number of subsets, that xor of remaining numbers equals to 0)

재귀 대신 동적 프로그래밍을 사용하여 가장 큰 공통 접미사(자바스크립트) 찾기 (Use dynamic programming instead of recursion to find largest common suffix (javascript))

제거 방법 : java.lang.OutOfMemoryError (how to remove : java.lang.OutOfMemoryError)

가장 효율적인 좌석 배치 (Most efficient seating arrangement)

aglorithm의 복잡성을 가진 춤 (A dance with an aglorithm's complexity)

장애물이 있는 처음부터 끝까지 경로의 수를 계산합니다. (Count the number of paths from start to end with obstacles)

직사각형 필드 내에서 다양한 크기의 직사각형을 효율적으로 배치 (Efficient placement of variable size rectangles within a rectangular field)

기차 또는 버스를 이용할 수 있는 도시 간 최단 경로 DYNAMIC PROGRAMMING (Shortest path between cities that you can use either train or bus DYNAMIC PROGRAMMING)

인덱스가 오름차순으로 정렬되도록 주어진 합계를 갖는 하위 배열의 개수 (Count of sub-arrays with a given sum such that the indices are in ascending order)

2차원 배열의 경로 수 계산(그리드 Traveller) (Count number of paths on 2d-array (grid Traveller))

n개의 볼과 m개의 빈이 주어지고 각 빈이 특정 용량을 가질 때, 몇 개의 조합이 있습니까? (Given n balls and m bins, each bin with a certain capacity, how many combinations are there?)

재귀 호출을 메모할 때 엄청난 효율성 차이 (Drastic efficiency difference when memoizing recursive calls)







코멘트