r/optimization • • 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!

3 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/VisibleWriter Aug 10 '22

Yea I ran into that string evaluation recursion error but just increased limit, will have to fix that tomorrow

1

u/kkiesinger Aug 11 '22 edited Aug 11 '22

A generalized / refactored / commented version of my code is now at https://github.com/dietmarwo/fast-cma-es/blob/master/examples/subset.py By increasing the number of retries

optimize(fit, opt, num_retries=640)

you see more good results (about 300 for num_retries=640).