Split bill and settlement plan in group activities
JavaScript linear programming solver: jsLPSolver
- Payee can lose or earn money when making the transfers plan, because of the rounding problem. The upper limit of lost or gained amount is
$0.005 \times (n - 1)$ , where$n$ is the number of members in the group. The program prefers fairness than accuracy. To split $1 into 3, the program will give (0.33, 0.33, 0.33) instead of (0.33, 0.33, 0.34).
(1) Notations
Define due value of a group member, is the value they is allocated to minus the value they has already paid. If this value is negative, they has overpaid and is the payee in the following settlement. If the value is positive, they has underpaid and is the payer in the following settlement.
Define the due value of payer is supply value, and "zero minus the due value" of payee is demand value.
Let
(2) Variables
Let
Let
(3) The objective function
The objective is to minimize the transfers in the whole settlement.
(4) Constraints
The supply constraint:
The demand constraint:
If
Non-negative constraint:
Binary variable constraint: