I am building a software which handles multiple threads and resource allocation.I faced a situation which needs a mathematical solution.so I am putting it like a problem.Please give your inputs or suggestions as to how i tackle this situation.

I think it can be related to set theory from my knowledge.

Consider a friendly planet, named xyz, of our earth. The people of xyz only eat apples. Now, on one bad day, all apples from that planet have been stolen. Now, the sincere people of mathhelpforum have decided to feed the people of xyz.

So, mathhelpforum has sent a delegate of 'K' donors to xyz. Each donor has different bag of different capacity for carrying apples. Say, donor 'k1' has capacity of 'c1', donor 'k2' has capacity of 'c2', and so on. Each donor can give apples to any number of members(defined below). [So, Donor --> Member relation is One-to-Many]

On the other side, at xyz, the (alien) population contains 'T' families. Each family has 'B' family members.

The problem is how the donors should distribute the apples among the families of xyz such that all the families MUST get equal share of total-donation(TD) from mathhelpforum. But there is one condition I forgot to mention. According to xyz ritual, any member (from any family) can take apples ONLY from one donor. It is possible that a member can not get any apple from any donor. [So, Member --> Donor relation is One-to-One if it gets the donor]

Additional Information:

1. The total donation from mathhelpforum is always divisible by number of families with remainder zero. (TD%T = 0)

2. Every donor MUST be able to donate his/her apples to some member.

Example:

1. Consider an example, 5 donors went from mathhelpforum with following apple carrying capacities - [2 2 2 3 3]

2. On xyz, there are 3 families, each family has 2 members.

3. So, Following allocation is possible.

Family T1 - m1 (2 from d1)

- m2 (2 from d2)

Family T2 - m1 (2 from d3)

- m2 (2 from d4)

Family T3 - m1 (1 from d4)

- m2 (3 from d5)

Please note that every family gets EXACTLY four(4) apples. Moreover, There is only one donor tagged to every member, BUT not vice versa.

Sample data set

----------------------------------------------------------------------------------------

Families Members Donors Donors-Capacity

/ Family

--------------------------------------------------------------------------

2 2 2 [ 1 1 ]

--------------------------------------------------------------------------

2 2 3 [ 1 1 2 ]

--------------------------------------------------------------------------

2 1 2 [ 1 1 ]

--------------------------------------------------------------------------

3 3 3 [ 2 2 2 ]

--------------------------------------------------------------------------

can someone suggest me as to how to tackle this?

Thanks for your time?