The code is for a simulation of registration desk with 2 personnel and 10 students where, it takes 5 min to complete the registration and 3 min is the waiting period before the next student can start registration.
I m new to simulation and I fail to understand the purpose/use/working of code tagged as #line1 and #line2
Also, why doesn't the code execute first for the for loop before #line2?
import simpy
class Student(object):
def __init__(self,env,reg):
self.env=env
self.action=env.process(self.run()) #line 1
self.reg=reg
def run(self):
with reg.request() as r:
yield r
print("Start registration at at %d" % env.now)
yield env.timeout(5)
print("Start waiting at %d "% env.now)
yield env.timeout(3)
env=simpy.Environment()
reg=simpy.Resource(env,capacity=2)
student=Student(env,reg)
for i in range (9):
env.process(student.run())
env.run(until=80) #line2