millionmilesaway
millionmilesaway

Reputation: 111

Discount distribution problem (optimization)

Suppose we have a shop and sell 5 different products: A, B, C, D and E. Each product has a fixed base cost of $8.00.

Now we represent the amount of each product bought as a tuple (a, b, c, d, e). These are the rules for discounts:

As an example, say we have (2,0,3,1,5), so 2x Product A, 3x Product C, 1x ProductD, 5x Product E. Then for example we could use a greedy approach:

(2,0,3,1,5) -> (1,0,2,0,4) -> (0,0,1,0,3) -> (0,0,0,0,2) -> (0,0,0,0,1) -> (0,0,0,0,0)

          (-20%)         (-10%)          (-5%)         (-0%)          (-0%)

The discount can only be applied once per group of different products. In the first step we would apply it to 4 different products, so ($8.00 * 4) * 0.8, second step we would get ($8.00 * 3) * 0.90.

So if we introduce variables in then we get in general that

totalPrice = [(base_price * n) * discountFor(n)] + [(base_price * (n-1)) * discountFor(n-1)] + ... + [(base_price * 2) * discountFor(2)] + (k * base_price)

I'm not allowed to use a naive approach. Playing with a few examples I found the greedy approach to be pretty stable but I'm not sure if there's a counterexample.

I tried writing the problem down formally but there's no obvious analytical solution here as the number of how often we could use a specific discount is dependent on which ones we have used before.

Is there a way to solve this using dynamic programming, linear programming or another problem-solving technique?

Upvotes: 0

Views: 223

Answers (0)

Related Questions