Debian Codegraph @

docs/source/Manuals/programs/example1.py

raw symbols SCIP
1 from SimPy.Simulation import Process, activate, initialize, hold, simulate
2
3
4 class Customer(Process):
5 def buy(self, budget=0):
6 print('Here I am at the shops %s' % self.name)
7 t = 5.0
8 for i in range(4):
9 yield hold, self, t
10 # executed 4 times at intervals of t time units
11 print('I just bought something %s' % self.name)
12 budget -= 10.00
13 print('All I have left is %s I am going home %s' %
14 (budget, self.name))
15
16
17 initialize()
18
19 # create a customer named "Evelyn",
20 C = Customer(name='Evelyn')
21 # and activate her with a budget of 100
22 activate(C, C.buy(budget=100), at=10.0)
23
24 simulate(until=100.0)