At first, there are a bunch of objects. Every single object has an attribute, which tells the type of groups it wants to belong to. A group is a container for a given number of objects. It has a type.
Now I'm looking for the combination where most objects are in a group that the object preferred. As the amount of groups is calculated by a formula which gives the lowest possible number, there are combinations where not all objects are in a preferred type of group. That's ok, because I'm looking for the combination(s) where most objects are in a preferred group.
A object can favor multiple types of groups, so it doesn't matter in which of the favored groups it is.
The group type can be chosen freely from the requested group types.
Is there an algorithm which can solve this problem?
Example
There are five objects. The first two don't care whether they are in a group of type A or B. The third wants to be in a group of type A, the fourth in a group of type C and the last one wants to be in type B.
The group size is two. The count of groups is calculated by the formula below.
Every type of a group can be chosen freely from the requested types (A, B or C).
Edit
Think about group size 6 and 12 objects. Eleven of them with preferred group type A and one of them with preferred group type B. For 12 objects and group size 6 there are 2 groups. The best solution would be to make two groups with type A. Then eleven objects are in a preferred group and one is in a group that it didn't prefer. Just to clarify, every object should be in a group.
How to find the best combination of group types? In this example, how can I connect the object with preferred group type B to a group (in the graph)? As far as I understood, Ford Fulkerson requires that the group types are already knwon.


