views:

93

answers:

2

I need to get inherited class of DispenseAlgorithm. It must realize algorithm for calculate issuance of delivery. The algorithm must provide even nominals consumption .

public abstract class DispenseAlgorithm
{
       public abstract Dictionary<int, int> CalculateDispense(CassetteData[] data, int summ);
}

public class CassetteData
{
       public int UID { get; set; }
       public int Nominal { get; set; }
       public int Count { get; set; }

       public CassetteData() { }
}

The class CassetteData – provides info about set of denomination at current time (Nominal - value of nominal denomination, Count – quantity of denomination, UID - unique identifier of denomination set).

The method CalculateDispense has 2 parametes: - available at current time denomination set (CassetteData{] data) - sum we pay out (or give out) as cashback.

The method CalculateDispense must return object Dictionary, where key - unique identifier of denomination set , and value – quantity of denomination required to payment.

Wishful result: denomination must comes to end as evenly as possible at some sessions issuance of delivery

For example: We have denomination sets:

1        10 $                100 denomination
2        50 $                 100 denomination
3        100 $         100 denomination

We need to pay out 800$

Good result:

1     5 items 
2     5 items 
3     5 items

Because 800 = 10 * 5 + 50 * 5 + 100 * 5

Bad result:

1        0 items 
2        0 items 
3        8 items

Because 800 = 10 * 0 + 50 * 0 + 100 * 8

Denomination are means money, note, cut, bank note,bond

issuance of delivery are means issuance of cashback

Nominal - par, face value, par value, nominal value, rating

A: 

Such a big theory......... culd'nt understand what the question is

stacknewbee
I have the cash - CassetteData[]. It includes cells with money - CassetteData. I need to give the change. How can I do it? Algorith must provide even nominals consumption.
Grienders
+3  A: 

If I have understood your question correctly you are looking for an alogrithm which says for a set of integers Y, how can I get generate a value x such that x = a1*y1 + a2*y2 + a3*y3 + ... where y1, y2, y3,... are elements of Y and a1, a2, a3,... are integers which are minimally spaced, or rather as "even" as possible.

If this is correct then you need to define how you measure the best result in terms of the a's. You mention that you have a fixed pool of each note, and so therefore you want to try and keep the levels of this as even as possible, but how do you measure the "best" end result?

As a starting point i would suggest looking over this question and its responses as they seem to be the sort of thing you are after, except with the caveat that you need to maintain the denomination levels as well.

You could also consider looking into linear programming as this seems like a problem that could be expressed in that form and solved accordingly. Maximising and minimising values whilst working within a set of constraints is what it is all about so could well be something that could help you.

Hopefully that can serve as a useful starting point to your problem

chillysapien