MSc Data Science / Dissertation
Reinforcement Learning in Supply Chain Management
–
MSc dissertation investigating whether a Deep Q-Network agent can learn to adapt supplier allocation, delivery routing and safety stock decisions in a simulated supply chain exposed to disruptions.
Context
Summary
This research tests if reinforcement learning (RL) can make adaptive decisions in a supply chain with disruptions. A Deep Q-Network (DQN) agent chose a supplier allocation, a delivery route and a safety stock each simulated day. I compared it with fixed, random and rule-based policies.
- The DQN had the highest fill rate and the lowest backlog in the reported scenario. The rule-based policy had a better reward.
- On an unseen scenario, the DQN did much better than the fixed and random policies, but not as well as the rule-based policy.
- The agent showed signs of reward hacking and changed actions frequently. Reward design is the main weakness.
- RL can help with specific supply chain decisions. It needs optimisation, classical machine learning, rule-based methods, explainability and human oversight alongside it.
Context
Background and Motivation
I have three years of experience in digital solutions for logistics. My company develops logistics control tower software with digital twin capabilities. This project explores if RL can add useful decision support to that type of software.
Adaptive decisions matter most in complex, disruption-prone industries such as construction, defence and manufacturing. This project is a research proof of concept, not a deployed product.
Context
Problem Statement
Supply chains are difficult for RL:
- Delayed rewards. The effect of a decision can appear days or weeks later.
- Different timescales. Processes run hourly, daily and weekly.
- Limited data. Real disruptions are rare, so historical data has few examples to learn from.
- Interpretability. Deep RL policies are difficult to explain and validate.
This project addresses the data problem with simulation. The other challenges remain open.
Can a simplified supply chain simulation demonstrate that reinforcement learning can support supply chain management decisions and adapt to operational disruptions?
Implementation
Data
No external dataset was used. A stochastic simulation generated all training and evaluation data. Simulation gives the agent many repeatable disruptions, which real records cannot supply.
Theory
Methodology
Supply chain simulation

The single-echelon supply chain: stochastic demand, two suppliers, two delivery routes and a warehouse, with the equations for each step.
Open full sizeOne episode is 365 days. Each day, the agent selects one of 18 actions: a supplier split of 0.2, 0.5 or 0.8, Route A or B, and a safety stock of 20, 29 or 115 units. The agent cannot see supplier capacity or the demand noise level. It must detect disruptions from their effects.
Disruption scenarios
Each disruption lasts 90 days and starts on a random day.
Table 1. Disruption scenarios. Scenarios 0 to 7 were used in training. Scenario 8 was used only for evaluation.
| Scenario | Disruption | Use |
|---|---|---|
| 0 | None (, , no traffic) | Training |
| 1 | Supplier A capacity: from 1 to 0.5 | Training |
| 2 | Supplier B capacity: from 1 to 0.5 | Training |
| 3 | Route A traffic: from 0 to 5 | Training |
| 4 | Demand noise: from 10 to 40 | Training |
| 5 | Supplier A capacity + Route A traffic | Training |
| 6 | Supplier A capacity + demand noise | Training |
| 7 | Route A traffic + demand noise | Training |
| 8 | Supplier A capacity + Route A traffic + demand noise | Unseen |
Reinforcement learning architecture

The digital twin architecture: the DQN agent monitors the simulation, selects actions and learns from stored experience, in a MAPE-K loop.
Open full sizeThe agent trained for 2,500 episodes. Each episode used a random scenario from 0 to 7: the no-disruption baseline and seven disruption scenarios. I then compared the agent with three policies on all scenarios, including the unseen scenario 8:
- Fixed: always the same action. It sets a lower bound.
- Random: a random action each day.
- Rule-based: reads the true disruption parameters and applies the correct response. It sets the target to beat.
Theory
Theoretical Foundations
Markov decision process
The agent and the simulation interact in a loop. The agent observes the state: the current supply chain data. It selects an action. The simulation moves forward one day and returns a reward and the next state. The agent learns which actions give the highest total reward over time.
Reward function
The reward function defines the objective used to train the agent:
Bellman equation
The value of an action is its immediate reward plus the discounted value of the best next action:
Deep Q-Network
A DQN uses a neural network to estimate the value of each action in the current state. The agent stores its experience from the simulation and uses it to improve these estimates. During training, the network updates its weights to make its estimates more accurate. A second target network, which updates less often, keeps learning stable. The agent then selects the action with the highest estimated future reward.
Implementation
Technical Implementation
Python implements the supply chain simulation. Gymnasium provides the RL environment interface. Stable-Baselines3 implements and trains the DQN agent.
Results
Results
Learning curve

The DQN's mean episode reward during training under disruption scenario 5, with fixed and rule-based baselines.
Open full sizePolicy performance comparison
Table 2. Policy performance under disruption scenario 5, one 365-day episode per policy. Inventory and backlog are in units.
| Policy | Average fill rate | Average NSAmp | Average inventory | Average backlog | Average reward | Total reward |
|---|---|---|---|---|---|---|
| Fixed | 0.256 | 8.18 | 8.1 | 555.5 | −269.29 | −98,291.4 |
| Random | 0.454 | 25.61 | 31.4 | 153.6 | −85.70 | −31,279.1 |
| Rule-based | 0.540 | 11.36 | 20.5 | 65.5 | −3.48 | −1,270.2 |
| DQN | 0.719 | 32.09 | 54.2 | 26.7 | −11.08 | −4,045.3 |
The DQN had the highest fill rate and the lowest backlog, but the rule-based policy had a better average reward.
Policy behaviour over time

