本文整理汇总了Python中dream.simulation.imports.Machine类的典型用法代码示例。如果您正苦于以下问题:Python Machine类的具体用法?Python Machine怎么用?Python Machine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Machine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: removeEntity
def removeEntity(self, entity):
activeEntity=Machine.removeEntity(self, entity)
if self.state==-1:
activeEntity.status='Bad'
else:
self.numGoodParts+=1
return activeEntity
示例2: removeEntity
def removeEntity(self,entity=None):
# run the default method
activeEntity=Machine.removeEntity(self, entity)
# count the number of parts in the server.
# If it is empty have one internal queue to signal the queue before the compound object
if not self.countInternalParts():
self.sendSignal(receiver=QB, signal=QB.canDispose, sender=Q1)
return activeEntity
示例3: getEntity
def getEntity(self):
activeEntity=Machine.getEntity(self)
for queue in G.InternalQueueList:
station=queue.next[0]
# do not send the signal if it is already triggered
if not queue.canDispose.triggered:
self.sendSignal(receiver=queue, signal=queue.canDispose, sender=station)
return activeEntity
示例4: main
from dream.simulation.imports import Machine, Source, Exit, Part, G, Repairman, Queue, Failure
from dream.simulation.imports import simulate, activate, initialize
#define the objects of the model
R=Repairman('R1', 'Bob')
S=Source('S1','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
M1=Machine('M1','Machine1', processingTime={'distributionType':'Fixed','mean':0.25})
Q=Queue('Q1','Queue')
M2=Machine('M2','Machine2', processingTime={'distributionType':'Fixed','mean':1.5})
E=Exit('E1','Exit')
#create failures
F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR':5}, repairman=R)
F2=Failure(victim=M2, distribution={'distributionType':'Fixed','MTTF':40,'MTTR':10}, repairman=R)
G.ObjList=[S,M1,M2,E,Q] #add all the objects in G.ObjList so that they can be easier accessed later
G.MachineList=[M1,M2]
G.ObjectInterruptionList=[F1,F2] #add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
S.defineRouting([M1])
M1.defineRouting([S],[Q])
Q.defineRouting([M1],[M2])
M2.defineRouting([Q],[E])
E.defineRouting([M2])
def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
示例5: main
from dream.simulation.imports import Machine, Source, Exit, Batch, BatchDecomposition,\
BatchSource, BatchReassembly, Queue, LineClearance, ExcelHandler, ExcelHandler
from dream.simulation.Globals import runSimulation
# define the objects of the model
S=BatchSource('S','Source',interArrivalTime={'Fixed':{'mean':1.5}}, entity='Dream.Batch', batchNumberOfUnits=100)
Q=Queue('Q','StartQueue',capacity=100000)
BD=BatchDecomposition('BC', 'BatchDecomposition', numberOfSubBatches=4, processingTime={'Fixed':{'mean':1}})
M1=Machine('M1','Machine1',processingTime={'Fixed':{'mean':0.5}})
Q1=LineClearance('Q1','Queue1',capacity=2)
M2=Machine('M2','Machine2',processingTime={'Fixed':{'mean':4}})
BRA=BatchReassembly('BRA', 'BatchReassembly', numberOfSubBatches=4, processingTime={'Fixed':{'mean':0}})
M3=Machine('M3','Machine3',processingTime={'Fixed':{'mean':1}})
E=Exit('E','Exit')
# define the predecessors and successors for the objects
S.defineRouting([Q])
Q.defineRouting([S],[BD])
BD.defineRouting([Q],[M1])
M1.defineRouting([BD],[Q1])
Q1.defineRouting([M1],[M2])
M2.defineRouting([Q1],[BRA])
BRA.defineRouting([M2],[M3])
M3.defineRouting([BRA],[E])
E.defineRouting([M3])
def main(test=0):
# add all the objects in a list
objectList=[S,Q,BD,M1,Q1,M2,BRA,M3,E]
# set the length of the experiment
示例6: getEntity
def getEntity(self):
activeEntity=Machine.getEntity(self) #call the parent method to get the entity
part=self.getActiveObjectQueue()[0] #retrieve the obtained part
part.machineId=self.id #create an attribute to the obtained part and give it the value of the object's id
return activeEntity #return the entity obtained
示例7: SelectiveQueue
#the custom queue
class SelectiveQueue(Queue):
#override so that it chooses receiver according to priority
def selectReceiver(self,possibleReceivers=[]):
# sort the receivers according to their priority
possibleReceivers.sort(key=lambda x: x.priority, reverse=True)
if possibleReceivers[0].canAccept():
return possibleReceivers[0]
elif possibleReceivers[1].canAccept():
return possibleReceivers[1]
return None
#define the objects of the model
S=Source('S','Source', interArrivalTime={'Fixed':{'mean':0.5}}, entity='Dream.Part')
Q=SelectiveQueue('Q','Queue', capacity=float("inf"))
M1=Machine('M1','Milling1', processingTime={'Fixed':{'mean':0.25}})
M2=Machine('M2','Milling2', processingTime={'Fixed':{'mean':0.25}})
E=Exit('E1','Exit')
F=Failure(victim=M1, distribution={'TTF':{'Fixed':{'mean':60.0}},'TTR':{'Fixed':{'mean':5.0}}})
#create priority attribute in the Machines
M1.priority=10
M2.priority=0
#define predecessors and successors for the objects
S.defineRouting([Q])
Q.defineRouting([S],[M1,M2])
M1.defineRouting([Q],[E])
M2.defineRouting([Q],[E])
E.defineRouting([M1,M2])
示例8: haveToDispose
def haveToDispose(self, callerObject=None):
for object in G.InternalProcessList:
# if there is one other machine processing return False
if object.isProcessing:
return False
return Machine.haveToDispose(self, callerObject)
示例9: initialize
def initialize(self):
Machine.initialize(self)
self.numGoodParts=0
self.state=1
示例10: canAccept
def canAccept(self, callerObject=None):
# do not start processing unless there are enough parts
# (i.e. equal to the number of processes) in the compound machine
if not self.countInternalParts()==len(G.InternalProcessList):
return False
return Machine.canAccept(self, callerObject)
示例11: main
from dream.simulation.imports import Machine, Source, Exit, Part, Frame, Assembly, Failure
from dream.simulation.Globals import runSimulation
#define the objects of the model
Frame.capacity=4
Sp=Source('SP','Parts', interArrivalTime={'Fixed':{'mean':0.5}}, entity='Dream.Part')
Sf=Source('SF','Frames', interArrivalTime={'Fixed':{'mean':2}}, entity='Dream.Frame')
M=Machine('M','Machine', processingTime={'Fixed':{'mean':0.25}})
A=Assembly('A','Assembly', processingTime={'Fixed':{'mean':2}})
E=Exit('E1','Exit')
F=Failure(victim=M, distribution={'TTF':{'Fixed':{'mean':60.0}},'TTR':{'Fixed':{'mean':5.0}}})
#define predecessors and successors for the objects
Sp.defineRouting([A])
Sf.defineRouting([A])
A.defineRouting([Sp,Sf],[M])
M.defineRouting([A],[E])
E.defineRouting([M])
def main(test=0):
# add all the objects in a list
objectList=[Sp,Sf,M,A,E,F]
# set the length of the experiment
maxSimTime=1440.0
# call the runSimulation giving the objects and the length of the experiment
runSimulation(objectList, maxSimTime)
# calculate metrics
working_ratio=(A.totalWorkingTime/maxSimTime)*100
示例12: main
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):
示例13: machine
from dream.simulation.imports import Source, Queue, Machine, Exit
from dream.simulation.Globals import runSimulation
# This is the baby step to building a complicated model of the behavior
# of a fleet of systems with multiple stakeholders.
# The baby step includes:
# A source to generate students
# A Queue for students to wait for a flight
# A machine (aircraft) to give students time
# An exit for graduated students
# The source is API for Aviation Preflight Indocrination
API = Source('API', 'Source', interArrivalTime={'Fixed': {'mean': 0.5}},
entity='Dream.Part')
RR = Queue('ReadyRoom', 'Queue', capacity=1)
AC = Machine('AC1', 'Machine', processingTime={'Fixed': {'mean': 0.25}})
E = Exit('The Fleet', 'The Fleet')
# The predecessors and successors for the objects
API.defineRouting(successorList=[RR])
RR.defineRouting(predecessorList=[API], successorList=[AC])
AC.defineRouting(predecessorList=[RR], successorList=[E])
E.defineRouting(predecessorList=[AC])
def main(test=0):
# add all the objects in a list
objectList=[API, RR, AC, E]
# set the length of the experiment
maxSimTime = 1440.0
# call the runSimulation giving the objects and the length of the
# experiment
示例14: main
from dream.simulation.imports import Machine, BatchSource, Exit, Batch, BatchDecomposition, Queue, G
from dream.simulation.imports import simulate, activate, initialize
# define the objects of the model
S=BatchSource('S','Source',interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Batch', batchNumberOfUnits=4)
Q=Queue('Q','StartQueue',capacity=100000)
BD=BatchDecomposition('BC', 'BatchDecomposition', numberOfSubBatches=4, processingTime={'distributionType':'Fixed','mean':1})
M=Machine('M','Machine',processingTime={'distributionType':'Fixed','mean':0.5})
E=Exit('E','Exit')
# add all the objects in the G.ObjList so that they can be easier accessed later
G.ObjList=[S,Q,BD,M,E]
# define the predecessors and successors for the objects
S.defineRouting([Q])
Q.defineRouting([S],[BD])
BD.defineRouting([Q],[M])
M.defineRouting([BD],[E])
E.defineRouting([M])
def main():
# initialize the simulation (SimPy method)
initialize()
# initialize all the objects
for object in G.ObjList:
object.initialize()
# activate all the objects
for object in G.ObjList:
activate(object,object.run())
# set G.maxSimTime 1440.0 minutes (1 day)
G.maxSimTime=1440.0
# run the simulation
simulate(until=G.maxSimTime)
示例15: postProcessing
def postProcessing(self):
Machine.postProcessing(self, MaxSimtime=maxSimTime)
self.GoodExits.append(self.numGoodParts)