[SCM] MAPE and Profit Simulation Based on Newsboy Model

In sales forecasting, can improving forecast accuracy (1-MAPE) increase profits?

This article attempts to perform a random simulation through the classic newsboy model to observe the relationship between MAPE and profit.

1. Model setting

                                                    Newsvendor Problem -- 30 Days

Purchase cost

0.7

Selling price

1

Salvage value

0

Demand parameter μ

100

Amount ordered each day q

[80, 90, 100, 110, 120, 130]

Demand parameter ? σ

taking values from 1 to 30 with an increment of 0.1

Second, the simulation code

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

#CONST
rounds = 30
c = 0.7   # purchase cost
s = 1     # selling price
u = 0     # salvage value
demand_mu = 100
color = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'w']
qs = [80]

# Demand
col = []
for demand_sigma in np.arange(1,30,0.1):
    row = [] 
    for _ in range(rounds):
        demand = max(round(np.random.normal(demand_mu, demand_sigma),0),0)
        while demand == 0:
            demand = max(round(np.random.normal(demand_mu, demand_sigma),0),0)
        row.append(demand)
    col.append(row)
col = np.array(col)
df_demand = pd.DataFrame(col, columns=[ i+1 for i in range(30)])

# newsvendor model 
fig = plt.figure(num=1, figsize=(10, 8),dpi=80) 
i = 1
for q in [80, 90, 100, 110, 120, 130]:
    df_sales_revenue = df_demand.applymap(lambda x: s * min(x, q))
    df_salvage_revenue = df_demand.applymap(lambda x: u * max(0, q-x))
    df_profit = df_sales_revenue + df_salvage_revenue - c * q
    df_mape = df_demand.applymap(lambda x: abs(x - q)/x)
    plt.subplot(2, 3, i)
    plt.scatter(df_profit.mean(axis=1), df_mape.mean(axis=1), c=color[i-1])
    plt.title('q = '+ str(q), size=26)
    plt.xlabel('Profit', size=12)
    plt.ylabel('MAPE',  size=12)
    i += 1

plt.legend(loc='best')

fig.tight_layout()#调整整体空白
plt.subplots_adjust(wspace =0.3, hspace =0.3)#调整子图间距
plt.savefig('./ppt素材/newsvendor_simulation.jpg') 

Third, the simulation results

Conclusion: At each order point, Profit increases with the decrease of MAPE and tends to stabilize.

Published 26 original articles · won 13 · views 7292

Guess you like

Origin blog.csdn.net/original_recipe/article/details/100145622