No description has been provided for this image

Submitting a Mortgage Application¶

Faisal Qureshi
faisal.qureshi@ontariotechu.ca
http://www.vclab.ca

Copyright information¶

© Faisal Qureshi

License¶

No description has been provided for this image This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
In [90]:
import numpy as np
import simpy
import pandas as pd
In [91]:
def mortgage_application(env, name, clerk, manager):
    global df
    
    arrival = env.now
    
    with clerk.request() as clerk_request:
        yield clerk_request
        print (f'{name} found a clerk at {env.now}')
        yield env.timeout(4)

    with manager.request() as manager_request:
        yield manager_request
        print (f'{name} found a manager at {env.now}')
        yield env.timeout(2)

    print(f'{name} left at {env.now}')

    record = {'Name': [name], 'Arrival': [arrival], 'Departure': [env.now]}
    df = pd.concat([df, pd.DataFrame(record)])  
In [92]:
columns = ['Name', 'Arrival', 'Departure']
df = pd.DataFrame(columns = columns)

env = simpy.Environment()
clerk = simpy.Resource(env, capacity=2)
manager = simpy.Resource(env, capacity=1)

env.process(mortgage_application(env, 'John', clerk, manager))
env.process(mortgage_application(env, 'Jane', clerk, manager))
env.process(mortgage_application(env, 'Zack', clerk, manager))
env.process(mortgage_application(env, 'Brittany', clerk, manager))

env.run(until=37)
John found a clerk at 0
Jane found a clerk at 0
John found a manager at 4
Zack found a clerk at 4
Brittany found a clerk at 4
John left at 6
Jane found a manager at 6
Jane left at 8
Zack found a manager at 8
Zack left at 10
Brittany found a manager at 10
Brittany left at 12
In [89]:
print(df)
       Name Arrival Departure
0      John       0         6
0      Jane       0         8
0      Zack       0        10
0  Brittany       0        12
No description has been provided for this image