Debian Codegraph @

docs/source/Tutorials/bankprograms/bank04.py

raw symbols SCIP
1 """ bank04: Simulate a single customer. random time in system """
2 from SimPy.Simulation import *
3 from random import Random, expovariate
4
5 ## Model components ------------------------
6
7
8 class Customer(Process):
9 """ Customer arrives in the bank, looks around for
10 a random time and then leaves """
11 def __init__(self, name):
12 Process.__init__(self)
13 self.name = name
14
15 def visit(self, rv, timeInBank=0):
16 print("%7.4f %s: Here I am" % (now(), self.name))
17 t = rv.expovariate(1.0 / timeInBank)
18 yield hold, self, t
19 print("%7.4f %s: I must leave" % (now(), self.name))
20
21 ## Experiment data -------------------------
22
23 maxTime = 100.0 # minutes
24
25 ## Model/Experiment ------------------------------
26
27
28 def model():
29 rv = Random(1133)
30 initialize()
31 c = Customer(name="Klaus")
32 activate(c, c.visit(rv, timeInBank=10.0), at=5.0)
33 simulate(until=maxTime)
34
35 model()