I have a task in which I must distribute unique resources among consumers. Rules are:
- each consumer has a set of resource types they can use,
- each resource is unique,
- each consumer must receive n>0 resources,
- all resources must be distributed.
E. g. we have this list of consumers and their preferences:
- A: {X, W}
- B: {X, Y, V}
- C: {X, Z}
- D: {Z}
We have a list of resources: [X, W, Y, V, Z].
If we assign resources naively by iterating through the list of consumers and providing them with the first available resource from their set, we fail on D because the only Z is already assigned to C. A better solution is this: A(W), B(Y, V), C(X), D(Z).
Looks like a logic programming problem to me! While it is trivial to write a Prolog program that provides solutions for this particular case, what I want is a general program that can solve any such problems, or tell me that no solution for given data exists.
Where should I look, what should I google for, does this problem have a name?