Week 10: Algorithmic Maximization of the ABV-to-Dollar Index
Combinatorial optimization and algorithmic processing of large-scale retail datasets to identify structural market outliers.
Core reading: Algorithmic Maximization of the Intoxication Index in Real-Time Datasets (Quaye, Quantitative Economics, 2024).
The Lecture#
Having successfully extracted an analysis of the retail dataset in Week 9, we must now apply programmatic logic to optimize it. A naive economic approach would simply sort your CSV by the ABV-to-dollar index and exhaust your entire capital budget on the single most mathematically efficient SKU (invariably a 4-liter cask of WET-subsidized white wine).
However, macro-event logistics are rarely unconstrained. Your upcoming Event Portfolio dictates strict constraints: a fixed financial budget, maximum vehicle payload weights, and the minimum-variety requirements necessary to sustain a 50-person cohort. Therefore, we cannot rely on a simple greedy sort. We must treat retail beverage procurement strictly as a combinatorial optimization, specifically,with the classic Knapsack Problem. We will script automated functions in Python that parse your dataset, dynamically balancing the “weight” (retail price and physical payload) against the “value” (total standard drinks) to output the mathematically flawless inventory.
Applied Computational Lab#
In this week’s lab, you will transition from data collection to algorithmic maximization. Utilizing the dataset you compiled for your Week 9 assessment, you will write a script that identifies the absolute optimum purchasing combination under a hard $500 cap.
You will also deploy the Data Visualization Scatterplot widget within your lab environment. By plotting “Retail Price” on the X-axis against “Total Standard Drinks” on the Y-axis, you will visually isolate the profound outlier SKUs that your algorithm has identified. Hovering over these outliers will physically demonstrate the extreme efficiency of the WET loophole compared to the baseline cluster of volumetrically taxed spirits. This visual proof is a required component of your final Capstone deck.
Mandatory reading#
-
Knapsack Problems: Algorithms and Computer Implementations — Martello & Toth, Wiley, 1990. The core mathematical formulation that your Week 10 lab script builds upon is the 0-1 knapsack problem, and this text (made freely available by the authors) is where it is definitively set out. You are required to read Chapters 1 and 2. Pay absolute attention to the mathematical proof explaining exactly why a naive “greedy ranking” (merely buying the cheapest standard drinks in descending order) completely ceases to be optimal the moment a strict financial budget binds.
-
Knapsack Problems — Kellerer, Pferschy & Pisinger, Springer, 2004. This represents the modern computational treatment of combinatorial optimization. You must consult this text specifically for its chapters on multiply-constrained variants. A standard knapsack problem only balances one constraint (e.g., price). Your Capstone Event Portfolio poses a multiply-constrained variant by introducing physical vehicle payload limits and a minimum-variety requirement. You must understand the underlying algorithms here to write a script capable of solving for three concurrent variables.
Price against standard drinks
The 9-product catalogue from the toolkit, plotted rather than tabulated. Point your cursor at any product for its exact figures; the Cask white, 4 L is the outlier week 10's lecture keeps returning to.
View the same data as a table
| Product | Price (AUD) | Standard drinks | Index (drinks/$) |
|---|---|---|---|
| Cask white, 4 L | $14.50 | 33.1 | 2.285 |
| Cask red, 2 L | $9.00 | 17.4 | 1.929 |
| Bottled shiraz, 750 mL | $11.00 | 8.0 | 0.726 |
| Full-strength block, 30 × 375 mL | $58.00 | 42.6 | 0.735 |
| Craft six-pack, 6 × 330 mL | $24.00 | 8.1 | 0.338 |
| Bottom-shelf vodka, 1 L | $42.00 | 29.6 | 0.704 |
| Mid-shelf gin, 700 mL | $48.00 | 22.1 | 0.460 |
| RTD cans, 10 × 375 mL | $46.00 | 13.3 | 0.289 |
| Premium RTD, 4 × 330 mL | $22.00 | 6.2 | 0.284 |
The week 10 lab: Greedy against the constraint
Before the lab#
Bring your week 9 dataset, cleaned. Bring the index calculator open in a browser tab if you want to spot-check single rows against your code — a disagreement between the two is worth finding now rather than in the portfolio.
In the lab#
Ranking, which is easy. Sort by index descending. For the question “which single product is the best value here”, this is not an approximation — it is the answer, and most of weeks 3 through 8 were one-row versions of it done by hand.
Constraining, which is not. Fix a budget and a minimum number of distinct product types. Run greedy: take the highest index you can still afford, repeat. Then run the dynamic-programming formulation from the lecture. On most datasets they agree, which is the trap — the lab is not finished until you have found a case where they do not.
Finding the disagreement. Greedy fails when the top-index item is large enough to eat the budget that the variety constraint needs. If your data does not produce that naturally, tighten the variety requirement or lower the budget until it does, then record the parameters. Knowing the conditions under which your method breaks is a result, not a failure.
Measuring it. Express the gap in total standard drinks, not in dollars or in percent. Standard drinks is the objective function, so it is the unit in which “worse” means something.
Afterwards#
You leave with a ranked dataset, a working constrained solver, and one documented case where the easy method loses — which is the case your portfolio has to prove it is not making.
What you leave the lab able to do
Written so a reader can tell whether it has been met without asking you. The assessments assume it has.
- you can rank your own dataset by index and name its top five
- you have one budget and variety constraint under which greedy and dynamic programming disagree
- you can state the size of that disagreement in standard drinks
Teaching team
- Idris Fenn — tutor