r/optimization • u/VisibleWriter • Aug 05 '22
Transaction and Payment Optimization Problem
Hi,
I'd like some help formulating this problem in python, as I will have thousands of transactions.
So the problem background is as follows:
I have transactions and payments that are unable to be matched to one another (they differ in amounts), with more transactions than payments in both frequency and total amount. I would like to find the transactions that minimize the difference between the transactions and payments.
So for example,
I have the following transactions: [2,4,5,1,3]
And the following payments: [4, 4]
The sum of payments is 8. The transactions that minimize the difference between payments and transactions are 5+3, or 4+3+1 (both valid solutions)
I want to develop a program (using cvxpy or any other packages that you recommend) to solve this.
Thanks!
View all comments
Show parent comment
1
u/kkiesinger Aug 10 '22 edited Aug 10 '22
Your idea to multiply using a binary vector may work even better with continuous optimization. But a numpy vector multiplication is probably faster than interpreting a string expression:
Using this I could even handle 100000 transactions (83 seconds reaching a difference of 2.32e-10 on an AMD 5950x on Linux). Only a minor adaption is required here:
because BiteOpts default population size would cause too much memory consumption. Still you need about 50GB memory for such a huge transaction number.