Re: Summing combinations to a known total problem, for cash-allocation / open-item accounting



Dave Lomax <billy_boy_clinton@xxxxxxxxxxx> wrote:
: Hi Randy,

: Thanks for your help. Unless I'm missing something, this method is
: basically a "decision tree"? The trouble with this is that it tries
: both combinations of £70 + £30, AND £30 + £70, which are obviously the
: same. And, as suggested in a previous posting, we can trim the
: "solution test set" at the beginning and end, if we use a binary table
: method, and COUNT through the solutions.

: Is there any more to DYNAMIC PROGRAMMING, than just using a recursive
: function? Am I missing something here?

: All help much appreciated :)

: Cheers,
: Dave

One of the main ideas behind dynamic programming is avoiding solving
the same sub-problem more than once. You do this by either
computing the solution in a bottom up fashion using a table
of some sort, or by using memoization.

Your problem looks like the change-making problem. The dynamic
programming solution is an O(mn) algorithm where m is the total
you are trying to reach, and n is the number of values.

Stephen



: "Randy Poe" <poespam-trap@xxxxxxxxx> wrote in message news:<1112025282.758926.52500@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...

:> Dynamic programming has been suggested. Let me get a
:> little more specific.
:>
:> Recursion works well on this problem.
:>
:> 1=2E Sort the n amounts in decreasing order: 75, 70, 30, 25.
:>
:> 2=2E Write a recursive routine (let's call it "subdivide")
:> which takes a list of amounts in decreasing order, and
:> a total to subdivide, and returns a division.
:>
:> div =3D subdivide(total, amounts)
:>
:> 3=2E subdivide does the following:
:> a. If amount has only one entry see if you can
:> divide the total into evenly spaced chunks
:> of that size. (so a total of 50 with an amount
:> of 25 would work, but a total of 45 would not).
:> Return either the solution or a code that says
:> "not possible".
:>
:> b. If amount has more than one entry, then take
:> the largest entry. Try using 0 to the largest
:> possible amount of that entry, and call subdivide
:> with the remainder.
:>
:> Ex: subdivide(125,[75 70 30 25])
:> try 0 75's, call subdivide(125, [70 30 25])
:> recurse: try 0 70's, call subdivide(125,[30 25])
:> try 1 70, call subdivide(55,[30 25])
:> try 1 75, call subdivide(50,[70 30 25])
:> recurse: try 0 70's, subdivide(50,[30 25])
:>
:> I hope that gives you the general scheme.
:>
:> - Randy
.



Relevant Pages

  • form/subform caclulation timing
    ... I have an "order entry form" can be viewed at ... money (a set limit and limited by the amount of money they pay in). ... The refund field is calculated via subtracting the shiping ... until they get done entering the data. ...
    (microsoft.public.access.formscoding)
  • Re: [Full-disclosure] Root password change
    ... The amount of time needed to pop in a disk and hit reboot ... a "crypto safe"), which is the highest level, only specify entry protection ... of 10 man-minutes forced entry, 20 man-hours surreptitious entry, and ... the testing is done by an expert locksmith with special expertise in this ...
    (Full-Disclosure)
  • Re: Trying Again
    ... The step you are missing in the simple formula is to read Mike's suggestion ... Why don't you try Mike's suggestion, and see what numbers you get? ... amount, it doesn't ADD it to the existing numbers which is what I ... I will try your way tomorrow Jacinthe, I am not a regular Excel user, ...
    (microsoft.public.excel.misc)
  • RE: Can anyone povide step by step instructions on how to do the follo
    ... amount into and a Worksheet_Changeevent to detect when the budget amount ... entry changes and go put the amount in the proper cell. ... Ive created an excel spreadsheet using simple =sumcommands for the ...
    (microsoft.public.excel.misc)
  • Re: What is the Buyers comeback?
    ... another amount ... What's missing is the trimmed, quoted posts ... You've paid? ...
    (alt.marketing.online.ebay)