I have a Server that can serve at-most 3 customers at a time. I have modeled it as a SimPy Resource
with capacity=3
as follows. How can I update my code such that whenever a new customer arrives, if all of the server's capacity is being utilized, the new customer is simply forgotten?
I have read the documentation, but I cannot find an example that fits this scenario.
SERVERS= 3
class Servers:
def __init__(self, env):
self.cashier = simpy.Resource(env, capacity= SERVERS)
def Customer(name, env, servers):
print('Customer %s arriving at %s' % (name, env.now))
with servers.cashier.request() as req:
yield req
print('Customer %s starts being served at %s' % (name, env.now))
yield env.timeout(35)
print('Customer %s done served at %s' % (name, env.now))
def customer_generator(env, servers):
for i in range(100):
env.process(Customer(i, env, servers))
yield env.timeout(5)
env = simpy.Environment()
servers = Servers(env)
cus_generator = env.process(customer_generator(env, servers))
env.run(1000)