Commit f181a2c0 authored by Georgios Dagkakis's avatar Georgios Dagkakis

several changes. Model that uses only Source-Queue-Exit runs for 1 replication

parent 302452f4
...@@ -258,7 +258,7 @@ class CoreObject(ManPyObject): ...@@ -258,7 +258,7 @@ class CoreObject(ManPyObject):
if self.checkForDedicatedOperators(): if self.checkForDedicatedOperators():
allocationNeeded=False allocationNeeded=False
from Globals import ManPyEnvironment from Globals import ManPyEnvironment
for obj in G.MachineList: for obj in self.environment.MachineList:
if obj.operatorPool!='None': if obj.operatorPool!='None':
if obj.operatorPool.operators: if obj.operatorPool.operators:
allocationNeeded=False allocationNeeded=False
...@@ -291,7 +291,7 @@ class CoreObject(ManPyObject): ...@@ -291,7 +291,7 @@ class CoreObject(ManPyObject):
self.offShiftTimeTryingToReleaseCurrentEntity=0 self.offShiftTimeTryingToReleaseCurrentEntity=0
self.timeLastEntityLeft=self.env.now self.timeLastEntityLeft=self.env.now
self.outputTrace(entity.name, "released "+self.objName) self.outputTrace(self.environment,entity.name, "released "+self.objName)
#append the time to schedule so that it can be read in the result #append the time to schedule so that it can be read in the result
#remember that every entity has it's schedule which is supposed to be updated every time #remember that every entity has it's schedule which is supposed to be updated every time
...@@ -380,8 +380,8 @@ class CoreObject(ManPyObject): ...@@ -380,8 +380,8 @@ class CoreObject(ManPyObject):
self.nameLastEntityEntered=activeEntity.name # this holds the name of the last entity that got into object self.nameLastEntityEntered=activeEntity.name # this holds the name of the last entity that got into object
# update the next list of the object # update the next list of the object
self.updateNext(activeEntity) self.updateNext(activeEntity)
self.outputTrace(activeEntity.name, "got into "+self.objName) self.outputTrace(self.environment,activeEntity.name, "got into "+self.objName)
self.printTrace(activeEntity.name, enter=self.id) self.printTrace(self.environment,activeEntity.name, enter=self.id)
# # if there are entities with requiredParts then check whether the requirements are fulfilled for them to proceed # # if there are entities with requiredParts then check whether the requirements are fulfilled for them to proceed
# # ass soon as a "buffer" receives an entity it controls if the entity is requested elsewhere, # # ass soon as a "buffer" receives an entity it controls if the entity is requested elsewhere,
# # then it checks if there other requested entities by the same requesting entity. # # then it checks if there other requested entities by the same requesting entity.
...@@ -389,7 +389,7 @@ class CoreObject(ManPyObject): ...@@ -389,7 +389,7 @@ class CoreObject(ManPyObject):
# # their sequences for the requesting entity # # their sequences for the requesting entity
# from Globals import ManPyEnvironment # from Globals import ManPyEnvironment
# # for all the entities in the EntityList # # for all the entities in the EntityList
# for entity in G.EntityList: # for entity in self.environment.EntityList:
# requiredParts=entity.getRequiredParts() # requiredParts=entity.getRequiredParts()
# if requiredParts: # if requiredParts:
# # if the activeEntity is in the requierdParts of the entity # # if the activeEntity is in the requierdParts of the entity
...@@ -493,7 +493,7 @@ class CoreObject(ManPyObject): ...@@ -493,7 +493,7 @@ class CoreObject(ManPyObject):
def signalReceiver(self): def signalReceiver(self):
possibleReceivers=self.findReceiversFor(self) possibleReceivers=self.findReceiversFor(self)
if possibleReceivers: if possibleReceivers:
receiver=self.selectReceiver(possibleReceivers) receiver=self.selectReceiver(self.environment,possibleReceivers)
receiversGiver=self receiversGiver=self
# perform the checks that canAcceptAndIsRequested used to perform and update activeCallersList or assignExit and operatorPool # perform the checks that canAcceptAndIsRequested used to perform and update activeCallersList or assignExit and operatorPool
while not receiver.canAcceptAndIsRequested(receiversGiver): while not receiver.canAcceptAndIsRequested(receiversGiver):
...@@ -514,7 +514,7 @@ class CoreObject(ManPyObject): ...@@ -514,7 +514,7 @@ class CoreObject(ManPyObject):
self.receiver=receiver self.receiver=receiver
self.receiver.giver=self self.receiver.giver=self
self.printTrace(self.id, signalReceiver=self.receiver.id) self.printTrace(self.environment,self.id, signalReceiver=self.receiver.id)
# assign the entry of the receiver # assign the entry of the receiver
self.receiver.assignEntryTo() self.receiver.assignEntryTo()
# assign the exit of the current object to the receiver # assign the exit of the current object to the receiver
...@@ -530,14 +530,14 @@ class CoreObject(ManPyObject): ...@@ -530,14 +530,14 @@ class CoreObject(ManPyObject):
# select a receiver Object # select a receiver Object
# ======================================================================= # =======================================================================
@staticmethod @staticmethod
def selectReceiver(possibleReceivers=[]): def selectReceiver(environment,possibleReceivers=[]):
candidates=possibleReceivers candidates=possibleReceivers
# dummy variables that help prioritize the objects requesting to give objects to the object (activeObject) # dummy variables that help prioritize the objects requesting to give objects to the object (activeObject)
maxTimeWaiting=0 # dummy variable counting the time a successor is waiting maxTimeWaiting=0 # dummy variable counting the time a successor is waiting
receiver=None receiver=None
from Globals import ManPyEnvironment from Globals import ManPyEnvironment
for object in candidates: for object in candidates:
timeWaiting=G.env.now-object.timeLastEntityLeft # the time it has been waiting is updated and stored in dummy variable timeWaiting timeWaiting=environment.env.now-object.timeLastEntityLeft # the time it has been waiting is updated and stored in dummy variable timeWaiting
if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):# if the timeWaiting is the maximum among the ones of the successors if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):# if the timeWaiting is the maximum among the ones of the successors
maxTimeWaiting=timeWaiting maxTimeWaiting=timeWaiting
receiver=object # set the receiver as the longest waiting possible receiver receiver=object # set the receiver as the longest waiting possible receiver
...@@ -602,7 +602,7 @@ class CoreObject(ManPyObject): ...@@ -602,7 +602,7 @@ class CoreObject(ManPyObject):
# loop through the possible givers to see which have to dispose and which is the one blocked for longer # loop through the possible givers to see which have to dispose and which is the one blocked for longer
for object in candidates: for object in candidates:
# calculate how much the giver is waiting # calculate how much the giver is waiting
timeWaiting=G.env.now-object.timeLastEntityEnded timeWaiting=self.environment.env.now-object.timeLastEntityEnded
if(timeWaiting>=maxTimeWaiting): if(timeWaiting>=maxTimeWaiting):
giver=object # the object to deliver the Entity to the activeObject is set to the ith member of the previous list giver=object # the object to deliver the Entity to the activeObject is set to the ith member of the previous list
maxTimeWaiting=timeWaiting maxTimeWaiting=timeWaiting
...@@ -670,7 +670,7 @@ class CoreObject(ManPyObject): ...@@ -670,7 +670,7 @@ class CoreObject(ManPyObject):
if now==float('inf'): if now==float('inf'):
now=0 now=0
lastExits=[] lastExits=[]
for object in G.ExitList: for object in self.environment.ExitList:
lastExits.append(object.timeLastEntityEntered) lastExits.append(object.timeLastEntityEntered)
if lastExits: if lastExits:
now=max(lastExits) now=max(lastExits)
......
...@@ -105,14 +105,14 @@ class Exit(CoreObject): ...@@ -105,14 +105,14 @@ class Exit(CoreObject):
# ======================================================================= # =======================================================================
def getEntity(self): def getEntity(self):
activeEntity = CoreObject.getEntity(self) #run the default method activeEntity = CoreObject.getEntity(self) #run the default method
# if the entity is in the G.pendingEntities list then remove it from there # if the entity is in the self.environment.pendingEntities list then remove it from there
from Globals import ManPyEnvironment from Globals import ManPyEnvironment
# G.pendingEntities[:]=(entity for entity in G.pendingEntities if not entity is activeEntity) # self.environment.pendingEntities[:]=(entity for entity in self.environment.pendingEntities if not entity is activeEntity)
if G.RouterList: if self.environment.RouterList:
if activeEntity in G.pendingEntities: if activeEntity in self.environment.pendingEntities:
G.pendingEntities.remove(activeEntity) self.environment.pendingEntities.remove(activeEntity)
# if activeEntity in G.EntityList: # if activeEntity in self.environment.EntityList:
# G.EntityList.remove(activeEntity) # self.environment.EntityList.remove(activeEntity)
# self.clear(activeEntity) # self.clear(activeEntity)
self.totalLifespan+=self.env.now-activeEntity.startTime #Add the entity's lifespan to the total one. self.totalLifespan+=self.env.now-activeEntity.startTime #Add the entity's lifespan to the total one.
self.numOfExits+=1 # increase the exits by one self.numOfExits+=1 # increase the exits by one
...@@ -135,10 +135,10 @@ class Exit(CoreObject): ...@@ -135,10 +135,10 @@ class Exit(CoreObject):
def deleteEntityfromlist(entity, list): def deleteEntityfromlist(entity, list):
if entity in list: if entity in list:
list.remove(entity) list.remove(entity)
lists=(G.EntityList, G.PartList, G.pendingEntities, G.WipList) lists=(self.environment.EntityList, self.environment.PartList, self.environment.pendingEntities, self.environment.WipList)
# lists=(G.EntityList, G.PartList, G.BatchList, G.SubBatchList, # lists=(self.environment.EntityList, self.environment.PartList, self.environment.BatchList, self.environment.SubBatchList,
# G.JobList, G.OrderList, G.OrderComponentList, G.MouldList, # self.environment.JobList, self.environment.OrderList, self.environment.OrderComponentList, self.environment.MouldList,
# G.pendingEntities, G.WipList) # self.environment.pendingEntities, self.environment.WipList)
for list in lists: for list in lists:
deleteEntityfromlist(entity,list) deleteEntityfromlist(entity,list)
...@@ -158,11 +158,11 @@ class Exit(CoreObject): ...@@ -158,11 +158,11 @@ class Exit(CoreObject):
self.Exits.append(self.numOfExits) self.Exits.append(self.numOfExits)
self.UnitExits.append(self.totalNumberOfUnitsExited) self.UnitExits.append(self.totalNumberOfUnitsExited)
try: # throw exception in case the numOfExits is zero try: # throw exception in case the numOfExits is zero
self.Lifespan.append(((self.totalLifespan)/self.numOfExits)/G.Base) self.Lifespan.append(((self.totalLifespan)/self.numOfExits)/self.environment.Base)
except ZeroDivisionError: # the lifespan in this case is zero except ZeroDivisionError: # the lifespan in this case is zero
self.Lifespan.append(0) self.Lifespan.append(0)
try: # throw exception in case of zero division try: # throw exception in case of zero division
self.TaktTime.append(((self.totalTaktTime)/self.numOfExits)/G.Base) self.TaktTime.append(((self.totalTaktTime)/self.numOfExits)/self.environment.Base)
except ZeroDivisionError: # the average time between exits is zero if no Entity exited except ZeroDivisionError: # the average time between exits is zero if no Entity exited
self.TaktTime.append(0) self.TaktTime.append(0)
......
...@@ -113,11 +113,10 @@ class ManPyEnvironment(object): ...@@ -113,11 +113,10 @@ class ManPyEnvironment(object):
self.SubBatchList=[] self.SubBatchList=[]
# entities that just finished processing in a station # entities that just finished processing in a station
# and have to enter the next machine # and have to enter the next machine
self.pendingEntities=[] self.pendingEntities=[]
self.env=simpy.Environment()
self.totalPulpTime=0 # temporary to track how much time PuLP needs to run self.totalPulpTime=0 # temporary to track how much time PuLP needs to run
self.SimPyEnvironment=simpy.Environment() self.SimPyEnvironment=simpy.Environment()
self.env=self.SimPyEnvironment
# ======================================================================= # =======================================================================
# method to move entities exceeding a certain safety stock # method to move entities exceeding a certain safety stock
......
{
"graph": {
"node": {
"E1": {
"interruptions": {},
"top": 0.10215053763440862,
"_class": "Dream.Exit",
"name": "Stock",
"left": 0.5
},
"S1": {
"name": "Raw Material",
"top": 0.8978494623655914,
"entity": "Dream.Part",
"interArrivalTime": {
"Fixed": {
"distributionType": "Fixed",
"mean": 0.5
}
},
"interruptions": {},
"_class": "Dream.Source",
"left": 0.5
},
"Q1": {
"name": "Queue",
"top": 0.5,
"interruptions": {},
"_class": "Dream.Queue",
"left": 0.5
}
},
"edge": {
"1": {
"source": "Q1",
"destination": "E1",
"data": {},
"_class": "Dream.Edge"
},
"0": {
"source": "S1",
"destination": "Q1",
"data": {},
"_class": "Dream.Edge"
}
}
},
"_class": "Dream.Simulation",
"general": {
"maxSimTime": "10",
"_class": "Dream.Configuration",
"confidenceLevel": "0.95",
"trace": "No",
"numberOfReplications": "1"
}
}
\ No newline at end of file
...@@ -600,9 +600,9 @@ def initializeObjects(environment): ...@@ -600,9 +600,9 @@ def initializeObjects(environment):
# =========================================================================== # ===========================================================================
def activateObjects(environment): def activateObjects(environment):
for element in environment.ObjectInterruptionList: for element in environment.ObjectInterruptionList:
environment.env.process(element.run()) environment.SimPyEnvironment.process(element.run())
for element in environment.ObjList: for element in environment.ObjList:
environment.env.process(element.run()) environment.SimPyEnvironment.process(element.run())
# =========================================================================== # ===========================================================================
# the main script that is ran # the main script that is ran
...@@ -637,7 +637,7 @@ def main(argv=[], input_data=None): ...@@ -637,7 +637,7 @@ def main(argv=[], input_data=None):
#run the experiment (replications) #run the experiment (replications)
for i in xrange(environment.numberOfReplications): for i in xrange(environment.numberOfReplications):
environment.env=simpy.Environment() # initialize the environment # environment.env=simpy.Environment() # initialize the environment
environment.maxSimTime=float(JSONData['general'].get('maxSimTime', '100')) # read the maxSimTime in each replication environment.maxSimTime=float(JSONData['general'].get('maxSimTime', '100')) # read the maxSimTime in each replication
# since it may be changed for infinite ones # since it may be changed for infinite ones
if environment.RouterList: if environment.RouterList:
...@@ -659,7 +659,7 @@ def main(argv=[], input_data=None): ...@@ -659,7 +659,7 @@ def main(argv=[], input_data=None):
# then we have to find the end time as the time the last entity ended. # then we have to find the end time as the time the last entity ended.
if environment.maxSimTime==-1: if environment.maxSimTime==-1:
# If someone does it for a model that has always events, then it will run forever! # If someone does it for a model that has always events, then it will run forever!
environment.env.run(until=float('inf')) environment.SimPyEnvironment.run(until=float('inf'))
# identify from the exits what is the time that the last entity has ended. # identify from the exits what is the time that the last entity has ended.
endList=[] endList=[]
...@@ -667,14 +667,14 @@ def main(argv=[], input_data=None): ...@@ -667,14 +667,14 @@ def main(argv=[], input_data=None):
endList.append(exit.timeLastEntityLeft) endList.append(exit.timeLastEntityLeft)
# identify the time of the last event # identify the time of the last event
if float(max(endList))!=0 and G.env.now==float('inf'): #do not let G.maxSimTime=0 so that there will be no crash if float(max(endList))!=0 and environment.SimPyEnvironment.now==float('inf'): #do not let G.maxSimTime=0 so that there will be no crash
environment.maxSimTime=float(max(endList)) environment.maxSimTime=float(max(endList))
else: else:
print "simulation ran for 0 time, something may have gone wrong" print "simulation ran for 0 time, something may have gone wrong"
logger.info("simulation ran for 0 time, something may have gone wrong") logger.info("simulation ran for 0 time, something may have gone wrong")
#else we simulate until the given maxSimTime #else we simulate until the given maxSimTime
else: else:
environment.env.run(until=environment.maxSimTime) environment.SimPyEnvironment.run(until=environment.maxSimTime)
#carry on the post processing operations for every object in the topology #carry on the post processing operations for every object in the topology
for element in environment.ObjList+environment.ObjectResourceList+environment.RouterList: for element in environment.ObjList+environment.ObjectResourceList+environment.RouterList:
......
...@@ -133,19 +133,19 @@ class ManPyObject(object): ...@@ -133,19 +133,19 @@ class ManPyObject(object):
# outputs message to the trace.xls. Format is (Simulation Time | Entity or Frame Name | message) # outputs message to the trace.xls. Format is (Simulation Time | Entity or Frame Name | message)
# ======================================================================= # =======================================================================
@staticmethod @staticmethod
def outputTrace(entityName, message): def outputTrace(environment,entityName, message):
from Globals import ManPyEnvironment from Globals import ManPyEnvironment
if(G.trace=="Yes"): #output only if the user has selected to if(environment.trace=="Yes"): #output only if the user has selected to
#handle the 3 columns #handle the 3 columns
G.traceSheet.write(G.traceIndex,0,str(G.env.now)) environment.traceSheet.write(environment.traceIndex,0,str(environment.env.now))
G.traceSheet.write(G.traceIndex,1,entityName) environment.traceSheet.write(environment.traceIndex,1,entityName)
G.traceSheet.write(G.traceIndex,2,message) environment.traceSheet.write(environment.traceIndex,2,message)
G.traceIndex+=1 #increment the row environment.traceIndex+=1 #increment the row
#if we reach row 65536 we need to create a new sheet (excel limitation) #if we reach row 65536 we need to create a new sheet (excel limitation)
if(G.traceIndex==65536): if(environment.traceIndex==65536):
G.traceIndex=0 environment.traceIndex=0
G.sheetIndex+=1 environment.sheetIndex+=1
G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True) environment.traceSheet=environment.traceFile.add_sheet('sheet '+str(environment.sheetIndex), cell_overwrite_ok=True)
#=========================================================================== #===========================================================================
# sends a signal # sends a signal
......
...@@ -104,11 +104,11 @@ class Queue(CoreObject): ...@@ -104,11 +104,11 @@ class Queue(CoreObject):
self.expectedSignals['isRequested']=1 self.expectedSignals['isRequested']=1
self.expectedSignals['loadOperatorAvailable']=1 self.expectedSignals['loadOperatorAvailable']=1
receivedEvent=yield self.env.any_of([self.isRequested, self.canDispose, self.loadOperatorAvailable]) receivedEvent=yield self.env.any_of([self.isRequested, self.canDispose, self.loadOperatorAvailable])
self.printTrace(self.id, received='') self.printTrace(self.environment,self.id, received='')
# if the event that activated the thread is isRequested then getEntity # if the event that activated the thread is isRequested then getEntity
if self.isRequested in receivedEvent: if self.isRequested in receivedEvent:
transmitter, eventTime=self.isRequested.value transmitter, eventTime=self.isRequested.value
self.printTrace(self.id, isRequested=transmitter.id) self.printTrace(self.environment,self.id, isRequested=transmitter.id)
# reset the isRequested signal parameter # reset the isRequested signal parameter
self.isRequested=self.env.event() self.isRequested=self.env.event()
self.getEntity() self.getEntity()
......
...@@ -44,6 +44,7 @@ class EntityGenerator(object): ...@@ -44,6 +44,7 @@ class EntityGenerator(object):
def __init__(self, victim=None): def __init__(self, victim=None):
self.type="EntityGenerator" #String that shows the type of object self.type="EntityGenerator" #String that shows the type of object
self.victim=victim self.victim=victim
self.environment=victim.environment
self.env=victim.environment.SimPyEnvironment self.env=victim.environment.SimPyEnvironment
#=========================================================================== #===========================================================================
...@@ -57,11 +58,11 @@ class EntityGenerator(object): ...@@ -57,11 +58,11 @@ class EntityGenerator(object):
entity.creationTime=self.env.now # assign the current simulation time as the Entity's creation time entity.creationTime=self.env.now # assign the current simulation time as the Entity's creation time
entity.startTime=self.env.now # assign the current simulation time as the Entity's start time entity.startTime=self.env.now # assign the current simulation time as the Entity's start time
entity.currentStation=self.victim # update the current station of the Entity entity.currentStation=self.victim # update the current station of the Entity
G.EntityList.append(entity) self.environment.EntityList.append(entity)
self.victim.outputTrace(entity.name, "generated") # output the trace self.victim.outputTrace(self.environment,entity.name, "generated") # output the trace
self.victim.getActiveObjectQueue().append(entity) # append the entity to the resource self.victim.getActiveObjectQueue().append(entity) # append the entity to the resource
self.victim.numberOfArrivals+=1 # we have one new arrival self.victim.numberOfArrivals+=1 # we have one new arrival
G.numberOfEntities+=1 self.environment.numberOfEntities+=1
self.victim.appendEntity(entity) self.victim.appendEntity(entity)
if self.victim.expectedSignals['entityCreated']: if self.victim.expectedSignals['entityCreated']:
succeedTupple=(entity,self.env.now) succeedTupple=(entity,self.env.now)
...@@ -69,7 +70,7 @@ class EntityGenerator(object): ...@@ -69,7 +70,7 @@ class EntityGenerator(object):
self.victim.expectedSignals['entityCreated']=0 self.victim.expectedSignals['entityCreated']=0
# else put it on the time list for scheduled Entities # else put it on the time list for scheduled Entities
else: else:
entityCounter=G.numberOfEntities+len(self.victim.scheduledEntities) # this is used just ot output the trace correctly entityCounter=self.environment.numberOfEntities+len(self.victim.scheduledEntities) # this is used just ot output the trace correctly
self.victim.scheduledEntities.append(self.env.now) self.victim.scheduledEntities.append(self.env.now)
self.victim.outputTrace(self.victim.item.type+str(entityCounter), "generated") # output the trace self.victim.outputTrace(self.victim.item.type+str(entityCounter), "generated") # output the trace
yield self.env.timeout(self.victim.calculateInterArrivalTime()) # wait until the next arrival yield self.env.timeout(self.victim.calculateInterArrivalTime()) # wait until the next arrival
...@@ -117,13 +118,9 @@ class Source(CoreObject): ...@@ -117,13 +118,9 @@ class Source(CoreObject):
self.entityGenerator=EntityGenerator(victim=self) # the EntityGenerator of the Source self.entityGenerator=EntityGenerator(victim=self) # the EntityGenerator of the Source
self.numberOfArrivals = 0 self.numberOfArrivals = 0
# self.entityGenerator.initialize()
# activate(self.entityGenerator,self.entityGenerator.run())
self.env.process(self.entityGenerator.run()) self.env.process(self.entityGenerator.run())
# self.entityCreated=SimEvent('an entity is created')
self.entityCreated=self.env.event() self.entityCreated=self.env.event()
# event used by router # event used by router
# self.loadOperatorAvailable=SimEvent('loadOperatorAvailable')
self.loadOperatorAvailable=self.env.event() self.loadOperatorAvailable=self.env.event()
self.scheduledEntities=[] # list of creations that are scheduled self.scheduledEntities=[] # list of creations that are scheduled
...@@ -144,7 +141,7 @@ class Source(CoreObject): ...@@ -144,7 +141,7 @@ class Source(CoreObject):
self.expectedSignals['entityCreated']=1 self.expectedSignals['entityCreated']=1
self.expectedSignals['loadOperatorAvailable']=1 self.expectedSignals['loadOperatorAvailable']=1
receivedEvent=yield self.env.any_of([self.entityCreated, self.canDispose, self.loadOperatorAvailable]) receivedEvent=yield self.env.any_of([self.entityCreated, self.canDispose, self.loadOperatorAvailable])
self.printTrace(self.id, received='') self.printTrace(self.environment,self.id, received='')
# if an entity is created try to signal the receiver and continue # if an entity is created try to signal the receiver and continue
if self.entityCreated in receivedEvent: if self.entityCreated in receivedEvent:
transmitter, eventTime=self.entityCreated.value transmitter, eventTime=self.entityCreated.value
...@@ -167,9 +164,9 @@ class Source(CoreObject): ...@@ -167,9 +164,9 @@ class Source(CoreObject):
from Globals import ManPyEnvironment from Globals import ManPyEnvironment
assert entity, 'cannot append None entity' assert entity, 'cannot append None entity'
activeEntity=entity activeEntity=entity
if G.RouterList: if self.environment.RouterList:
# at the newly created entity to the pendingEntities # at the newly created entity to the pendingEntities
G.pendingEntities.append(activeEntity) self.environment.pendingEntities.append(activeEntity)
#============================================================================ #============================================================================
# sets the routing out element for the Source # sets the routing out element for the Source
...@@ -180,8 +177,9 @@ class Source(CoreObject): ...@@ -180,8 +177,9 @@ class Source(CoreObject):
# creates an Entity # creates an Entity
#============================================================================ #============================================================================
def createEntity(self): def createEntity(self):
self.printTrace(self.id, create='') self.printTrace(self.environment,self.id, create='')
return self.item(id = self.item.type+str(G.numberOfEntities), name = self.item.type+str(self.numberOfArrivals)) #return the newly created Entity return self.item(id = self.item.type+str(self.environment.numberOfEntities),
name = self.item.type+str(self.numberOfArrivals)) #return the newly created Entity
#============================================================================ #============================================================================
# calculates the processing time # calculates the processing time
#============================================================================ #============================================================================
...@@ -198,10 +196,10 @@ class Source(CoreObject): ...@@ -198,10 +196,10 @@ class Source(CoreObject):
newEntity.startTime=newEntity.creationTime # assign the current simulation time as the Entity's start time newEntity.startTime=newEntity.creationTime # assign the current simulation time as the Entity's start time
#print self.env.now, 'getting from the list. StartTime=',newEntity.startTime #print self.env.now, 'getting from the list. StartTime=',newEntity.startTime
newEntity.currentStation=self # update the current station of the Entity newEntity.currentStation=self # update the current station of the Entity
G.EntityList.append(newEntity) self.environment.EntityList.append(newEntity)
self.getActiveObjectQueue().append(newEntity) # append the entity to the resource self.getActiveObjectQueue().append(newEntity) # append the entity to the resource
self.numberOfArrivals+=1 # we have one new arrival self.numberOfArrivals+=1 # we have one new arrival
G.numberOfEntities+=1 self.environment.numberOfEntities+=1
self.appendEntity(newEntity) self.appendEntity(newEntity)
activeEntity=CoreObject.removeEntity(self, entity) # run the default method activeEntity=CoreObject.removeEntity(self, entity) # run the default method
if len(self.getActiveObjectQueue())==1: if len(self.getActiveObjectQueue())==1:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment