Skip to content

peng168fly/warehouse-inventory-simulation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Warehouse Inventory Simulation with SimPy

Overview

This project simulates a single-product warehouse inventory system using the SimPy discrete-event simulation library. It models customer arrivals, demand, inventory replenishment based on an (s, S) policy, variable supplier lead times, and associated costs (ordering, holding, shortage).

The simulation also incorporates a basic dynamic inventory policy mechanism, which adjusts the reorder point (s) and order-up-to level (S) based on recent demand trends compared to a baseline average.

Purpose

The primary goal is to demonstrate:

  1. How to model a common inventory system using discrete-event simulation (SimPy).
  2. The implementation and behavior of a standard (s, S) inventory replenishment policy.
  3. The concept and potential benefits of a simple adaptive inventory policy that reacts to sustained changes in demand.
  4. The trade-offs between holding costs, ordering costs, and shortage costs in determining inventory levels and service levels.

Concepts Demonstrated

  • Discrete-Event Simulation: Using SimPy to model events occurring over time (customer arrivals, order placements, order arrivals).
  • (s, S) Inventory Policy: Triggering orders when inventory drops to level 's' and ordering enough to bring the potential inventory up to level 'S'.
  • Dynamic Policy Adjustment: Temporarily modifying 's' and 'S' based on a simple moving average of recent demand compared to a baseline.
  • Stochastic Processes: Modeling random customer arrivals (Poisson process via exponential interarrival times), variable customer demand (uniform distribution), and variable supplier lead times (log-normal distribution).
  • Cost Analysis: Calculating total inventory costs based on ordering, holding (time-weighted average inventory), and stockout penalties.
  • Performance Metrics: Calculating service level (fulfilled demand / total demand) and number of stockout events.

Features

  • Simulates customer arrivals following a Poisson process.
  • Models variable demand per customer using a uniform distribution.
  • Implements an (s, S) inventory replenishment policy.
  • Includes log-normally distributed supplier lead times.
  • Features a basic dynamic policy that adjusts RP/TS based on a moving average of demand.
  • Calculates and reports key performance indicators (KPIs):
    • Service Level (%)
    • Total Units Short
    • Stockout Events
    • Time-Weighted Average Inventory
    • Ordering Costs
    • Holding Costs
    • Shortage Costs
    • Total Inventory Costs
  • Includes a simulation warm-up period to allow the system to reach a more stable state before collecting primary statistics.
  • Outputs detailed event logs during the simulation run.

How to Run

Prerequisites

  • Python 3.x
  • pip (Python package installer)

Installation

  1. Clone this repository:
    git clone <your-repo-url>
    cd <repository-directory>
  2. Install the required packages:
    pip install -r requirements.txt

Execution

Run the simulation script from the command line:

python warehouse_simulation.py

The script will print simulation events to the console and output summary statistics and cost analysis at the end.

Parameters

Key parameters can be adjusted directly in the warehouse_simulation.py script:

  • SIM_DURATION: Total length of the simulation (days).
  • WARM_UP_PERIOD: Initial period excluded from final metrics (days).
  • INITIAL_STOCK: Starting inventory level.
  • BASE_REORDER_POINT: Base inventory level 's' to trigger reorder.
  • BASE_TARGET_STOCK: Base order-up-to level 'S'.
  • MEAN_LEAD_TIME, LEAD_TIME_STD_DEV: Parameters for supplier lead time (log-normal).
  • CUSTOMER_ARRIVAL_RATE: Average customers per day.
  • DEMAND_MIN, DEMAND_MAX: Range of units demanded per customer.
  • ORDER_COST: Fixed cost per order placed.
  • HOLDING_COST_PER_UNIT_DAY: Cost to hold one unit in inventory for one day.
  • STOCKOUT_COST_PER_UNIT: Penalty cost for each unit of demand that cannot be met.
  • DEMAND_AVG_WINDOW: Lookback window (days) for calculating recent average demand for the dynamic policy.
  • DYNAMIC_THRESHOLD_MULTIPLIER: Factor above baseline average demand needed to trigger the dynamic policy adjustment.
  • DYNAMIC_REORDER_POINT_FACTOR, DYNAMIC_TARGET_STOCK_FACTOR: Multipliers applied to base RP/TS when the dynamic policy is active.

Example Scenario Justification

The default parameters, particularly the high shortage cost ($10/unit) relative to the holding cost ($0.05/unit/day), and the resulting high optimal inventory levels (RP=600, TS=800), can be considered plausible in scenarios where stockouts are extremely costly. For example:

  • Critical Spare Parts: Where a stockout leads to expensive downtime in manufacturing or operations.
  • Specialized Medical Supplies: Where unavailability impacts patient care significantly.

In these cases, maintaining a high service level, even at increased holding cost, can be the most cost-effective strategy overall, which this simulation demonstrates.

Limitations & Future Work

This simulation implements a basic dynamic inventory policy as an introductory adaptive mechanism. It successfully shows the concept and potential benefits of adapting inventory levels based on recent demand trends compared to a purely static policy.

However, this approach has limitations:

  • Reactive: Relies on a Simple Moving Average (SMA) of past demand, lagging behind trends.
  • Simple Trigger: Activation based only on the average demand level, ignoring volatility changes.
  • Fixed Adjustments: Uses fixed multipliers for policy changes, which might not be optimal.
  • Potential Oscillation: Can switch on/off frequently if demand hovers near the threshold.
  • Ignores External Factors: Doesn't use potentially relevant info like promotions, seasonality, or supplier reliability changes.

Potential Future Enhancements:

  • ML Forecasting: Replace the SMA with more sophisticated time series forecasting models (e.g., SARIMA, Prophet, LSTM) to predict future demand proactively.
  • Advanced Triggers: Incorporate demand volatility forecasts or forecast error tracking into the dynamic policy trigger.
  • Optimized Adjustments: Use Reinforcement Learning (RL) or simulation-based optimization to determine the magnitude of policy adjustments dynamically based on the system state and cost function.
  • Feature Engineering: Incorporate external factors (promotions, holidays, lead time forecasts) into ML models for more context-aware predictions and policy decisions.
  • Multi-Product Simulation: Extend the model to handle multiple products with potential shared resources or correlations.

License

(Optional - Consider adding an open-source license, e.g., MIT License)

MIT License

Copyright (c) [Year] [Your Name/Organization]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%