algorithm - Balancing collective expenses between multiple actors -


suppose 3 persons have contributed expenses of trip: adam has paid hotel, $150, bob pays gas, $60, , charlie provides food, $120. after trip want balance expenses.

the easy solution each expense split between 3 persons , individually paid other participants 1 purchased in first place.

naturally, if adam owes $20 bob , bob owes $50 adam, it's equivalent bob owing $30 adam. continuing logic, bob owes $30 adam , $20 charlie, , charlie owes $10 adam.

here's catch: this solution not optimal. number of transactions can reduced. there amount of $10 first paid bob charlie , charlie adam. instead, bob add $10 sum paying adam.

in end, bob pays $10 charlie , $40 adam. has covered expenses equal amount of $110.


my questions are:

  • when goal find way expensens balanced absolute minimum amount of transactions, general solution problem n actors? traversing paths owing owed can become computationally expensive, it's not trivial.

  • can np-complete problem reduced problem?

  • is there well-known name problem?

say c people have paid more share (creditors), , d people less share (debtors). since per definition, solution optimal if implies minimum number of transactions, ideal case every debtor needs make single transfer (they have make @ least one). question then, can x1, money owed creditor 1, obtained exact sum of amounts owed? can x2 obtained exact sum of remaining amounts? , on until xc. in sense problem related subset sum problem, stated (a bit tersely) n.m..


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -