Debian Codegraph @

docs/source/Tutorials/bankprograms/bank03.py

raw symbols SCIP
1 """ bank03: Many non-random Customers """
2 from SimPy.Simulation import *
3
4 ## Model components ------------------------
5
6
7 class Source(Process): # (1)
8 """ Source generates customers regularly """
9
10 def generate(self, number, TBA): # (2)
11 for i in range(number):
12 c = Customer(name="Customer%02d" % (i)) # (3)
13 activate(c, c.visit(timeInBank=12.0))
14 yield hold, self, TBA # (4)
15
16
17 class Customer(Process):
18 """ Customer arrives, looks around and leaves """
19
20 def visit(self, timeInBank):
21 print("%7.4f %s: Here I am" % (now(), self.name))
22 yield hold, self, timeInBank
23 print("%7.4f %s: I must leave" % (now(), self.name))
24
25 ## Experiment data -------------------------
26
27 maxNumber = 5
28 maxTime = 400.0 # minutes
29 ARRint = 10.0 # time between arrivals, minutes
30
31 ## Model/Experiment ------------------------------
32
33 initialize()
34 s = Source() # (5)
35 activate(s, s.generate(number=maxNumber, # (6)
36 TBA=ARRint), at=0.0)
37 simulate(until=maxTime)