Greetings StackOverflow Community!
I have a question regarding the SimPy framework in Python:
Here is a very simple code example for cars continously arriving at a charging station and get charged at one of the two available charging spots and then leave again. Other arriving cars will wait until a charging spot is free again:
import simpy
env = simpy.Environment()
bcs = simpy.Resource(env, capacity = 2)
def car(env, name, bcs, driving_time, charge_duration):
yield env.timeout(driving_time)
print('%s arriving at %d' % (name, env.now))
with bcs.request() as req:
yield req
print('%s starting to charge at %s' % (name, env.now))
yield env.timeout(charge_duration)
print('%s leaving the bcs at %s' % (name, env.now))
for i in range(10):
env.process(car(env, 'Car %d' % i, bcs, i*2, 5))
env.run()
My question now is: What if I have two charging stations with one charging spot each. So there would still be two charging spots, but from two resources. (The goal of this is for example to have two charging stations which different charging times on their spots.)
I'm not quite sure, how to initate this. Basically I got the two ressources:
bcs1 = simpy.Resource(env, 1)
bcs2 = simpy.Resource(env, 1)
Thanks in advance!