Debian Codegraph @

docs/source/Tutorials/bankprograms/bank05.py

raw symbols SCIP
1 """ bank05: The single Random Customer """
2 from SimPy.Simulation import *
3 from random import expovariate, seed # (1)
4
5 ## Model components ------------------------
6
7
8 class Customer(Process):
9 """ Customer arrives at a random time,
10 looks around and then leaves """
11
12 def visit(self, timeInBank):
13 print("%f %s Here I am" % (now(), self.name))
14 yield hold, self, timeInBank
15 print("%f %s I must leave" % (now(), self.name))
16
17 ## Experiment data -------------------------
18
19 maxTime = 100.0 # minutes
20 timeInBank = 10.0
21 ## Model/Experiment ------------------------------
22
23 seed(99999) # (2)
24 initialize()
25 c = Customer(name="Klaus")
26 t = expovariate(1.0 / 5.0) # (3)
27 activate(c, c.visit(timeInBank), at=t) # (4)
28 simulate(until=maxTime)