File: bank01.py

package info (click to toggle)
python-simpy 2.3.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,864 kB
  • sloc: python: 11,171; makefile: 143
file content (25 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
""" bank01: The single non-random Customer """  # (1)
from SimPy.Simulation import *  # (2)

## Model components -----------------------------


class Customer(Process):  # (3)
    """ Customer arrives, looks around and leaves """

    def visit(self, timeInBank):  # (4)
        print("%2.1f %s  Here I am" % (now(), self.name))  # (5)
        yield hold, self, timeInBank  # (6)
        print("%2.1f %s  I must leave" % (now(), self.name))  # (7)

## Experiment data ------------------------------

maxTime = 100.0     # minutes (8)
timeInBank = 10.0   # minutes

## Model/Experiment ------------------------------

initialize()  # (9)
c = Customer(name="Klaus")  # (10)
activate(c, c.visit(timeInBank), at=5.0)  # (11)
simulate(until=maxTime)  # (12)