1

I am building a Inventory simulation model using Simpy in a multi-echelon environment. However there seems to be some blocking function which is not letting my program proceed beyond time unit 0.

A simplified version of my code is:

class repl():
    rosq_st=1
    toq_st=5
    poq_dc=30
    lt_st=2
    lt_dc=10
    ss_st=2
    ss_dc=10
    toq_day=toq_st/lt_st
    rop_st=ss_st+(lt_st*rosq_st)
    rop_dc=ss_dc+(lt_dc*toq_day)
    simulation_time=30

class Inventory():
    def __init__(self,env):
        self.env=env
        self.st_inv=simpy.Container(env,init=repl.rop_st)
        self.dc_inv=simpy.Container(env,init=repl.rop_dc)
        env.process(self.custord(env))
        env.process(self.ropcheck_st_inv(env)) #check ropcheck_st_inv_proc?
        env.process(self.ropcheck_dc_inv(env)) # check ropcheck_dc_inv_proc?
        print ("inv process started")

    def ropcheck_st_inv(self,env):
        while True:
            if self.st_inv.level<repl.rop_st:
                print ("Order placed to DC at time {}".format(self.env.now))
                yield self.env.timeout(repl.lt_st)
                print ("Order received at store at time {}".format(self.env.now))
                yield self.env.dc_inv.get(repl.toq_st)
                yield self.env.st_inv.put(repl.toq_st)
                print ("Order added to store at time {}".format(self.env.now))
                yield self.env.timeout(1)

    def ropcheck_dc_inv(self,env):
        while True:
            if self.dc_inv.level<repl.rop_dc:
                print ("Order placed to sup at time {}".format(self.env.now))
                yield self.env.timeout(repl.lt_dc)
                print ("Order received at dc at time {}".format(self.env.now))
                yield self.env.dc_inv.put(repl.poq_dc)
                print ("Order added to dc at time {}".format(self.env.now))
                yield self.env.timeout(1)

    def custord(self,env):
        while True:
            print (str(self.env.now))
            yield self.st_inv.get(repl.rosq_st)
            print (self.st_inv.level)
            yield self.env.timeout(1)

env = simpy.Environment()
inventory = Inventory(env)
env.run(until=10)
Ankit Goel
  • 360
  • 1
  • 5
  • 18

0 Answers0