forked from myrlund/salabim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example - bank, 3 clerks.py
50 lines (39 loc) · 1.24 KB
/
Example - bank, 3 clerks.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
# Example - bank, 3 clerks.py
import salabim as sim
class CustomerGenerator(sim.Component):
def process(self):
while True:
Customer()
yield self.hold(sim.Uniform(5, 15).sample())
class Customer(sim.Component):
def process(self):
self.enter(waitingline)
for clerk in clerks:
if clerk.ispassive():
clerk.activate()
break # activate only one clerk
yield self.passivate()
class Clerk(sim.Component):
def process(self):
while True:
while len(waitingline) == 0:
yield self.passivate()
self.customer = waitingline.pop()
yield self.hold(30)
self.customer.activate()
env = sim.Environment(trace=False)
CustomerGenerator(name='customergenerator')
clerks = sim.Queue('clerks')
for i in range(3):
Clerk().enter(clerks)
waitingline = sim.Queue('waitingline')
env.run(till=50000)
waitingline.length.print_histogram(30, 0, 1)
print()
waitingline.print_info()
waitingline.print_statistics()
waitingline.length.print_histogram(30, 0, 1)
print()
waitingline.length_of_stay.print_histogram(30, 0, 10)
waitingline.length_of_stay.print_statistics()
waitingline.length.print_statistics()