2017-10-17 13:29:46

Traceback (most recent call last):
  File "banksim.py", line 6, in <module>
    class Customer(Process):
NameError: name 'Process' is not defined

Hear is the code.

""" bank01: The single non-random Customer """           
import simpy

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

class Customer(Process):                                 
    """ Customer arrives, looks around and leaves """
       
    def visit(self,timeInBank):                         
        print now(),self.name," Here I am"               
        yield hold,self,timeInBank                       
        print now(),self.name," I must leave"           

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

maxTime = 100.0     # minutes                           
timeInBank = 10.0   # minutes

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

initialize()                                             
c = Customer(name="Klaus")                               
activate(c,c.visit(timeInBank),at=5.0)                   
simulate(until=maxTime)

Bitcoin Address:
1MeNca7h6m8du4TV3psN4m4X666p6Y36u5m

2017-10-17 14:26:53

According to the example found at https://simpy.readthedocs.io/en/latest/ … nege.html, what your trying to do is either not possible or has changed. The closest code I could find to what your trying to do is (python 3.x only):

"""
Bank renege example

Covers:

- Resources: Resource
- Condition events

Scenario:
  A counter with a random service time and customers who renege. Based on the
  program bank08.py from TheBank tutorial of SimPy 2. (KGM)

"""
import random

import simpy


RANDOM_SEED = 42
NEW_CUSTOMERS = 5  # Total number of customers
INTERVAL_CUSTOMERS = 10.0  # Generate new customers roughly every x seconds
MIN_PATIENCE = 1  # Min. customer patience
MAX_PATIENCE = 3  # Max. customer patience


def source(env, number, interval, counter):
    """Source generates customers randomly"""
    for i in range(number):
        c = customer(env, 'Customer%02d' % i, counter, time_in_bank=12.0)
        env.process(c)
        t = random.expovariate(1.0 / interval)
        yield env.timeout(t)


def customer(env, name, counter, time_in_bank):
    """Customer arrives, is served and leaves."""
    arrive = env.now
    print('%7.4f %s: Here I am' % (arrive, name))

    with counter.request() as req:
        patience = random.uniform(MIN_PATIENCE, MAX_PATIENCE)
        # Wait for the counter or abort at the end of our tether
        results = yield req | env.timeout(patience)

        wait = env.now - arrive

        if req in results:
            # We got to the counter
            print('%7.4f %s: Waited %6.3f' % (env.now, name, wait))

            tib = random.expovariate(1.0 / time_in_bank)
            yield env.timeout(tib)
            print('%7.4f %s: Finished' % (env.now, name))

        else:
            # We reneged
            print('%7.4f %s: RENEGED after %6.3f' % (env.now, name, wait))


# Setup and start the simulation
print('Bank renege')
random.seed(RANDOM_SEED)
env = simpy.Environment()

# Start processes and run
counter = simpy.Resource(env, capacity=1)
env.process(source(env, NEW_CUSTOMERS, INTERVAL_CUSTOMERS, counter))
env.run()
"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github