Operator sorts also according to preemption needs

parent 847c8a4c
...@@ -132,10 +132,6 @@ class MachineManagedJob(MachineJobShop): ...@@ -132,10 +132,6 @@ class MachineManagedJob(MachineJobShop):
giverObject.assignExitTo(activeObject) giverObject.assignExitTo(activeObject)
elif giverObject.exitIsAssignedTo()!=activeObject: elif giverObject.exitIsAssignedTo()!=activeObject:
return False return False
# if the activeObject is not in manager's activeCallersList of the entityToGet
if activeObject not in giverObjectQueue[0].manager.activeCallersList:
# append it to the activeCallerList of the manager of the entity to be received
giverObjectQueue[0].manager.activeCallersList.append(self)
# update entityToGet # update entityToGet
activeObject.entityToGet=giverObjectQueue[0] activeObject.entityToGet=giverObjectQueue[0]
#make the operators List so that it holds only the manager of the current order #make the operators List so that it holds only the manager of the current order
......
...@@ -49,7 +49,7 @@ class Operator(ObjectResource): ...@@ -49,7 +49,7 @@ class Operator(ObjectResource):
self.Working=[] # holds the percentage of working time self.Working=[] # holds the percentage of working time
# the following attributes are not used by the Repairman # the following attributes are not used by the Repairman
self.activeCallersList=[] # the list of object that request the operator # self.activeCallersList=[] # the list of object that request the operator
self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows
self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue
SRlist = [schedulingRule] SRlist = [schedulingRule]
...@@ -164,16 +164,28 @@ class Operator(ObjectResource): ...@@ -164,16 +164,28 @@ class Operator(ObjectResource):
# now picks the machine that waits the most # now picks the machine that waits the most
# ======================================================================= # =======================================================================
def sortCandidateEntities(self): def sortCandidateEntities(self):
from Globals import G
router=G.Router
candidateMachines=self.candidateStations candidateMachines=self.candidateStations
# for the candidateMachines # for the candidateMachines
if candidateMachines: if candidateMachines:
# choose the one that waits the most time and give it the chance to grasp the resource # choose the one that waits the most time and give it the chance to grasp the resource
for machine in candidateMachines: for machine in candidateMachines:
machine.critical=False
if machine.broker.waitForOperator: if machine.broker.waitForOperator:
machine.timeWaiting=now()-machine.broker.timeWaitForOperatorStarted machine.timeWaiting=now()-machine.broker.timeWaitForOperatorStarted
else: else:
machine.timeWaiting=now()-machine.timeLastEntityLeft machine.timeWaiting=now()-machine.timeLastEntityLeft
# find the stations that hold critical entities
if self in router.preemptiveOperators:
for entity in station.getActiveObjectQueue():
if entity.isCritical:
machine.critical=True
break
# sort the stations according their timeWaiting
self.candidateStations.sort(key= lambda x: x.timeWaiting, reverse=True) self.candidateStations.sort(key= lambda x: x.timeWaiting, reverse=True)
# sort the stations if they hold critical entities
self.candidateStations.sort(key=lambda x: x.critical, reverse=False)
# # TODO: have to consider what happens in case of a critical order # # TODO: have to consider what happens in case of a critical order
# #if we have sorting according to multiple criteria we have to call the sorter many times # #if we have sorting according to multiple criteria we have to call the sorter many times
# if self.schedulingRule=="MC": # if self.schedulingRule=="MC":
......
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