You may consider generalizing the Hall marriage theorem and / or the assignment problem .
The idea for this paradigm is to create a bipartite graph, where the nodes are people and cereals, with the edge between the person p
and the grain c
, if p
voted for c
. The goal is to select 3 cereals so that the graph obtained by removing all other cereals is
Instead, you might think of it as a problem of maximum coverage . In this case, you have sets C1,C2,...,Cm
, where Ci
is a set of people who like grain i
. For example, if you took cereals and people in the order shown in the table, you have
C1 = {1,5} C2 = {2} C3 = {1,4,5} C4 = {3,5}
Let n
be the number of people, so Ci
is a subset of {1,2,...,n}
. The goal is to find k
sets so that the combining power is maximized. If there are several solutions, choose the one that minimizes the power of intersections (minimizes the amount that one person dominates) or maximizes the number of repetitions of the least frequent element (maximizes the happiness of the least happy person).
In this example, the smallest k
for which all elements are covered is k=3
and gives a unique solution C2,C3,C4
.
However, you look at this, you have an NP problem, but there are well-known algorithms for solving them (check out the wikipedia articles for links).
Pengone
source share