-
Notifications
You must be signed in to change notification settings - Fork 0
/
cost_distribution.py
62 lines (48 loc) · 1.77 KB
/
cost_distribution.py
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
60
61
62
from typing import List
import matplotlib.pyplot as plt
import numpy as np
from gantry_grid import Gantry
def cost_plot(costs: List[int], x_min, x_max) -> None:
"""
Plots a histogram of the distribution of the costs for an order given a
list of the cost for the order.
Args:
costs: The list of the build costs for the order.
x_min (int): Where to start the plot on the x-axis.
x_max (int): Where to end the plot on the x-axis.
"""
min = np.min(costs)
mean = np.round(np.mean(costs), 3)
median = np.median(costs)
max = np.max(costs)
std = np.round(np.std(costs), 3)
bins = [i + .25 * j for i in range(x_min, x_max) for j in [-1, 1]]
fig = plt.figure()
ax = fig.add_subplot(111)
plt.hist(costs, bins=bins, color='navy')
plt.ylabel("Frequency")
plt.xlabel("Build Pallet Cost")
plt.text(.89, .95,
"Min: " + str(min) + '\n' +
"Mean: " + str(mean) + '\n' +
"Median: " + str(median) + '\n' +
"Max: " + str(max) + '\n' +
"SD: " + str(std),
horizontalalignment='left',
verticalalignment='top',
transform=ax.transAxes)
plt.show()
costs = []
build_index_num = 0
for x in range(100):
gantry = Gantry()
gantry.set_base_case()
gantry.set_order(50)
gantry.fill_by_product()
for pallet_num in range(len(gantry.order.order_list)):
build_cost = gantry.build_spot_cost(pallet_num,
gantry.build_indices[build_index_num])
costs.append(build_cost)
# switch to the other build location in the base case
build_index_num = 1 - build_index_num
cost_plot(costs, 10, 55)