-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPuzzlORFebruary2014.py
135 lines (105 loc) · 2.55 KB
/
PuzzlORFebruary2014.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
#PuzzlOR February 2014 Pizza Delivery
import random
import sys
import math
# def main():
# try:
# random.seed(123)
# #of drivers needed
# drivers = []
# number_of_iterations = 10000
# iterationsComplete = True
# iterationsDone = 0
# while(iterationsComplete):
# if iterationsDone = 10000:
# iterationsComplete = False
# break
# else:
# #order arrival time
# interarrival_time = 6.0
# arrival_time = int(random.expovariate(1/interarrival_time))
# #service rate
# service_rate = math.ceil(random.uniform(20,61))
# iterationsDone += 1
# except:
# e = sys.exc_info()
# print(e)
# sys.exit(1)
def main():
random.seed(12)
interarrival_time = 6.0
arrival_time = int(random.expovariate(1/interarrival_time))
print(arrival_time)
if __name__ == "__main__":
main()
# import random
# import sys
# import math
# def main():
# try:
# random.seed(3)
# #data
# #interarrival time of 6 minutes exponentially distributed
# interarrival_time = 6.0
# arrival_time = int(random.expovariate(1/interarrival_time))
# #service rate
# service_rate = math.ceil(random.uniform(20,61))
# #average order delivery time < 60 minutes
# max_time = 60
# number_customers = 10
# workers_needed = (number_customers * service_rate)/max_time
# print(int(workers_needed)+1)
# except:
# e = sys.exc_info()
# print(e)
# sys.exit(1)
# if __name__ == "__main__":
# main()
# #PuzzlOR February 2014 Pizza Delivery
# import random
# import sys
# import math
# """
# assumption only 1 order per round trip
# """
# def calc_avg(alist):
# total = 0
# count = 0
# for value in alist:
# if value > 0:
# total+=value
# count+=1
# return math.ceil(total/count)
# def calc_driver(alist):
# driverCount = 0
# total = 0
# for value in alist:
# total+=value
# if total <= 60:
# driverCount+=1
# if total >= 60:
# total = 0
# return driverCount
# def main():
# try:
# random.seed(1)
# driver_data = []
# count_begin = 0
# count_end = 100000
# while (count_begin < count_end):
# delivery_data = []
# interarrival_time = 6.0/60.0
# amount_order = int(random.expovariate(interarrival_time))
# for value in range(0,amount_order):
# pickup_delivery_time = math.ceil(random.uniform(20,61))
# delivery_data.append(pickup_delivery_time)
# driver_data.append(calc_driver(delivery_data))
# count_begin+=1
# driver_data.sort()
# print(calc_avg(driver_data))
# except:
# e = sys.exc_info()
# print(e)
# sys.exit(1)
# if __name__ == "__main__":
# main()