algorithm to determine minimum payments amongst a group

后端 未结 8 697
庸人自扰
庸人自扰 2020-12-05 12:09

The Problem

I was recently asked to calculate the money owed amongst a group of people who went on a trip together and came upon an interesting problem: given that

相关标签:
8条回答
  • 2020-12-05 12:33

    In the world of the corporate treasury, this is known as payment or settlement netting.

    Multinational corporates usually have many flows between their subsidiaries every month, often in different currencies. They can save considerable amounts by optimising the settlement of these flows. Typically a corporate will perform such an optimisation (a netting cycle) once a month. When there are multiple currencies, there are three sources of savings:

    • bank transaction fees (fewer payments means lower fees)
    • lower interest rate float and settlement risk arising from streamlined processing by the bank (the money spends less time tied up in the banking system)
    • FX matching (much less foreign currency is exchanged because most of it is 'netted out')

    There are two ways to actually calculate the optimised settlement.

    Bilateral netting is the solution well described by @AndrewShepherd on this page. However, in a cross-border implementation, this approach can have legal and administrative problems implications since different borders are being crossed each month.

    Multilateral netting solves the network by adding a new subsidiary called the netting centre and re-routes all amounts through it. Compare the before and after diagrams below:

    Before netting

    Before netting

    After netting

    After netting

    Although this adds one more flow than is necessary (compared to bi-lateral netting), the advantages are:

    • the calculation is simpler and the result is easier to visualise (also, there is only one solution, as opposed to the bilateral approach)
    • the netting centre becomes an invaluable resource regarding flows and FX exposure within the whole group
    • if the netting centre is, say, in Germany, then all legal issues with cross-border payments are dealt once and for all within the netting centre's country (central bank reporting, etc.)
    • all foreign exchange required for the optimised settlement can be bought or sold from the netting centre

    (At it's basic level, the calculation is simple, but there can be many legal and administrative complications so corporates frequently develop or purchase a netting system from a software vendor or service provider.)

    0 讨论(0)
  • 2020-12-05 12:35

    While I concur with @Andrew that turning this into a graph problem is probably overcomplicated, I'm not sure his approach yields the minimal number of transactions. It's how you'd solve the problem in real life to save yourself a headache; just pool the money.

    A few steps that seem 'right':

    • Remove all individuals with zero debt; they don't need to send or receive money from anyone.
    • Pair all givers and receivers with identical amounts owed/owing. Since the minimal connectivity per node of non-zero debt is 1, their transactions are already minimal if they just pay each other. Remove them from the graph.
    • Starting with the individual with the largest amount to pay back, create a list of all receivers with owed less than that amount. Try all combinations of payment until one is found that satisfies most receivers with one transaction. 'Save' the surplus debt remaining.
    • Move on to the next largest giver, etc.
    • Allocate all the surplus debt to the remaining receivers.

    As always, I'm afraid I'm pretty sure about the first two steps, less sure about the others. In any case, it does sound like a textbook problem; I'm sure there's a 'right' answer out there.

    0 讨论(0)
提交回复
热议问题