-
Notifications
You must be signed in to change notification settings - Fork 2
/
reliability_problem_new_policy.py
127 lines (94 loc) · 4.16 KB
/
reliability_problem_new_policy.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
# Bearing Life(Hours)
bearing_life = [1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900]
# Bearing Life(Hours) - Probability
bearing_probabilities = [0.10, 0.14, 0.24, 0.14, 0.12, 0.10, 0.06, 0.05, 0.03, 0.02]
# calculate cumulative probabilities
cumulative_probabilities = [bearing_probabilities[0]]
for i in range(1, len(bearing_probabilities)):
cumulative_probabilities.append(cumulative_probabilities[i-1] + bearing_probabilities[i])
# generate random digit assignments
bearing_random_digits = []
count = 0
for i in range(len(bearing_probabilities)):
bearing_random_digits.append([])
for j in range(int(bearing_probabilities[i]*100)):
bearing_random_digits[i].append(count)
count += 1
# for i in range(len(cumulative_probabilities)):
# print(f"{cumulative_probabilities[i]:.2f}")
# delay Life(minutes)
delay_life = [4 , 6 , 8]
# delay Life(minutes) - Probability
delay_probabilities = [0.3 , 0.6 , 0.1]
# calculate cumulative probabilities
cumulative_probabilities = [delay_probabilities[0]]
for i in range(1, len(delay_probabilities)):
cumulative_probabilities.append(cumulative_probabilities[i-1] + delay_probabilities[i])
# generate random digit assignments
delay_random_digits = []
count = 0
for i in range(len(delay_probabilities)):
delay_random_digits.append([])
for j in range(int(delay_probabilities[i]*10)):
delay_random_digits[i].append(count)
count += 1
# for i in range(len(cumulative_probabilities)):
# print(f"{cumulative_probabilities[i]:.2f}")
# delay_random_digits
import random
# for bearing 1
total_hours_of_operation = 30000
total_clock_hour = 0
total_delay_minutes = 0
total_change = 0 # how many bearing have to change
while total_hours_of_operation > total_clock_hour:
total_change += 1
bearing_random_num_1 = random.randint(0 , 99)
bearing_random_num_2 = random.randint(0 , 99)
bearing_random_num_3 = random.randint(0 , 99)
delay_random_num = random.randint(0 , 9)
current_clock = 0
current_delay = 0
# find bearing 1 clock from generated random num
for i in range(len(bearing_random_digits)):
if bearing_random_num_1 in bearing_random_digits[i]:
current_clock = bearing_life[i]
break
# find bearing 2 clock from generated random num
for i in range(len(bearing_random_digits)):
if bearing_random_num_2 in bearing_random_digits[i]:
current_clock = min(bearing_life[i] , current_clock)
break
# find bearing 3 clock from generated random num
for i in range(len(bearing_random_digits)):
if bearing_random_num_3 in bearing_random_digits[i]:
current_clock = min(bearing_life[i] , current_clock)
break
total_clock_hour += current_clock
# find delay from generated random num
for i in range(len(delay_random_digits)):
if delay_random_num in delay_random_digits[i]:
current_delay = delay_life[j]
break
total_delay_minutes += current_delay
# 20 minutes to change one bearing
# Downtime of the machining center costs Rs. 5 per minute
# direct on job cost of the repairman is Rs. 25 per hour
# cost of a bearing is Rs. 20.
three_bearing_change_time_minutes = 40
cost_of_downtime_per_minutes = 5
cost_of_repairman_per_hour = 25
cost_of_one_bearing = 20
print("Total repairman delay time =" , total_delay_minutes , "minutes")
print("Time spent in bearing replacement =", total_change*three_bearing_change_time_minutes , "minutes")
print("Total downtime =" , total_delay_minutes+(total_change*three_bearing_change_time_minutes) , "minutes")
cost_of_downtime = cost_of_downtime_per_minutes*(total_delay_minutes+(total_change*three_bearing_change_time_minutes))
print("Cost of downtime = Rs.", cost_of_downtime)
cost_of_repairman = total_change*three_bearing_change_time_minutes*cost_of_repairman_per_hour/60
print("Cost of repairman = Rs.", cost_of_repairman)
print("\n")
print("Total bearing replaced =", total_change*3)
cost_of_bearing = cost_of_one_bearing*total_change*3
print("Cost of bearing = Rs.", cost_of_bearing)
print("\n")
print("Total estimated cost = Rs.", cost_of_repairman+cost_of_bearing+cost_of_downtime)