Supply Chain Lab RL Inventory Agent Lab Home
AI & Machine Learning

RL Inventory Agent: Watch It Learn

A Q-learning agent manages a single product under Poisson demand. Press play and literally watch it learn: the Q-table heat-map sharpens, the cost curve falls toward the tuned (s,S) benchmark, and the ordering policy takes shape state by state.

How to use it

The learning room

Run controls

The world

Changing the world resets the agent - it must learn the new economics from scratch. Benchmarks retune automatically.

–
Agent cost / period
–
Tuned (s,S) benchmark
–
Gap to benchmark

Q-table: rows are inventory states 0–20, columns the four order sizes. Darker navy = better action value; the red ring is the agent's current state. Watch columns crystallise as it learns.

Cost per period, episode by episode (red). Dashed teal = tuned (s,S) policy; dashed grey = naive fixed order. Learning shows as the red curve settling between them - then hugging the teal line.

The implied policy: for each inventory level, the order size the agent currently thinks best. A learned (s,S)-like shape is a downward staircase - big orders when empty, nothing when full.

Quiz: inventory is ? units. What will the agent order?

Try these experiments

  1. Set ε to 0 early (first ~50 episodes) and watch the agent get stuck on a mediocre policy it never explores its way out of.
  2. Raise the fixed order cost K and watch the learned policy widen its gap - order rarely, but big, exactly like (s,S) says.
  3. Find ε/α settings that get within 10% of the benchmark inside 300 episodes - then argue why the same tension (explore vs exploit) appears in every supply chain pilot.

About this tool

The concept

Reinforcement learning improves a policy from experienced rewards alone - no demand forecast, no formula, just trial, error and feedback.

How it works

Tabular Q-learning: Q(s,a) ← Q + α(r + γ·maxQ(s′) − Q). ε-greedy exploration; states are inventory levels, actions are order sizes.

The benchmark

Inventory theory says an (s,S) policy is optimal here. The agent never hears that - yet its learned policy converges toward the same shape.