I am trying to run a simulation with SimPy. Unlike open systems, since my system is closed, I need to generate a constant amount of entities immediately (10 in my case). So, no interarrival times.
The problem is that when I try to generate entities in a while loop with or without interarrival times, I don't get an error. (Without interarrival times, of course it doesn't stop running, cause you know, it tries to generate as much as possible in a given runtime). The code below works but it is not what I need.
def customer_generator(self, env, resource1, resource2):
while True:
p = self.customer(env, resource1, resource2) # create a new customer
env.process(p) # start the simulation of the customer
But when I try to generate them in a for loop to create only 10 entities,
def customer_generator(self, env, resource1, resource2):
for x in range(10):
p = self.customer(env, resource1, resource2) # create a new customer
env.process(p) # start the simulation of the customer
I get this "None is not a generator" error.
File "C:\Users\Can\Anaconda3\lib\site-packages\simpy\events.py", line 310, in __init__
raise ValueError('%s is not a generator.' % generator)
ValueError: None is not a generator.
Maybe I am missing a simple detail. Any suggestions on how I can generate only 10 entities without getting this error?