Commit graph

10 commits

Author SHA1 Message Date
Bradley M. Kuhn
e87b6abb7f Sort solution by date in output. 2013-02-18 14:08:46 -05:00
Bradley M. Kuhn
afe912f163 Searching is better when you can set the begin date, end date and then go back from begin date. 2013-02-18 14:08:46 -05:00
Bradley M. Kuhn
11639785bb Improve spreadsheet and debugging output. 2013-02-18 14:08:46 -05:00
Bradley M. Kuhn
8ebb54638c Start search from date: easy way to resume searches.
Instead of always starting a search from the end date, allow a CLI option
that is the data to use for the start of searching (back from the end date).
This is useful when resuming a search (since they take a long time).
2013-02-18 14:08:45 -05:00
Bradley M. Kuhn
94094ce365 Finish reporting details for STDOUT; change command line arg to bank balance.
Report in CSV now goes to STDOUT.

The command line argument that was the difference to seek is now the bank
balance.
2013-02-18 14:08:45 -05:00
Bradley M. Kuhn
0530b729e2 Default to brute-force subset sum solution.
The dynamic programming version of the subset sum problem required far too
much RAM for larger bank balances.  Meanwhile, the brute-force is not to bad
now that the loop tries the closer dates *first*.
2013-02-18 14:08:45 -05:00
Bradley M. Kuhn
18d2867a63 Rename the function to note it's the dynamic programming one. 2013-02-18 14:08:45 -05:00
Bradley M. Kuhn
b1b807fcfa Loop through to build smaller sets when testing.
Usually, transactions that didn't appear are nearby in date to the statement
date.  This loop cycles through.  Overall, this would take longer to find a
solution, but since most solutions are in the early dates "back" from the
statement date, this will probably be faster in typical cases.
2013-02-18 14:08:45 -05:00
Bradley M. Kuhn
6962fc4c57 Basic implementation probably correct, but needs much RAM.
This is the basic implementation but for large numbers, it needs a *LOT*
of RAM.
2013-02-18 14:08:45 -05:00
Bradley M. Kuhn
b214a2db5b Began work on script to reconcile bank accounts.
The goal here is to take as input an account, a monthly balance amount
that appears on a bank statement, and the date of that bank statement and
output the list of transactions that likely weren't cleared properly as of
that date that caused the balance in the accounts to fail to match the
balance that appeared on the statement.

Note that determining this answer requires solving the known NP-Complete
problem called the subset sum problem.  There is a known pseudo-polynomial
dynamic programming solution to this problem, but it's still exponential
in the size of the numbers you have to balance.

So, if you have *big* account balances, this will make take quite a while
to run.  For smaller accounts, the pseudo-polynomial solution might be
helpful.  (BTW, the wikipedia entry on the subset sum problem isn't, at
the time of this commit, particularly good, but it's "good enough" to give
you a sense of what the subset sum problem is:
    http://en.wikipedia.org/wiki/Subset_sum_problem

)

I originally wrote the subset sum problem solution implementation here:
  2dca069d81

The code is just cut and pasted in here with some minor modifications.

This rest of this first commit just has that aforementioned paste, plus the
beginnings of the CLI and query to run to get the proper entries.
2013-02-18 14:08:44 -05:00