import numpy as np
import matplotlib.pyplot as plt
# Diberikan nilai
D = 100 # Permintaan tahunan
S = 50 # Biaya pemesanan per pesanan
H = 5 # Biaya penyimpanan per unit per tahun
p = 2000 # Tingkat produksi
d = 100 # Tingkat permintaan
# Menghitung EOQ
EOQ = np.sqrt((2 * D * S) / H)
print(f"EOQ: {EOQ:.2f} unit")
# Menghitung EPQ
EPQ = np.sqrt((2 * D * S) / (H * (1 - (d / p))))
print(f"EPQ: {EPQ:.2f} unit")
# Fungsi untuk menghitung total biaya
def total_cost(Q, D, S, H, d, p):
ordering_cost = (D / Q) * S
holding_cost = (Q / 2) * H * (1 - (d / p))
return ordering_cost + holding_cost
# Rentang jumlah untuk grafik
quantities = np.linspace(1, 2 * EPQ, 500)
# Menghitung total biaya untuk berbagai jumlah
total_costs = [total_cost(Q, D, S, H, d, p) for Q in quantities]
# Membuat grafik
plt.figure(figsize=(10, 6))
plt.plot(quantities, total_costs, label='Total Cost', color='b')
plt.axvline(EOQ, color='r', linestyle='--', label=f'EOQ = {EOQ:.2f} units')
plt.axvline(EPQ, color='g', linestyle='--', label=f'EPQ = {EPQ:.2f} units')
plt.xlabel('Order/Production Quantity (units)')
plt.ylabel('Total Cost (currency)')
plt.title('Total Cost vs Order/Production Quantity')
plt.legend()
plt.grid(True)
plt.show()
import matplotlib.pyplot as plt
# Diberikan nilai
D = 100 # Permintaan tahunan
S = 50 # Biaya pemesanan per pesanan
H = 5 # Biaya penyimpanan per unit per tahun
p = 2000 # Tingkat produksi
d = 100 # Tingkat permintaan
# Menghitung EOQ
EOQ = np.sqrt((2 * D * S) / H)
print(f"EOQ: {EOQ:.2f} unit")
# Menghitung EPQ
EPQ = np.sqrt((2 * D * S) / (H * (1 - (d / p))))
print(f"EPQ: {EPQ:.2f} unit")
# Fungsi untuk menghitung total biaya
def total_cost(Q, D, S, H, d, p):
ordering_cost = (D / Q) * S
holding_cost = (Q / 2) * H * (1 - (d / p))
return ordering_cost + holding_cost
# Rentang jumlah untuk grafik
quantities = np.linspace(1, 2 * EPQ, 500)
# Menghitung total biaya untuk berbagai jumlah
total_costs = [total_cost(Q, D, S, H, d, p) for Q in quantities]
# Membuat grafik
plt.figure(figsize=(10, 6))
plt.plot(quantities, total_costs, label='Total Cost', color='b')
plt.axvline(EOQ, color='r', linestyle='--', label=f'EOQ = {EOQ:.2f} units')
plt.axvline(EPQ, color='g', linestyle='--', label=f'EPQ = {EPQ:.2f} units')
plt.xlabel('Order/Production Quantity (units)')
plt.ylabel('Total Cost (currency)')
plt.title('Total Cost vs Order/Production Quantity')
plt.legend()
plt.grid(True)
plt.show()