I want to make a simulation of a store with two types of customers: a normal customer and a VIP.
I don't want to serve these customers FIFO. Instead - no matter what the queue looks like - I want to serve a VIP with chance p and a normal customer with chance 1-p.
I know the basics of Simpy but I don't know how to implement different ways a cashier picks a customer that will be served next.
The easy way is to create two Simpy Stores, Regular and VIP:
import simpy
import random
# create 2 stores
env = simpy.Environment()
regularStore = simpy.Store(env)
vipStore = simpy.Store(env)
# populate (you can use any generate process here)
regularStore.put('customer')
vipStore.put('VIP')
def server(env, regularStore, vipStore, p):
# create the choose process
if random.random() <= p:
pickCustomer = yield vipStore.get()
else:
pickCustomer = yield regularStore.get()
print(pickCustomer)
env.process(server(env, regularStore, vipStore, 0.30))
env.run()