HiveBrain v1.2.0
Get Started
← Back to all entries
patternpythonMinor

Inventory simulation using Pandas DataFrame

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
simulationpandasinventoryusingdataframe

Problem

I've been learning Python like for a year and started learning a little about pandas DataFrame. I made this little program to practice all the concepts and would like to hear your suggestions for improvement.

GOAL

This program should plot how the inventory levels behave according some initials conditions: number of periods, demand distribution, lead time distribution and the chosen control policy (see types of policy).

DEFINITIONS AND FORMULAS

inventory position = on hand inventory + inventory on order

lead time = the amount of time between the placing of an order and the receipt of the goods ordered.

NOTATION

s reorder point, Q order quantity, R review period, S order-up-to level

TYPES OF POLICY

We use four different base policy types:

  • (s, Q)-policy. Whenever the inventory position reaches the reorder point s or drops below this point, an order of size Q is triggered.



  • (s, S)-policy. Under this policy, the size of the order – triggered whenever the inventory position reaches or drops below the reorder point s – equals the difference between the order-up-to level S and the current inventory position.



  • (R, S)-policy. The review period R indicates the length of the interval in-between two reviews. At these points of time, the inventory position is observed and the difference between the inventory position and the order-up-to level S is ordered.



  • (R, s, S)-policy. Every R intervals the inventory position is checked. An order is triggered only if the inventory position has reached or dropped below the reorder point s. Then the order size equals the difference between the order-up-to level S and the current inventory position.



```
import matplotlib.pyplot as plt
import numpy as np
from pandas import DataFrame

# The distribution factory
def make_distribution(function,*pars):
def distribution():
return function(*pars)
return distribution

def make_data(periods=52,
initial_inventory = 10,
demand_dist =

Solution

Nice piece of code. Are you calculating safety stock based on the std dev of the demand distribution? Couldn't find in the code - sorry if it is there.

If not not, that would be the natural next step.

The second step would be a simulation of inventory levels based on the policy you created in step one and two.

But you can go further and calculate the lost sales - that should involve bayesian calculations - and, given the cost of holding inventory, the money the company is saving by following your suggested policy:
  • reduced avg inventory (free working capital: one time only)
  • increased margin by selling more (every period)



Do a basic NPV calculation and you have a very solid number to show to any client.

Context

StackExchange Code Review Q#27874, answer score: 3

Revisions (0)

No revisions yet.