Daily fill rate, NSAmp, inventory, backlog, reward and cumulative reward for all four policies under scenario 5, with the disruption periods shaded.
Open full sizeResults
Discussion and Limitations

Daily actions of the rule-based policy and the DQN under scenario 5: the DQN changes action much more often.
Open full size- Reward hacking. The DQN showed signs of reward hacking and frequent action switching. The reward function needs more work, for example a penalty for switching.
- Interpretability. A deep neural network does not explain why the agent selects a particular action.
- Simulation limitations. The single-echelon supply chain is a simplified proof of concept. Its results do not show performance in a real supply chain.
- Future research. Targeted supply chain applications, multi-agent RL where appropriate, alternative algorithms such as PPO, explainable AI and human oversight.
Context
Lessons Learned
RL can be useful for specific supply chain decisions, but one approach is unlikely to manage an entire supply chain. The better approach is to combine RL with classical machine learning, optimisation and rule-based methods, each where it fits. When deep learning makes operational decisions, explainability and human oversight are essential. For logistics control tower and digital twin software, I see the opportunity in targeted, explainable decision support, not a fully autonomous controller.
Context
Video Explanation
Interactive
Interactive Application
Supply Chain Optimisation App
This app simulates one manufacturer under normal conditions. It finds the safety stock, capacity and feedback setting that give the lowest total cost. The fill rate must meet a target.
The app shows four effects:
- The trade-off between inventory variance and order variance.
- Safety stock as a buffer against demand and lead-time uncertainty.
- Capacity as a buffer against order variability.
- The effect of the order cadence on production stability.
Dynamics
Demand and lead times are random. Each day, the simulation does these steps in this sequence:
- The manufacturer receives orders that arrive on that day.
- Demand occurs.
- The manufacturer supplies today's demand first, then any backlog.
- On a review day, the manufacturer places a new order.
Orders can arrive out of sequence. The production of each order is spread evenly over one review period.
Order policy
The manufacturer uses the Proportional Order Up-To (POUT) policy:
- is the mean demand for one review period.
- is net stock (inventory minus backlog).
- is the sum of orders placed but not received.
- is the proportional feedback controller.
controls how fast the manufacturer corrects errors:
- A small keeps inventory stable but makes orders unstable.
- A large keeps orders stable but makes inventory unstable.
- gives the standard Order Up-To policy.
- makes the system unstable.
Theory gives . The simulation agrees with this result.
Cost model
Table 3. Daily cost components.
| Cost | Equation |
|---|---|
| Holding | |
| Backlog | |
| Capacity | |
| Overtime |
Optimal safety stock
The cost-only optimum is the quantile of the net stock shortfall. If this value does not meet the fill-rate target, the app increases the safety stock until the target is met.
The app also shows King's formula as a reference:
King's formula uses the cycle service level, which is the probability of no stockout in a cycle. The app uses the fill rate, which is the fraction of demand supplied from stock. Thus, King's formula usually gives a higher value.
With a monthly cadence, the optimal safety stock can be negative. Cycle stock supplies most of the demand, so a small planned shortage at the end of each cycle costs less than extra stock.
Optimal capacity
One more unit of capacity costs each day. It saves on each day with overtime. Thus, the optimal capacity is the quantile of daily production:
- If , the optimal capacity is less than the mean production.
- If , the optimal capacity is more than the mean production.
Inputs
Table 4. App inputs and their ranges.
| Input | Range |
|---|---|
| Mean daily demand () | 10–100 |
| Demand standard deviation () | 0.1–0.5 × |
| Mean lead time () | 5–25 days |
| Lead time standard deviation () | 0.2–0.4 × |
| Target fill rate | 0.75–0.99 |
| Holding cost (), backlog cost () | 1–10 |
| Capacity cost (), overtime cost () | 1–10, with |
Cadence
The cadence sets how often the manufacturer orders: daily (), weekly () or monthly (). A longer cadence makes daily production more stable, so the manufacturer needs less spare capacity. But a longer cadence also increases cycle stock, which increases holding cost.
Optimisation method
The optimiser finds the safety stock (), capacity () and with the lowest expected cost over 365 days:
- For each from 0.1 to 10, it simulates 30 replications.
- For each , it calculates the optimal capacity and safety stock directly from the results.
- It selects the best in the range 1 to 10.
- It refines that with a bounded scalar search.
Orders do not depend on safety stock. Thus, one simulation for each is sufficient. All parameter sets use the same random numbers, so the comparison is fair. One optimisation takes approximately one second.
How to use the app
- Set the inputs.
- Select the cadence.
- Push Optimise. The app puts the optimal values into the parameter boxes and shows the cost and fill rate.
- Examine the charts of Bullwhip, inventory variance and cost against .
- To test different values, push Edit and change the parameters.
- Push Run to simulate one year with the current parameters.
- Compare the cost with the optimum.
- Download the results as a CSV file.
Tools
Implementation
Source Code
Context