Corresponding Algorithm (Java)

I am writing an algorithm to map students to different groups. Each group has a limited number of places. Each student provides his 5 best groups. Then the students are placed in groups in a predetermined order (senior students and students with excellent attendance are given higher priority). There is no need to fill out the groups completely, but they cannot be filled with bandwidth.

I looked at similar problems with marriage, such as the Gail-Chapelle stable marriage algorithm, but the problem I am experiencing is that there are much fewer groups than students, and each group can accept several students.

What is the best way to implement such an algorithm in order to find a solution that has been fully optimized so that there is no better arrangement of students in groups? In terms of complexity of the algorithm, I place approximately 600 students in 10-20 groups.

+4
source share
4 answers

NB Closed voices are terribly out of place. The choice of algorithm and design to solve a controversial problem is absolutely part of the programming.

I think that you will be further with a minimum weight of two-way matching than with “Stable marriage” (also called the Hungarian method or algorithm or “Maximum weight”), which can give you minimum weight by simply negating the weight.)

. , node .

. . . - . - .

/, .

@nava - , , MWBM, . .

, , , . "" "dummy", . . , .

, . , O_i i- . R_ip - , p- . , W_ip - , i- p- . - :

W_ip = A * R_ip + B * O_i

A B, . , . , B , .

A = 1, B = N^2, where N is the number of students.

, , , .. , , .

, ( 90-), MWBM , , FORTRAN. O (N ^ 3). 1000 ( ). O (N ^ 2 log N), 3 N = 1000. "" 5000 .

, , .

+1

Knapsack ( , wikipedia), K () . "" , , "" . , , .

, , , .

+1

.

() .

:

students  <-- sorted by attendance

for i=0 to n in students:
   groups <-- sorted by ith student preference
   for  j=0 to m in groups:
     if group j has space then add student i to group j; studentAssigned=true; break;

   if studentAssigned=false;
     add i to unallocated

for i=0 to k in unallocated 
  allocate i to a random group that is not filled
+1

:

  • ( , , , 1, , 0 ).

But there are some details that you did not explain. For example, what happens if there are students who cannot enter any of their 5 options because they are replenished with other students with a higher priority?

0
source

Source: https://habr.com/ru/post/1629574/


All Articles