-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.6 Bearing Reliability.py
144 lines (121 loc) · 3.5 KB
/
2.6 Bearing Reliability.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import math
import random
import matplotlib.pyplot as plt
life = [1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900]
probability = [0.10, .14, .24, .14, .12, .10, .06, .05, .03, 0.02]
probability = [int(i * 100) for i in probability]
c_probability = [probability[0]]
i = 1
while i < len(probability):
c_probability.append(c_probability[i - 1] + probability[i])
i += 1
delay = [4, 6, 8]
delay_probability = [0.3, 0.6, 0.1]
delay_probability = [int(i * 10) for i in delay_probability]
c_delay_pro = [delay_probability[0]]
i = 1
while i < len(delay_probability):
c_delay_pro.append(c_delay_pro[i - 1] + delay_probability[i])
i += 1
def clock():
x = random.randint(1, 100)
if x <= c_probability[0]:
return life[0]
elif x <= c_probability[1]:
return life[1]
elif x <= c_probability[2]:
return life[2]
elif x <= c_probability[3]:
return life[3]
elif x <= c_probability[4]:
return life[4]
elif x <= c_probability[5]:
return life[5]
elif x <= c_probability[6]:
return life[6]
elif x <= c_probability[7]:
return life[7]
elif x <= c_probability[8]:
return life[8]
else:
return life[9]
def late():
x = random.randint(1, 10)
if x <= c_delay_pro[0]:
return delay[0]
elif x <= c_delay_pro[1]:
return delay[1]
else:
return delay[2]
bearing1_life = []
bearing2_life = []
bearing3_life = []
lf = 0
while lf < 20000:
i = clock()
lf += i
bearing1_life.append(i)
lf = 0
while lf < 20000:
i = clock()
lf += i
bearing2_life.append(i)
lf = 0
while lf < 20000:
i = clock()
lf += i
bearing3_life.append(i)
print(bearing1_life)
print(bearing2_life)
print(bearing3_life)
bearing_life_count = [len(bearing1_life), len(bearing2_life), len(bearing3_life)]
maxlen = max(bearing_life_count)
two_down = 0
three_down = 0
try:
for i in range(maxlen):
if (bearing1_life[i] == bearing2_life[i] == bearing3_life[i]):
three_down += 1
except:
pass
try:
for i in range(maxlen):
if (bearing1_life[i] == bearing2_life[i] or bearing2_life[i] == bearing3_life[i] or bearing3_life[i] ==
bearing1_life[i]):
two_down += 1
except:
pass
print(two_down , three_down)
total_cost = 0
total_bearing_cost = 0
total_delay_cost = 0
total_repair_cost = 0
num_of_bearing = sum(bearing_life_count)
total_bearing_cost = num_of_bearing * 20
mechanic_delay = []
num_of_mechanic_call = num_of_bearing-two_down-(three_down*2)
for i in range(num_of_mechanic_call):
x = late()
mechanic_delay.append(x)
total_delay_cost = sum(mechanic_delay)*5
time_needed = (num_of_bearing*20) - (two_down*10) - (three_down*20)
total_repair_cost = (time_needed/60) * 25
total_cost = total_bearing_cost+total_delay_cost+total_repair_cost
total_cost
bearing_life = []
mechanic_delay_2 = []
lf = 0
while lf<20000:
life_of_bearings = [clock(),clock(),clock()]
x = min(life_of_bearings)
y = late()
bearing_life.append(x)
mechanic_delay_2.append(y)
lf+=x
total_bearing_cost = len(bearing_life)*20
total_delay_cost = sum(mechanic_delay_2)*5
total_repair_cost = ((len(bearing_life)*40)/60)*25
total_cost_2 = total_bearing_cost+total_delay_cost+total_repair_cost
print("Previous Cost : ",total_cost)
print("New Cost : ",total_cost_2)
print("Saves : ",total_cost-total_cost_2)