Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Simulating Inventory Levels Over Time | Inventory Management and Demand Forecasting
Python for Supply Chain

bookSimulating Inventory Levels Over Time

Deslize para mostrar o menu

Tracking inventory over time is crucial for effective supply chain management. By simulating how inventory levels change daily—due to customer demand and scheduled replenishments—you gain valuable insight into potential stockouts, overstock situations, and the timing of orders. This allows you to make informed decisions about when to reorder products, how much safety stock to keep, and how to optimize storage space.

123456789101112131415161718192021
# Simulate daily inventory for 30 days initial_stock = 100 daily_demand = 7 replenishment_quantity = 50 replenishment_interval = 7 # days between replenishments days = 30 inventory = [] current_stock = initial_stock for day in range(1, days + 1): # Subtract daily demand current_stock -= daily_demand # Replenish if it's a replenishment day if day % replenishment_interval == 0: current_stock += replenishment_quantity # Prevent negative inventory current_stock = max(current_stock, 0) inventory.append(current_stock) print(inventory)
copy

The simulation logic follows a simple but powerful pattern. You start with an initial stock value, then use a loop to represent each day in your simulation period. On each day, you subtract the expected daily demand from the current inventory. If the day matches the replenishment schedule (for example, every 7 days), you add the replenishment quantity to the current stock. At each step, you ensure the inventory does not fall below zero, which reflects a real-world scenario where you cannot ship more than you have in stock. By appending the current inventory value to a list each day, you build a complete record of inventory levels throughout the simulation period.

12345678910
import matplotlib.pyplot as plt days = list(range(1, 31)) plt.figure(figsize=(10,5)) plt.plot(days, inventory, marker='o', linestyle='-', color='b') plt.title('Simulated Inventory Levels Over 30 Days') plt.xlabel('Day') plt.ylabel('Inventory Level') plt.grid(True) plt.show()
copy

1. What can inventory simulations help supply chain managers anticipate?

2. How does replenishment frequency affect inventory levels?

3. Fill in the blank: To append a value to a list in Python, use list.____(value).

question mark

What can inventory simulations help supply chain managers anticipate?

Select the correct answer

question mark

How does replenishment frequency affect inventory levels?

Select the correct answer

question-icon

Fill in the blank: To append a value to a list in Python, use list.____(value).

(value)

Clique ou arraste solte itens e preencha os espaços

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Seção 2. Capítulo 2
some-alt