simpy

Simpy Store Batch Processing

对着背影说爱祢 提交于 2019-12-07 15:56:33
I'm trying to create a producer/consumer simulation where the consumer processes items in batches. The problem is that the Store.get() function removes items from the Store as soon as it is called, but I need it to wait until I've called yield: import simpy def producer(env, Q): item = 0 while True: yield Q.put(item) print('Submit item:%d'%item) item += 1 def consumer(env, Q): while True: yield env.timeout(20) events = [Q.get() for i in range(4)] items = yield env.all_of(events) print([items for items in items.values()]) env = simpy.Environment() maxQD = 2 Q = simpy.Store(env, capacity=maxQD)

SimPy Resource of 3 where each has different characteristics

情到浓时终转凉″ 提交于 2019-12-05 05:36:57
问题 I am trying to simulate a situation where we have 5 machines that occur in a 1 -> 3 -> 1 situation. i.e the 3 in the middle operate in parallel to reduce the effective time they take. I can easily simulate this by create a SimPy resource with a value of three like this: simpy.Resource(env, capacity=3) However in my situation each of the three resources operates slightly differently and sometimes I want to be able to use any of them (when I'm operating) or book a specific one (when i want to