Business Case Algorithms (Inventory Optimization Pricing Models)#

(a.k.a. Making Money with Math — or at Least Trying To)

Welcome to Business Algorithms, where your goal isn’t just to find the most efficient solution — it’s to make someone rich, or at least make the quarterly report look good. 📊

In this chapter, we’ll dive into:

  • Inventory Optimization

  • Dynamic Pricing Models

  • Demand Forecasting

  • and other ways to make spreadsheets jealous.


🏬 1. Inventory Optimization#

(a.k.a. Don’t Run Out of Stuff, Don’t Hoard Either)

Inventory optimization is all about the delicate balance between:

  • Too little stock → angry customers 😡

  • Too much stock → angry finance department 💸

We want that sweet spot where profits soar and warehouses don’t look like an Amazon apocalypse.


🧠 The Classic EOQ (Economic Order Quantity) Formula#

EOQ helps you decide how much to order at a time.

[ EOQ = \sqrt{\frac{2DS}{H}} ]

Where:

  • D = demand per year

  • S = cost per order

  • H = holding cost per item per year

In plain English:

“How many widgets should I buy so the accountant doesn’t have a breakdown?”


💻 Example#

import math

def eoq(demand, order_cost, holding_cost):
    return math.sqrt((2 * demand * order_cost) / holding_cost)

print(eoq(10000, 50, 5))  # 141.42 units

Result: You should order ~141 units at a time. Or as the business guy says:

“Round it to 150 — we like nice numbers.”


🧩 Safety Stock: Because Life Is Uncertain#

If EOQ is the plan, safety stock is the insurance policy.

It protects against unexpected spikes in demand — or suppliers who think “on time” means next month.

Formula (simplified): [ SafetyStock = Z \times \sigma_{demand} ]

Where Z = desired service level (like 1.65 for 95%), and σ_demand = standard deviation of demand.

Translation:

“We don’t trust reality, so we keep extra.”


💰 2. Pricing Models#

(a.k.a. The Science of Guessing What People Will Pay)

Pricing is like dating:

  • Too high → people run away.

  • Too low → people think you’re desperate.

The secret lies in algorithms that balance demand and revenue.


🧮 The Demand Curve (a.k.a. “Why Discounts Exist”)#

Let’s assume demand follows a simple rule: [ Demand = a - b \times Price ]

Your Revenue = Price × Demand

So the goal is to find the price that maximizes revenue.

def optimal_price(a, b):
    # Maximizes revenue = price * (a - b*price)
    return a / (2*b)

print(optimal_price(100, 2))  # Price = 25

That’s the sweet spot where everyone’s kinda happy — except marketing, who’ll still want to add a “limited time offer.” 😅


💹 Dynamic Pricing: When Algorithms Play Airline Manager#

Dynamic pricing is the dark art behind why your flight ticket costs \(99 today and \)499 tomorrow.

It’s based on:

  • Time left before the event

  • Current demand

  • Remaining inventory

  • And possibly, whether the website thinks you look rich 💳

def dynamic_price(base_price, demand_factor, time_factor):
    return base_price * (1 + demand_factor - time_factor)

print(dynamic_price(100, 0.3, 0.1))  # $120

Dynamic pricing in business = “charging the most money people will still pay without tweeting about it angrily.”


📦 3. Demand Forecasting#

(a.k.a. Guessing the Future, but with Excel and Hope)

You can’t optimize inventory or pricing if you don’t know demand. Enter: Forecasting Algorithms — where you pretend to see the future using math. 🔮


🧮 Simple Moving Average (SMA)#

def moving_average(data, window):
    return [sum(data[i:i+window])/window for i in range(len(data)-window+1)]

sales = [120, 130, 140, 150, 170, 180]
print(moving_average(sales, 3))

Output → [130, 140, 153.33, 166.67]

It smooths out the noise — like a financial meditation. 🧘‍♂️


📈 Exponential Smoothing#

Because the most recent data usually matters more (except in family arguments).

def exp_smooth(data, alpha):
    smoothed = [data[0]]
    for i in range(1, len(data)):
        smoothed.append(alpha * data[i] + (1 - alpha) * smoothed[-1])
    return smoothed

print(exp_smooth(sales, 0.3))

Now you can predict demand, make stock decisions, and look mysteriously wise in meetings.


🧩 4. Optimization Meets Machine Learning#

In modern business, algorithms don’t just follow rules — they learn them.

Combine:

  • Regression models for predicting demand

  • Linear programming for cost minimization

  • Clustering for customer segmentation

  • Reinforcement learning for dynamic pricing

You’ve just built a business algorithmic empire. 👑


🏁 Real-World Business Examples#

Business Problem

Algorithm Used

Real-Life Analogy

Reorder levels

EOQ + Forecasting

Stocking snacks before Netflix night 🍿

Airline ticket pricing

Dynamic Programming + Greedy

“You should’ve booked earlier.” ✈️

E-commerce recommendations

Clustering + Regression

“We noticed you bought socks — how about 50 more?” 🧦

Ride-hailing surge

Dynamic Pricing

“It’s raining — now your cab costs your dignity.” 🚕

Supermarket shelf layout

Optimization + Greedy

“Put chips near beer. Profits will follow.” 🍺


💬 Final Thoughts#

Business algorithms prove that math isn’t just for nerds — it’s for profit, efficiency, and survival.

Every time you:

  • See “Only 2 seats left!” — that’s an algorithm.

  • Get a “20% off” email — that’s an algorithm.

  • Wonder why milk is always at the back — yep, algorithm. 🥛

So remember:

“Behind every business decision is an algorithm — and behind every algorithm is a developer quietly weeping over data.” 💻😭


# Your code here