sortEntities criteria of operator corrected

parent d2250e3b
......@@ -68,66 +68,82 @@ class Operator(Repairman):
if criterion=="FIFO":
pass
#if the schedulingRule is based on a pre-defined priority
# TODO: entityToGet is not updated for all available Objects
elif criterion=="Priority":
activeObjectQ.sort(key=lambda x: x.entityToGet.priority)
#if the scheduling rule is time waiting (time waiting of machine
# TODO: consider that the timeLastEntityEnded is not a
# indicative identifier of how long the station was waiting
elif criterion=='WT':
activeObjectQ.sort(key=lambda x: x.timeLastEntityEnded)
#if the schedulingRule is earliest due date
elif criterion=="EDD":
activeObjectQ.sort(key=lambda x: x.dueDate)
activeObjectQ.sort(key=lambda x: x.entityToGet.dueDate)
#if the schedulingRule is earliest order date
elif criterion=="EOD":
activeObjectQ.sort(key=lambda x: x.orderDate)
activeObjectQ.sort(key=lambda x: x.entityToGet.orderDate)
#if the schedulingRule is to sort Entities according to the stations they have to visit
elif criterion=="NumStages":
activeObjectQ.sort(key=lambda x: len(x.remainingRoute), reverse=True)
activeObjectQ.sort(key=lambda x: len(x.entityToGet.remainingRoute), reverse=True)
#if the schedulingRule is to sort Entities according to the their remaining processing time in the system
# TODO: have to compare the entitiesToGet
elif criterion=="RPC":
for entity in activeObjectQ:
for object in activeObjectQ:
entity=object.entityToGet
RPT=0
for step in entity.remainingRoute:
processingTime=step.get('processingTime',None)
if processingTime:
RPT+=float(processingTime.get('mean',0))
RPT+=float(processingTime.get('mean',0))
entity.remainingProcessingTime=RPT
activeObjectQ.sort(key=lambda x: x.remainingProcessingTime, reverse=True)
activeObjectQ.sort(key=lambda x: x.entityToGet.remainingProcessingTime, reverse=True)
#if the schedulingRule is to sort Entities according to longest processing time first in the next station
# TODO: have to compare the entitiesToGet
elif criterion=="LPT":
for entity in activeObjectQ:
for object in activeObjectQ:
entity=object.entityToGet
processingTime = entity.remainingRoute[0].get('processingTime',None)
entity.processingTimeInNextStation=float(processingTime.get('mean',0))
if processingTime:
entity.processingTimeInNextStation=float(processingTime.get('mean',0))
else:
entity.processingTimeInNextStation=0
activeObjectQ.sort(key=lambda x: x.processingTimeInNextStation, reverse=True)
activeObjectQ.sort(key=lambda x: x.entityToGet.processingTimeInNextStation, reverse=True)
#if the schedulingRule is to sort Entities according to shortest processing time first in the next station
# TODO: have to compare the entitiesToGet
elif criterion=="SPT":
for entity in activeObjectQ:
for object in activeObjectQ:
entity=object.entityToGet
processingTime = entity.remainingRoute[0].get('processingTime',None)
if processingTime:
entity.processingTimeInNextStation=float(processingTime.get('mean',0))
else:
entity.processingTimeInNextStation=0
activeObjectQ.sort(key=lambda x: x.processingTimeInNextStation)
activeObjectQ.sort(key=lambda x: x.entityToGet.processingTimeInNextStation)
#if the schedulingRule is to sort Entities based on the minimum slackness
# TODO: have to compare the entitiesToGet
elif criterion=="MS":
for entity in activeObjectQ:
for object in activeObjectQ:
object.entityToGet
RPT=0
for step in entity.remainingRoute:
processingTime=step.get('processingTime',None)
if processingTime:
RPT+=float(processingTime.get('mean',0))
entity.remainingProcessingTime=RPT
activeObjectQ.sort(key=lambda x: (x.dueDate-x.remainingProcessingTime))
activeObjectQ.sort(key=lambda x: (x.entityToGet.dueDate-x.entityToGet.remainingProcessingTime))
#if the schedulingRule is to sort Entities based on the length of the following Queue
# TODO: have to compare the entitiesToGet
elif criterion=="WINQ":
from Globals import G
for entity in activeObjectQ:
for object in activeObjectQ:
entity=object.entityToGet
nextObjIds=entity.remainingRoute[1].get('stationIdsList',[])
for obj in G.ObjList:
if obj.id in nextObjIds:
nextObject=obj
entity.nextQueueLength=len(nextObject.getActiveObjectQueue())
activeObjectQ.sort(key=lambda x: x.nextQueueLength)
activeObjectQ.sort(key=lambda x: x.entityToGet.nextQueueLength)
else:
assert False, "Unknown scheduling criterion %r" % (criterion, )
......
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