Introduction
This
documents describes how Microsoft Dynamics AX for Retail determine which
combination of discounts to apply to transactions when more than one discount
applies to one or more items in the transaction and the total quantity of the
items with multiple possible discounts increases beyond a few (25) items. The
exact number of items depends on how many discounts can be applied to each item
and how complex the discounts are.
Overlapping
discounts is the term we’ll use when two or more discounts can be applied to
the same set of items in a sales transaction. Determining the combination of
discounts to use that would results in the lowest transaction total is a
combinatorial optimization problem. This is especially true when a discount
requires 2 or more items to be purchased together and the effective discount
amount varies with the price of the two items, as is the case in the common
retail discount Buy 1 Get 1 X% off.
To determine the best combination of discounts to apply quickly and continue to
provide the rich discount functionality available in Dynamics AX for Retail a
new methodology has been introduced for determining the best combination of
discounts by evaluating the discounts relative to each other as applied to all
the items in a transaction with overlapping discounts.
Let’s look at
an example to understand the problem of how to choose the best combination of
discounts.
We’ll buy 2
items and there are two possible discounts which cannot be combined
 Discount 1: Buy 1 item get a 2^{nd} item of equal or lesser value at 50% off.
 Discount 2: Buy 2 items and get 20% off both.
For any 2 items
the better of these two discounts depends on the price of the two items with
respect to each other. When the price of both items is equal or close to equal
then Discount 1 is better. When the
price of one item is significantly less than the other item then Discount 2 is
better. The rule for evaluating these two specific discounts against each other
works out to be: If
Then Discount 1 is the
better value otherwise Discount 2 is the better value. Note, when the price of
item 1 is equal to 2/3 the price of item 2 then the two discounts are equal.
In this example
the effective discount percent for Discount 1 varies from a few percent when
the price of the two items is far apart to a maximum of 25% when the two items
have the same price. The effective discount percent for Discount 2 is fixed. It
is always 20%. Because the effective discount for Discount 1 is ranges above
and below Discount 2 the best discount can only be chosen based on the price of
the items to be discounted.
If
we buy 4 items and both discounts could be applied to all 4 items then only two
applications of Discount 1 or Discount 2 could be applied to the transaction
because each discount requires two items to qualify and the discounts cannot be
combined on any single item. These are
‘Exclusive’ discounts.
Let’s
look at three sets of items with different price ranges to illustrate the
possible combinations.
 All items have the same Rs. 15 price. The best discount combination is two applications of Discount 1. You will have 2 full priced items and two 50% off items. The transaction total will be Rs. 45 which is net 25% off the total of Rs. 60. (Rs. 15, Rs. 15, Rs. 7.5, Rs. 7.5). Discount 2 is only 20% off.
 Now let’s say two items are Rs. 20 each and two items are Rs. 10 each. Now the best discount combination is two applications of Discount 2. All 4 items would have 20% off each. The transaction total will be Rs. 48 which is net 20% off the total of Rs. 60. (Rs. 16, Rs. 16, Rs. 8, Rs. 8). Discount 1 would be only 16.6% off. (Rs. 10 / Rs. 60).
 Finally let’s say two items are Rs. 20 each one item is Rs. 15 and one item is Rs. 5. Now the best discount combination is one application of Discount 2 and one application of Discount 1. Since the effective discount for Discount 2 is always 20% if we choose two items that eliminates the least effective combinations for Discount 1 we can maximize the effective discount of Discount 1. The least effective application of Discount 1 is a Rs. 20 item and a Rs. 5 item. So we use these two items for Discount 2. That leaves a Rs. 20 item and a Rs. 15 item. Discount 1 give a slightly better value so we’ll use it. The transaction total is Rs. 47.50 which is 20.8% off the total of Rs. 60. (Rs. 16, Rs. 4, Rs. 20, Rs. 7.5).
To make it easier to visual the 3^{rd} example two
tables below showing the effective discount percentage for all possible
combinations of items for both Discount 1 and Discount 2. I’ve marked the
lowest effective discount in red.
Discount
1 (50%)

20

20

15

5

20

25.0%

25.0%

21.4%

10.0%

20

25.0%

25.0%

21.4%

10.0%

15

21.4%

21.4%

25.0%

12.5%

5

10.0%

10.0%

12.5%

25.0%






Discount 2 (20%)

20

20

15

5

20

20%

20%

20%

20%

20

20%

20%

20%

20%

15

20%

20%

20%

20%

5

20%

20%

20%

20%






Now
an example that falls in between. When prices vary and two or more discount
competes the only way to guarantee the best combination of discounts is to
evaluate the discounts and compare them.
Continuing
the example from the previous section let’s add more items and an additional
discount that also requires 2 items to qualify. You’ll see the total number of
possible combinations that need to be evaluated very quickly grows beyond what
can possibly be calculated quickly.
# of items in the transaction

One 2item discount can be
applied

Two 2item discounts can be
applied

Three 2item discounts can be
applied


# of possible pair combinations

# of possible pair combinations

# of possible pair combinations

4

4

8

18

5

15

60

135

6

15

90

315

7

90

540

1890

When
additional multiitem discounts are applied to a transaction or larger
quantities are added to the transaction then the total number of possible
discount combinations grows quickly into the millions and the time required to
calculate the best possible combination of discounts will quickly become a
noticeable amount of time. Some optimizations can be done to reduce the total
number of combinations that need to be evaluated, however if the number
overlapping discounts or the quantities in the transaction are not limited you
will always end up with a very large number of combinations to evaluate
whenever you have overlapping multiitem discounts.
Marginal Value
As mentioned at
the beginning, to solve this problem we have added an optimization that
calculates the value per shared item of each discount on the set of items that
can have two or more discounts applied to them.
We refer to this as the Marginal
value of the discount for the shared items. The marginal value is the
average per item increase in the discount amount when the shared items are
included in each discount. Marginal value is calculated by taking the total
discount amount (D_{Total}) and subtracting the discount amount without
the shared items (D_{Minus Shared}) and dividing that difference by the
number of shared items (Items_{Shared}).
After we
calculate the marginal value of each discount on a shared set of items we then
apply the discounts to the shared items in order from highest to lowest
marginal value
No comments:
Post a Comment