예제 #1
0
def balanceQueue(buffer, refillLevel=1):
    # get the internal queue of the buffer
    objectQueue = buffer.getActiveObjectQueue()
    numInQueue = len(objectQueue)
    print '-' * 50
    print 'at time=', G.env.now
    # check if the buffer is empty and if yes fill it with 5 parts
    if numInQueue == 0:
        print 'buffer is starving, I will bring 5 parts'
        for i in range(refillLevel):
            # calculate the id and name of the new part
            partId = 'P' + str(G.numOfParts)
            partName = 'Part' + str(G.numOfParts)
            # create the Part
            P = Part(partId, partName, currentStation=buffer)
            # set the part as WIP
            setWIP([P])
            G.numOfParts += 1
    # else do nothing
    else:
        print 'buffer has', numInQueue, 'parts. No need to bring more'
예제 #2
0
from dream.simulation.imports import Machine, Queue, Exit, Part, ExcelHandler  
from dream.simulation.Globals import runSimulation, G

#define the objects of the model 
Q=Queue('Q1','Queue', capacity=1)
M=Machine('M1','Machine', processingTime={'Fixed':{'mean':0.25}})
E=Exit('E1','Exit')  
P1=Part('P1', 'Part1', currentStation=Q)

#define predecessors and successors for the objects    
Q.defineRouting(successorList=[M])
M.defineRouting(predecessorList=[Q],successorList=[E])
E.defineRouting(predecessorList=[M])

def main(test=0):
    # add all the objects in a list
    objectList=[Q,M,E,P1]  
    # set the length of the experiment  
    maxSimTime=float('inf')
    # call the runSimulation giving the objects and the length of the experiment
    runSimulation(objectList, maxSimTime, trace='Yes')

    # calculate metrics
    working_ratio = (M.totalWorkingTime/G.maxSimTime)*100

    # return results for the test
    if test:
        return {"parts": E.numOfExits,
        "simulationTime":E.timeLastEntityLeft,
      "working_ratio": working_ratio}
예제 #3
0
from dream.simulation.Globals import runSimulation, G
from dream.simulation.imports import Machine, Queue, Exit, Part, ExcelHandler

#define the objects of the model
Q=Queue('Q1','Queue', capacity=1)
M=Machine('M1','Machine', processingTime={'Fixed':{'mean':0.25}})
E=Exit('E1','Exit')
P1=Part('P1', 'Part1', currentStation=Q)
P2=Part('P2', 'Part2', currentStation=M, remainingProcessingTime={'Fixed':{'mean':0.1}})

#define predecessors and successors for the objects
Q.defineRouting(successorList=[M])
M.defineRouting(predecessorList=[Q],successorList=[E])
E.defineRouting(predecessorList=[M])

def main(test=0):
    # add all the objects in a list
    objectList=[Q,M,E,P1,P2]

    # set the length of the experiment
    maxSimTime = float('inf')

    # call the runSimulation giving the objects and the length of the experiment
    runSimulation(objectList, maxSimTime, trace='Yes')

    # calculate metrics
    working_ratio = (M.totalWorkingTime/G.maxSimTime)*100

    # return results for the test
    if test:
        return {"parts": E.numOfExits, "simulationTime":E.timeLastEntityLeft, "working_ratio": working_ratio}
예제 #4
0
                break
    # if canDispose is not triggered in the predecessor send it
    if not machine.previous[0].canDispose.triggered:
        # a succeed function on an event must always take attributes the transmitter and the time of the event
        succeedTuple = (machine, G.env.now)
        machine.previous[0].canDispose.succeed(succeedTuple)
    print G.env.now, 'from now on the machine will take from', machine.previous[
        0].id


#define the objects of the model
Q1 = Queue('Q1', 'Queue1', capacity=float('inf'))
Q2 = Queue('Q2', 'Queue2', capacity=float('inf'))
M = Machine('M1', 'Machine', processingTime={'Fixed': {'mean': 3}})
E = Exit('E1', 'Exit')
P1 = Part('P1', 'Part1', currentStation=Q1)
entityList = []
for i in range(5):  # create the WIP in a loop
    Q1PartId = 'Q1_P' + str(i)
    Q1PartName = 'Q1_Part' + str(i)
    PQ1 = Part(Q1PartId, Q1PartName, currentStation=Q1)
    entityList.append(PQ1)
    Q2PartId = 'Q2_P' + str(i)
    Q2PartName = 'Q2_Part' + str(i)
    PQ2 = Part(Q2PartId, Q2PartName, currentStation=Q2)
    entityList.append(PQ2)

#define predecessors and successors for the objects
Q1.defineRouting(successorList=[M])
Q2.defineRouting(successorList=[M])
M.defineRouting(successorList=[E])
예제 #5
0
QA = Queue('QA', 'QueueAfter', capacity=float("inf"))
MA = Machine('MA', 'MachineAfter', processingTime={'Exp': {'mean': 1}})
E = Exit('E', 'Exit')

QB.defineRouting(successorList=[Q1, Q2, Q3])
Q1.defineRouting(predecessorList=[QB], successorList=[M1])
Q2.defineRouting(predecessorList=[QB], successorList=[M2])
Q3.defineRouting(predecessorList=[QB], successorList=[M3])
M1.defineRouting(predecessorList=[Q1], successorList=[QA])
M2.defineRouting(predecessorList=[Q2], successorList=[QA])
M3.defineRouting(predecessorList=[Q3], successorList=[QA])
QA.defineRouting(predecessorList=[M1, M2, M3], successorList=[MA])
MA.defineRouting(predecessorList=[QA], successorList=[E])
E.defineRouting(predecessorList=[MA])

P1 = Part('P1', 'P1', currentStation=QB)
P2 = Part('P2', 'P2', currentStation=QB)
P3 = Part('P3', 'P3', currentStation=QB)
P4 = Part('P4', 'P4', currentStation=QB)
P5 = Part('P5', 'P5', currentStation=QB)
P6 = Part('P6', 'P6', currentStation=QB)

G.InternalQueueList = [Q1, Q2, Q3]
G.InternalProcessList = [M1, M2, M3]


def main(test=0):
    # call the runSimulation giving the objects and the length of the experiment
    runSimulation(objectList=[
        QB, Q1, M1, Q2, M2, Q3, M3, QA, E, P1, P2, P3, P4, P5, P6, MA
    ],
예제 #6
0
from dream.simulation.imports import Machine, Queue, Exit, Part, ExcelHandler
from dream.simulation.Globals import runSimulation, G

#define the objects of the model
Q = Queue('Q1', 'Queue', capacity=1)
M = Machine('M1', 'Machine', processingTime={'Fixed': {'mean': 0.25}})
E = Exit('E1', 'Exit')
P1 = Part('P1', 'Part1', currentStation=Q)
P2 = Part('P2', 'Part2', currentStation=M)

#define predecessors and successors for the objects
Q.defineRouting(successorList=[M])
M.defineRouting(predecessorList=[Q], successorList=[E])
E.defineRouting(predecessorList=[M])


def main(test=0):
    # add all the objects in a list
    objectList = [Q, M, E, P1, P2]
    # set the length of the experiment
    maxSimTime = float('inf')
    # call the runSimulation giving the objects and the length of the experiment
    runSimulation(objectList, maxSimTime, trace='Yes')

    # calculate metrics
    working_ratio = (M.totalWorkingTime / G.maxSimTime) * 100

    # return results for the test
    if test:
        return {
            "parts": E.numOfExits,