# Retail Discount Design – Simplex Discount with Quantity Control

At the first glance, we add quantity control to simple discount, so it would appear to behave like a simple discount more or less, but it is quite different: some obvious and some not.

By ‘simplex’ - forgive me for diverging from its original meaning in geometry - I take the liberty to coin it from sim-ple and com-plex. In fact, it is more on the complex side.

Setup

We have multiple options of how to enforce quantity control.

• Quantity control per (master) product. This is probably simplest setup in that it is easy to understand, and it is easier to implement than other options. Please note, if you have two variant products of the same master product, they share same control, say total quantity cannot exceed 4.
• Quantity control per discount line. I strongly discourage this setup – I only list it here because it is a possibility - unless you have a clear way to handle overlapped discount lines. Overlapped means that a product is configured in multiple discount lines.

For now, we will discuss quantity control per (master) product only.

How to apply simplex discount with quantity control when it is the only discount for the checkout cart?

It is slightly more complicated than simple discount case.

We need to enforce quantity control for each single product.

For variant products sharing the same master product, we can order them by price, and apply it to variant products from highest priced to lowest priced, until it reaches quantity ceiling.

When it competes with other discounts

In short – I have covered it many times before and I will not repeat here – how to figure out basic discount applications.

It is straightforward: one basic discount application for every product or variant product with quantity one.

In addition, the knapsack algorithm needs to be able to handle bounded scenarios.

For an algorithm to handle bounded discount knapsack problem, it needs quantity-control discount to maintain quantity-control when adding a new basic discount application and to tell whether it can add one more basic discount application.

Backup for knapsack algorithm

The estimation of simplex discount with quantity control is similar to that of simple discount. We just need to add a bit quantity control.

Applying it fast is more or less the same as applying it when it has no competition.

Compounding

It mainly depends on overall concurrency model

Nothing really to worry about with the concurrency model of compete within priority and compound across, because the knapsack algorithm does not deal with compounding.

For other models, it can mess up a lot. Recall that in many cases, we can turn a discount knapsack problem with compounded discounts into a one without. The key is to tag simple discount along non-simple (multi-item) discount. We can no longer consider simplex discount with quantity control as simple discount, instead, we need to make it just like multi-item discount. Now, we could still make tag-along work for simplex discount with quantity control, but the tag-along would be very complicated.

Optimizations

First, a bit good news: when the product quantity in the checkout cart is with quantity control, we can still consider it as a simple discount for the product, i.e. no quantity control.

For any optimizations that we have done with simple discounts, we need to re-visit them. In most cases, they do not apply, or we have to make accommodation to make it applicable.

Partial quantity

It would be odd for retailer to set up a discount like 10% off apple, up to 4 pounds. By default, it does not work with scale products.

For cheese, we could have a slightly different setup: say 10% off up to 4 pieces.

Tags