-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinventory.py
More file actions
59 lines (48 loc) · 1.89 KB
/
Copy pathinventory.py
File metadata and controls
59 lines (48 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import random
# Initialize a counter for the number of simulations
m = 0
# Loop to perform simulations until m reaches 5
while m != 5:
# Get user input for reorder point and reorder quantity
reorder_point = int(input("\n Enter reorder point: "))
reorder_quantity = int(input("\n Enter reorder quantity: "))
# Initialize variables for inventory and costs
units = 0
equivalent_stock = 0
day = 1
due_day = 0
demand = 0
total_cost = 0
current_stock = 115
# Loop for each day in the simulation period (180 days)
while day <= 180:
# Check if an order is due on the current day
if due_day == day:
# Increase inventory and reset units ordered
current_stock += reorder_quantity
units = 0
# Generate random demand for the day
demand = random.randint(0, 99)
# Calculate cost based on demand and inventory level
if demand <= current_stock:
current_stock -= demand
total_cost += current_stock * 0.75
else:
total_cost += (demand - current_stock) * 18
current_stock = 0
# Calculate equivalent stock (inventory + ordered units)
equivalent_stock = current_stock + units
# Check if inventory is below reorder point
if equivalent_stock <= reorder_point:
# Place an order and incur ordering cost
units = reorder_quantity
total_cost += 75
due_day = day + 3 # Set the due day for the ordered units
# Move to the next day
day += 1
# Print simulation results for the current reorder point and reorder quantity
print("\n Reorder point:", reorder_point)
print(" Reorder Quantity:", reorder_quantity)
print(" Total cost is:", total_cost)
# Increment the simulation counter
m += 1