Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 38 ยท Modelling

Multi-Period Planning and Inventory Models

Model production planning over several periods with inventory balance equations, overtime, backorders and storage costs, solved as a linear program in Python.

Many decisions repeat over time: how much to produce each month, how much to hold in stock, when to hire. The usual LP approach is a multi-period model: one set of decision variables per period, linked by balance equations that carry stock from one period to the next. This is how real production plans, cash-flow plans and energy schedules are built.

The inventory balance equation

Let I_t be the inventory at the end of period t, x_t the production in period t and d_t the demand. The stock at the end of a period is the stock you started with, plus what you produced, minus what you sold:

TEXT
I_t = I_(t-1) + x_t - d_t         for t = 1..T,  with I_0 given

This single equation is the core of the model. It links the periods, and it is linear, so the whole plan stays an LP. Add the sign restrictions x_t >= 0, I_t >= 0 (no negative stock) and capacity limits x_t <= cap_t, then minimize total production plus holding cost.

A six-month production plan

A factory faces uneven demand: it peaks in months 4 and 5. Regular production costs 20 dollars per unit with a capacity of 100 per month; overtime costs 28 dollars per unit with an extra 40 units available per month; holding a unit in stock for a month costs 2 dollars. The factory starts with 20 units in stock. Demand: 80, 90, 110, 160, 180, 100.

Variables per month t: regular r_t, overtime o_t, ending stock I_t.

TEXT
minimize    sum_t (20 r_t + 28 o_t + 2 I_t)
subject to  I_t = I_(t-1) + r_t + o_t - d_t
            0 <= r_t <= 100,   0 <= o_t <= 40,   I_t >= 0
Python Production planning with overtime and stock

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Look at the plan: the factory builds stock early using cheap regular production so it can cover the months-4-and-5 peak without too much overtime. That is the economic trade-off: holding costs 2 per unit-month, while overtime costs 8 more than regular production, so it is worth storing a unit for up to four months to avoid overtime.

The same model can also be written in a cumulative form. The cumulative supply constraint I_0 + sum_(s<=t) (r_s + o_s) - sum_(s<=t) d_s >= 0 is equivalent to non-negative stock and avoids the need for balance variables, but then you lose direct access to stock levels, so the balance form is usually better.

Allowing backorders

If customers will wait, a shortage need not be forbidden: model backorders B_t >= 0 with a penalty cost. Split net inventory into two non-negative parts: stock on hand I_t^+ and backlog I_t^-, with I_t = I_t^+ - I_t^-. The objective charges holding on I^+ and a (larger) penalty on I^-. This is the standard "free variable split" from standard form applied to inventory.

Python Backorders with a penalty

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

With only 110 units per month capacity and demand totalling 720, the plan will use backlog at the peak when stock cannot cover demand. Raising the backorder penalty makes the optimizer prefer early stocking.

Rolling horizons and the end effect

A subtle modelling choice: what happens after the last period? If the model is free to end with zero stock, it will run stock down to zero because holding stock costs money and nothing needs it later. This is the end-of-horizon effect. Fixes include requiring a minimum final stock (a safety stock), valuing leftover stock, or solving a rolling horizon: plan 12 months, implement only the first month, then re-solve with updated data.

Other multi-period models

The same recipe (state variable + balance equation + period costs) covers:

  • Cash management: cash on hand carries over, with borrowing and investing choices.
  • Workforce planning: workers at month t = workers at t-1 + hired - fired.
  • Reservoir operation: water level = previous level + inflow - release.
  • Battery scheduling: charge level plus charging minus discharging.
flowchart LR
  I0["I(t-1)"] --> Bal{{"I(t) = I(t-1) + x(t) - d(t)"}}
  X["x(t) production"] --> Bal
  D["d(t) demand"] --> Bal
  Bal --> I1["I(t)"]
  I1 --> Next["next period"]

The state variable flows from period to period through the balance equation.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which equation correctly links periods in an inventory model?

    Ending stock = starting stock + production - demand.
  2. 2. Why does the plan produce early in the cheap months?

    When holding cost is lower than the extra cost of expensive production, building stock ahead of a peak lowers total cost.
  3. 3. How are backorders modelled linearly?

    Splitting a free variable into positive and negative parts keeps the model linear.
  4. 4. What is the end-of-horizon effect?

    Nothing after the last period values stock, so it is run down. Add a safety stock or a terminal value to avoid it.

Summary

  • Multi-period models add one set of variables per period and balance equations linking them.
  • Inventory balance: I_t = I_(t-1) + x_t - d_t; minimize production plus holding cost.
  • Overtime and capacity bounds create the trade-off between producing early and producing late.
  • Backorders split net inventory into stock and backlog with a penalty.
  • Watch the end-of-horizon effect; use safety stock or a rolling horizon.

Next: Modelling Tricks: Absolute Values, Min-Max and More