new method canEntityProceed added for the jobshop case

parent 04fa9d7e
......@@ -156,3 +156,27 @@ class ConditionalBuffer(QueueManagedJob):
and\
x.order.basicsEnded),reverse=True)
# activeObjectQueue.sort(key=lambda x: x.managerAvailable, reverse=True)
#===========================================================================
# checks whether the entity can proceed to a successor object
#===========================================================================
def canEntityProceed(self, entity=None):
activeObject=self.getActiveObject()
activeObjectQueue=activeObject.getActiveObjectQueue()
assert entity in activeObjectQueue, entity.id +' not in the internalQueue of'+ activeObject.id
activeEntity=entity
# for entities of type OrderComponent, if they reside at a conditionalBuffer,
# they must wait till their basicsEnded flag is raised
if activeEntity.type=='OrderComponent':
if (activeEntity.componentType=='Secondary'\
and activeEntity.order.basicsEnded==False):
return False
mayProceed=False
# for all the possible receivers of an entity check whether they can accept and then set accordingly the canProceed flag of the entity
for nextObject in [object for object in activeObject.next if object.canAcceptEntity(activeEntity)]:
activeEntity.canProceed=True
activeEntity.candidateReceivers.append(nextObject)
mayProceed=True
return mayProceed
\ No newline at end of file
......@@ -469,6 +469,12 @@ class CoreObject(Process):
maxTimeWaiting=timeWaiting
return giver
#===========================================================================
# checks whether the entity can proceed to a successor object
#===========================================================================
def canEntityProceed(self):
pass
# =======================================================================
# actions to be taken after the simulation ends
# =======================================================================
......
......@@ -798,6 +798,24 @@ class Machine(CoreObject):
candidateOperator.candidateStations.append(activeObject)
return candidateOperator
#===========================================================================
# checks whether the entity can proceed to a successor object
#===========================================================================
def canEntityProceed(self, entity=None):
activeObject=self.getActiveObject()
activeObjectQueue=activeObject.getActiveObjectQueue()
assert entity in activeObjectQueue, entity.id +' not in the internalQueue of'+ activeObject.id
activeEntity=entity
from Globals import G
router = G.Router
# if the entity is in a machines who's broker waits for operator then
if activeObject in router.pendingMachines:
activeEntity.canProceed=True
activeEntity.candidateReceivers.append(activeObject)
return True
return False
# =======================================================================
# prepare the machine to be operated
# =======================================================================
......
......@@ -180,3 +180,23 @@ class MouldAssemblyBuffer(QueueManagedJob):
return thecaller.isInRoute(activeObject)\
and thecaller.getActiveObjectQueue()[0].order is activeEntity.order\
and activeEntity.order.componentsReadyForAssembly
#===========================================================================
# checks whether the entity can proceed to a successor object
#===========================================================================
def canEntityProceed(self, entity=None):
activeObject=self.getActiveObject()
activeObjectQueue=activeObject.getActiveObjectQueue()
assert entity in activeObjectQueue, entity.id +' not in the internalQueue of'+ activeObject.id
activeEntity=entity
# unassembled components of a mould must wait at a MouldAssemblyBuffer till the componentsReadyForAssembly flag is raised
if not activeEntity.order.componentsReadyForAssembly:
return False
mayProceed=False
# for all the possible receivers of an entity check whether they can accept and then set accordingly the canProceed flag of the entity
for nextObject in [object for object in activeObject.next if object.canAcceptEntity(activeEntity)]:
activeEntity.canProceed=True
activeEntity.candidateReceivers.append(nextObject)
mayProceed=True
return mayProceed
......@@ -384,35 +384,43 @@ class Router(ObjectInterruption):
for entity in [x for x in self.pending if x.manager]:
# if the entity is ready to move to a machine and its manager is available
if entity.manager.checkIfResourceIsAvailable():
# for entities of type OrderComponent, if they reside at a conditionalBuffer,
# they must wait till their basicsEnded flag is raised
if entity.type=='OrderComponent':
from ConditionalBuffer import ConditionalBuffer
if (entity.componentType=='Secondary'\
and type(entity.currentStation) is ConditionalBuffer\
and entity.order.basicsEnded==False):
continue
# unassembled components of a mould must wait at a MouldAssemblyBuffer till the componentsReadyForAssembly flag is raised
from MouldAssemblyBuffer import MouldAssemblyBuffer
if type(entity.currentStation) is MouldAssemblyBuffer:
if not entity.order.componentsReadyForAssembly:
continue
# for all the possible receivers of an entity check whether they can accept and then set accordingly the canProceed flag of the entity
if not entity.currentStation in self.pendingMachines:
for nextObject in [object for object in entity.currentStation.next if object.canAcceptEntity(entity)]:
entity.canProceed=True
entity.candidateReceivers.append(nextObject)
# if the entity is in a machines who's broker waits for operator then
if entity.currentStation in self.pendingMachines:
entity.canProceed=True
entity.candidateReceivers.append(entity.currentStation)
# if the entity can proceed, add its manager to the candidateOperators list
if entity.canProceed and not entity.manager in self.candidateOperators:
# check whether the entity canProceed and update the its candidateReceivers
if entity.currentStation.canEntityProceed(entity)\
and not entity.manager in self.candidateOperators:
self.candidateOperators.append(entity.manager)
# # for entities of type OrderComponent, if they reside at a conditionalBuffer,
# # they must wait till their basicsEnded flag is raised
# if entity.type=='OrderComponent':
# from ConditionalBuffer import ConditionalBuffer
# if (entity.componentType=='Secondary'\
# and type(entity.currentStation) is ConditionalBuffer\
# and entity.order.basicsEnded==False):
# continue
# # unassembled components of a mould must wait at a MouldAssemblyBuffer till the componentsReadyForAssembly flag is raised
# from MouldAssemblyBuffer import MouldAssemblyBuffer
# if type(entity.currentStation) is MouldAssemblyBuffer:
# if not entity.order.componentsReadyForAssembly:
# continue
# # for all the possible receivers of an entity check whether they can accept and then set accordingly the canProceed flag of the entity
# if not entity.currentStation in self.pendingMachines:
# for nextObject in [object for object in entity.currentStation.next if object.canAcceptEntity(entity)]:
# entity.canProceed=True
# entity.candidateReceivers.append(nextObject)
# # if the entity is in a machines who's broker waits for operator then
# if entity.currentStation in self.pendingMachines:
# entity.canProceed=True
# entity.candidateReceivers.append(entity.currentStation)
#
# # if the entity can proceed, add its manager to the candidateOperators list
# if entity.canProceed and not entity.manager in self.candidateOperators:
# self.candidateOperators.append(entity.manager)
# update the schedulingRule/multipleCriterionList of the Router
if self.sorting:
self.updateSchedulingRule()
# find the candidateEntities for each operator
self.findCandidateEntities()
#=======================================================================
# # testing
......@@ -430,9 +438,6 @@ class Router(ObjectInterruption):
for operator in self.candidateOperators:
# find which pendingEntities that can move to machines is the operator managing
operator.pickCandidateEntitiesFrom(self.pending)
# for entity in [x for x in self.pending if x.canProceed and x.manager==operator]:
# operator.candidateEntities.append(entity)
# print ' ', [x.id for x in operator.candidateEntities]
#=======================================================================
# find the schedulingRules of the candidateOperators
......
......@@ -197,6 +197,23 @@ class Queue(CoreObject):
def getEntity(self):
activeEntity=CoreObject.getEntity(self) #run the default behavior
return activeEntity
#===========================================================================
# checks whether the entity can proceed to a successor object
#===========================================================================
def canEntityProceed(self, entity=None):
activeObject=self.getActiveObject()
activeObjectQueue=activeObject.getActiveObjectQueue()
assert entity in activeObjectQueue, entity.id +' not in the internalQueue of'+ activeObject.id
activeEntity=entity
mayProceed=False
# for all the possible receivers of an entity check whether they can accept and then set accordingly the canProceed flag of the entity
for nextObject in [object for object in activeObject.next if object.canAcceptEntity(activeEntity)]:
activeEntity.canProceed=True
activeEntity.candidateReceivers.append(nextObject)
mayProceed=True
return mayProceed
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
......
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