Debian Codegraph @

docs/source/Tutorials/bankprograms_OO/bank02_OO.py

raw symbols SCIP
1 """ bank02_OO: More Customers """
2 from SimPy.Simulation import Simulation, Process, hold
3
4
5 ## Model components ------------------------
6 class Customer(Process):
7 """ Customer arrives, looks around and leaves """
8
9 def visit(self, timeInBank=0):
10 print("%7.4f %s: Here I am" % (self.sim.now(), self.name))
11 yield hold, self, timeInBank
12 print("%7.4f %s: I must leave" % (self.sim.now(), self.name))
13
14
15 ## Model -----------------------------------
16 class BankModel(Simulation):
17 def run(self):
18 """ PEM """
19 c1 = Customer(name="Klaus", sim=self)
20 self.activate(c1, c1.visit(timeInBank=10.0), at=5.0)
21 c2 = Customer(name="Tony", sim=self)
22 self.activate(c2, c2.visit(timeInBank=7.0), at=2.0)
23 c3 = Customer(name="Evelyn", sim=self)
24 self.activate(c3, c3.visit(timeInBank=20.0), at=12.0)
25 self.simulate(until=maxTime)
26
27 ## Experiment data -------------------------
28
29 maxTime = 400.0 # minutes
30
31 ## Experiment ------------------------------
32
33 mymodel = BankModel()
34 mymodel.run()
35