问题描述
我正在使用 python 开发模拟。我研究了其他网站,但是,我还没有找到我要找的东西。我对以特定(可识别)方式从数组启动 Resource
的方法感兴趣。我提供了我一直在运行的一个模拟的代码。
class Car_wash(object):
def __init__(self,env,num_wash,num_servers):
self.env = env
self.washingmachine = simpy.Resource(env,num_wash)
self.cashier = simpy.Resource(env,num_servers)
def purchase(self,customer):
yield self.env.timeout(random.uniform(1,3))
#yield self.env.timeout(random.randint(1,3))
#yield self.env.timeout(3)
def wash(self,customer):
yield self.env.timeout(10)
#yield self.env.timeout(random.randint(1,3))
#yield self.env.timeout(3)
def wash_the_car(env,customer,carwash):
#Customer arrives at the car wash
arrival_time = env.Now
with carwash.cashier.request() as request:
yield request
yield env.process(carwash.purchase(customer))
with carwash.washingmachine.request() as request:
yield request
yield env.process(carwash.wash(customer))
这个想法是我想生成多个洗衣机(从一个数组并形成一个数组),然后可以一个一个地选择。例如,我想生成 washingmachine1
、washingmachine2
等。通过这种方式,我可以在需要时参考特定元素,例如,我可以将特定客户分配给 washingmachine4
。有没有人知道这样做的方法(以简单有效的方式)?非常感谢您的帮助。最好的
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)