0

Working on a personal project, I have encountered a problem that I'll try to generalize here.

Given a list of resources of different value (e.g. resources = [1, 0.8, 1.5, 0.8, 1.2...]), I want to share them among a group of N people in a way that is as fair as possible (i.e. no one ends up hoarding too much value while others have too little).

I assume a good way of tackling this issue is to minimize the function:

f(r1,...,rN) = (avg - r1)^2 + (avg - r2)^2 + ... + (avg - rN)^2

Where avg = sum(resources) / N and rx is the resources assigned to person x.

I have stumbled upon scipy.optimize.minimize, and I think it might be helpful, but I can't figure out how to describe the constrain that the values of r1, ..., rn cannot be arbitrary but instead need to be taken from resources (and in a way that the same resource is not given to more than one person in a solution), since I don't have any experience with this module nor a strong mathematical background applicable to this type of problem.

Is there an easy way of solving this problem with scipy?

sascha
  • 32,238
  • 6
  • 68
  • 110
user2891462
  • 3,033
  • 2
  • 32
  • 60
  • Place the people in a min heap. For each resource give the person at the top of the heap the next available resource, remove them from the heap and reinsert them. The idea is ther person with the fewest resources is always at the top – Mitch Jun 21 '19 at 19:40
  • You should also sort the resources greatest to least to ensure you end up with an optimal distribution – Mitch Jun 21 '19 at 19:45

1 Answers1

0

This is a generalized variant of the Partition Problem (the optimization-variant is NP-hard).

The differences in your case:

    1. you got reals instead of integers
    1. you look for an n-way partition
    1. you have a different loss-metric (quadratic vs. linear | l2-norm vs. l1-norm)

Now i won't hesitate to say, that your problem is still NP-hard, although above differences might be taken care of when proof is needed (1. usually easy under mild conditions; e.g. in your case: multiply with 10; 2. easy 3. not sure how i would tackle this).

Start with wikis Partition article which outlines basic results and approaches (you will see: there is a difference between 2-partition and n>2 partition complexity-wise).

As this is a discrete-optimization problem (e.g. formulated as binary quadratic programming), scipy has nothing to offer there in terms of well-chosen approaches: e.g. no (binary) integer-programming.

The things mentioned together with the wiki-link will also indicate, that the approach in the comment is not guaranteeing the optimal solution.

sascha
  • 32,238
  • 6
  • 68
  • 110