sortEntities of operator corrected; further refinment needed. Seed def should...

sortEntities of operator corrected; further refinment needed. Seed def should be updated in other examples of JobShop
parent 9dd6535c
...@@ -51,10 +51,10 @@ ...@@ -51,10 +51,10 @@
"type": "number" "type": "number"
}, },
"seed": { "seed": {
"default": "", "default": 10,
"description": "When using the same seed, the random number generator produce the same sequence of numbers", "description": "When using the same seed, the random number generator produce the same sequence of numbers",
"title": "Seed for random number generator", "title": "Seed for random number generator",
"type": "string" "type": "number"
}, },
"timeUnit": { "timeUnit": {
"default": "hour", "default": "hour",
...@@ -1045,7 +1045,7 @@ ...@@ -1045,7 +1045,7 @@
"numberOfReplications": "1", "numberOfReplications": "1",
"numberOfSolutions": "2", "numberOfSolutions": "2",
"processTimeout": 10, "processTimeout": 10,
"seed": "", "seed": 10,
"timeUnit": "hour", "timeUnit": "hour",
"trace": "Yes" "trace": "Yes"
}, },
......
...@@ -204,16 +204,15 @@ class Operator(ObjectResource): ...@@ -204,16 +204,15 @@ class Operator(ObjectResource):
for entity in activeObjectQ: for entity in activeObjectQ:
RPT=0 RPT=0
for step in entity.remainingRoute: for step in entity.remainingRoute:
processingTime=step.get('processingTime',None) processingTime=step.get('processingTime',{})
if processingTime: if processingTime:
RPT+=float(processingTime.get('Fixed',{}).get('mean',0)) RPT+=float(processingTime.get('Fixed',{}).get('mean',0))
entity.remainingProcessingTime=RPT entity.remainingProcessingTime=RPT
activeObjectQ.sort(key=lambda x: x.remainingProcessingTime, reverse=True) activeObjectQ.sort(key=lambda x: x.remainingProcessingTime, reverse=True)
#if the schedulingRule is to sort Entities according to longest processing time first in the next station #if the schedulingRule is to sort Entities according to longest processing time first in the next station
elif criterion=="LPT": elif criterion=="LPT":
for entity in activeObjectQ: for entity in activeObjectQ:
processingTime = entity.remainingRoute[0].get('processingTime',None) processingTime = entity.remainingRoute[0].get('processingTime',{})
entity.processingTimeInNextStation=float(processingTime.get('Fixed',{}).get('mean',0)) entity.processingTimeInNextStation=float(processingTime.get('Fixed',{}).get('mean',0))
if processingTime: if processingTime:
entity.processingTimeInNextStation=float(processingTime.get('Fixed',{}).get('mean',0)) entity.processingTimeInNextStation=float(processingTime.get('Fixed',{}).get('mean',0))
...@@ -224,7 +223,7 @@ class Operator(ObjectResource): ...@@ -224,7 +223,7 @@ class Operator(ObjectResource):
elif criterion=="SPT": elif criterion=="SPT":
for entity in activeObjectQ: for entity in activeObjectQ:
processingTime = entity.remainingRoute[0].get('processingTime',None) processingTime = entity.remainingRoute[0].get('processingTime',{})
if processingTime: if processingTime:
entity.processingTimeInNextStation=float(processingTime.get('Fixed',{}).get('mean',0)) entity.processingTimeInNextStation=float(processingTime.get('Fixed',{}).get('mean',0))
else: else:
...@@ -236,21 +235,23 @@ class Operator(ObjectResource): ...@@ -236,21 +235,23 @@ class Operator(ObjectResource):
for entity in activeObjectQ: for entity in activeObjectQ:
RPT=0 RPT=0
for step in entity.remainingRoute: for step in entity.remainingRoute:
processingTime=step.get('processingTime',None) processingTime=step.get('processingTime',{})
if processingTime: if processingTime:
RPT+=float(processingTime.get('Fixed',{}).get('mean',0)) RPT+=float(processingTime.get('Fixed',{}).get('mean',0))
entity.remainingProcessingTime=RPT entity.remainingProcessingTime=RPT
activeObjectQ.sort(key=lambda x: (x.dueDate-x.remainingProcessingTime)) activeObjectQ.sort(key=lambda x: (x.dueDate-x.remainingProcessingTime))
#if the schedulingRule is to sort Entities based on the length of the following Queue #if the schedulingRule is to sort Entities based on the length of the following Queue
elif criterion=="WINQ": elif criterion=="WINQ":
from Globals import G from Globals import G
for entity in activeObjectQ: for entity in activeObjectQ:
nextObjIds=entity.remainingRoute[1].get('stationIdsList',[]) if len(entity.remainingRoute)>1:
for obj in G.ObjList: nextObjIds=entity.remainingRoute[1].get('stationIdsList',[])
if obj.id in nextObjIds: for obj in G.ObjList:
nextObject=obj if obj.id in nextObjIds:
entity.nextQueueLength=len(nextObject.getActiveObjectQueue()) nextObject=obj
entity.nextQueueLength=len(nextObject.getActiveObjectQueue())
else:
entity.nextQueueLength = 0
activeObjectQ.sort(key=lambda x: x.nextQueueLength) activeObjectQ.sort(key=lambda x: x.nextQueueLength)
else: else:
assert False, "Unknown scheduling criterion %r" % (criterion, ) assert False, "Unknown scheduling criterion %r" % (criterion, )
...@@ -360,4 +361,4 @@ class Operator(ObjectResource): ...@@ -360,4 +361,4 @@ class Operator(ObjectResource):
G.cells_to_write.append({'row':step+1, G.cells_to_write.append({'row':step+1,
'col':col_to_write, 'col':col_to_write,
'worker':self.alias}) 'worker':self.alias})
G.routeTraceSheet.write(step+1, col_to_write, self.alias) G.routeTraceSheet.write(step+1, col_to_write, self.alias)
\ No newline at end of file
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