from dream.simulation.imports import BatchScrapMachine, NonStarvingEntry, Exit, Part from dream.simulation.Globals import runSimulation #define the objects of the model NS=NonStarvingEntry('NS1','Entry',entityData={'_class':'Dream.Batch','numberOfUnits':100}) M=BatchScrapMachine('M1','Machine', processingTime={'Fixed':{'mean':0.02}}) E=Exit('E1','Exit') #define predecessors and successors for the objects NS.defineRouting(successorList=[M]) M.defineRouting(predecessorList=[NS],successorList=[E]) E.defineRouting(predecessorList=[M]) def main(test=0): # add all the objects in a list objectList=[NS,M,E] # set the length of the experiment maxSimTime=10 # call the runSimulation giving the objects and the length of the experiment runSimulation(objectList, maxSimTime) # calculate metrics working_ratio = (M.totalWorkingTime/maxSimTime)*100 # return results for the test if test: return {"batches": E.numOfExits, "working_ratio": working_ratio} #print the results print "the system produced", E.numOfExits, "batches"
from dream.simulation.imports import Machine, Source, Exit, Part, Queue, NonStarvingEntry from dream.simulation.Globals import runSimulation #define the objects of the model NS = NonStarvingEntry('NS1', 'Entry', entityData={'_class': 'Dream.Part'}) M1 = Machine('M1', 'Machine1', processingTime={'Exp': {'mean': 1}}) Q2 = Queue('Q2', 'Queue2') M2 = Machine('M2', 'Machine2', processingTime={'Exp': {'mean': 3}}) Q3 = Queue('Q3', 'Queue3') M3 = Machine('M3', 'Machine3', processingTime={'Exp': {'mean': 5}}) E = Exit('E1', 'Exit') #define predecessors and successors for the objects NS.defineRouting(successorList=[M1]) M1.defineRouting(predecessorList=[NS], successorList=[Q2]) Q2.defineRouting(predecessorList=[M1], successorList=[M2]) M2.defineRouting(predecessorList=[Q2], successorList=[Q3]) Q3.defineRouting(predecessorList=[M2], successorList=[M3]) M3.defineRouting(predecessorList=[Q3], successorList=[E]) E.defineRouting(predecessorList=[M3]) def main(test=0): # add all the objects in a list objectList = [NS, M1, M2, M3, Q2, Q3, E] # set the length of the experiment maxSimTime = 480 solutionList = [] for i in range(1, 10):
for obj in [M1, M2, M3, B123]: G.totalWIP += len(obj.getActiveObjectQueue()) # at the end of the simulation append to the list that keeps for all replications if G.env.now == G.maxSimTime - 1: G.AverageWIP.append(G.totalWIP / float(G.maxSimTime)) # returns a number from the uniform distribution (0,1) def createRandomNumber(): return Rnd.uniform(0, 1) #define the objects of the model NS1 = NonStarvingEntry('NS1', 'Entry1', entityData={ '_class': 'Dream.Part', 'status': 'Good' }) NS2 = NonStarvingEntry('NS2', 'Entry2', entityData={ '_class': 'Dream.Part', 'status': 'Good' }) M1 = OpMachine('M1', 'Machine1', processingTime={'Fixed': {'mean': 0.1}}) M2 = OpMachine('M2', 'Machine2', processingTime={'Fixed': {'mean': 0.1}}) M3 = OpMachine('M3', 'Machine3', processingTime={'Fixed': {'mean': 0.1}}) B123 = OpQueue('B123', 'Queue', capacity=capacity, gatherWipStat=True) E = OpExit('E1', 'Exit') Controller = EventGenerator('EV', 'Controller',
from dream.simulation.imports import BatchScrapMachine, NonStarvingEntry, Exit, Part from dream.simulation.Globals import runSimulation #define the objects of the model NS = NonStarvingEntry('NS1', 'Entry', entityData={ '_class': 'Dream.Batch', 'numberOfUnits': 100 }) M = BatchScrapMachine('M1', 'Machine', processingTime={'Fixed': { 'mean': 0.02 }}) E = Exit('E1', 'Exit') #define predecessors and successors for the objects NS.defineRouting(successorList=[M]) M.defineRouting(predecessorList=[NS], successorList=[E]) E.defineRouting(predecessorList=[M]) def main(test=0): # add all the objects in a list objectList = [NS, M, E] # set the length of the experiment maxSimTime = 10 # call the runSimulation giving the objects and the length of the experiment runSimulation(objectList, maxSimTime)
# count the total WIP for the machines and the Queue for obj in [M1,M2,M3,B123]: G.totalWIP+=len(obj.getActiveObjectQueue()) # at the end of the simulation append to the list that keeps for all replications if G.env.now==G.maxSimTime-1: G.AverageWIP.append(G.totalWIP/float(G.maxSimTime)) # returns a number from the uniform distribution (0,1) def createRandomNumber(): return Rnd.uniform(0,1) #define the objects of the model NS1=NonStarvingEntry('NS1','Entry1',entityData={'_class':'Dream.Part','status':'Good'}) NS2=NonStarvingEntry('NS2','Entry2',entityData={'_class':'Dream.Part','status':'Good'}) M1=OpMachine('M1','Machine1', processingTime={'Fixed':{'mean':0.1}}) M2=OpMachine('M2','Machine2', processingTime={'Fixed':{'mean':0.1}}) M3=OpMachine('M3','Machine3', processingTime={'Fixed':{'mean':0.1}}) B123=OpQueue('B123','Queue', capacity=capacity,gatherWipStat=True) E=OpExit('E1','Exit') Controller=EventGenerator('EV','Controller',start=0,interval=1,method=controllerMethod) #define predecessors and successors for the objects NS1.defineRouting(successorList=[M1]) NS2.defineRouting(successorList=[M2]) M1.defineRouting(predecessorList=[NS1],successorList=[B123]) M2.defineRouting(predecessorList=[NS2],successorList=[B123]) B123.defineRouting(predecessorList=[M1,M2],successorList=[M3]) M3.defineRouting(predecessorList=[B123],successorList=[E])