【发布时间】:2019-10-29 07:30:42
【问题描述】:
在 simpy 中,由于问题的性质,我将商店用作我的资源。
我有几个获取商店商品的请求。但是,一些获取请求具有更高的优先级,我希望它首先被处理。对于这种特殊的获取请求,我不希望遵循 FIFO 规则。
yield Store_item.get()
我尝试关注this question。但是,我无法创建适合此要求的子类。
我想要这样的东西:(但这是优先资源而不是存储资源的示例)。
def resource_user(name, env, resource, wait, prio):
yield env.timeout(wait)
with resource.request(priority=prio) as req:
print('%s requesting at %s with priority=%s'% (name,env.now,prio))
yield req
print('%s got resource at %s' % (name, env.now))
yield env.timeout(3)
但是,我需要它用于商店资源类,而不是用于商店的通用 get。
结果将是:
yield Store_item.priority_get()
【问题讨论】: