Commit d92a00dd authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

all the scheduling rules implemented. More testing and cleanup needed

parent 87acf8a4
...@@ -76,9 +76,16 @@ class CoreObject(Process): ...@@ -76,9 +76,16 @@ class CoreObject(Process):
#gets an entity from the predecessor that the predecessor index points to #gets an entity from the predecessor that the predecessor index points to
def getEntity(self): def getEntity(self):
self.Res.activeQ.append(self.previous[self.predecessorIndex].Res.activeQ[0]) #get the entity from the previous object giverObject=self.getGiverObject()
giverObject.sortEntities() #sort the Entities of the giver according to the scheduling rule if applied
activeObject=self.getActiveObject()
giverObjectQueue=self.getGiverObjectQueue()
activeEntity=giverObjectQueue[0]
activeObjectQueue=self.getActiveObjectQueue()
activeObjectQueue.append(activeEntity) #get the entity from the previous object
#and put it in front of the activeQ #and put it in front of the activeQ
self.previous[self.predecessorIndex].removeEntity() #remove the entity from the previous object giverObject.removeEntity() #remove the entity from the previous object
#actions to be taken after the simulation ends #actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime): def postProcessing(self, MaxSimtime):
...@@ -118,4 +125,16 @@ class CoreObject(Process): ...@@ -118,4 +125,16 @@ class CoreObject(Process):
for i in range(1, len(array)): for i in range(1, len(array)):
if(array[i]!=array[1]): if(array[i]!=array[1]):
difValuesFlag=True difValuesFlag=True
return difValuesFlag return difValuesFlag
\ No newline at end of file
def getActiveObject(self):
return self
def getActiveObjectQueue(self):
return self.Res.activeQ
def getGiverObject(self):
return self.previous[self.predecessorIndex]
def getGiverObjectQueue(self):
return self.getGiverObject().Res.activeQ
\ No newline at end of file
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
"Q2": { "Q2": {
"_class": "Dream.QueueJobShop", "_class": "Dream.QueueJobShop",
"name": "Queue2", "name": "Queue2",
"schedulingRule": "NumStations", "schedulingRule": "MC-Priority-EDD",
"isDummy": "0", "isDummy": "0",
"capacity": "1000" "capacity": "1000"
}, },
...@@ -92,9 +92,9 @@ ...@@ -92,9 +92,9 @@
"J1": { "J1": {
"_class": "Dream.Job", "_class": "Dream.Job",
"name": "Job1", "name": "Job1",
"priority": "1", "priority": "-1",
"dueDate": "900", "dueDate": "900",
"orderDate": "5", "orderDate": "0",
"route": [ "route": [
{ {
"stepNumber": "0", "stepNumber": "0",
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
"stationId": "Q2", "stationId": "Q2",
"processingTime": { "processingTime": {
"distributionType": "Fixed", "distributionType": "Fixed",
"mean": "2" "mean": "4"
} }
}, },
{ {
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
"name": "Job2", "name": "Job2",
"priority": "7", "priority": "7",
"dueDate": "100", "dueDate": "100",
"orderDate": "3", "orderDate": "-1",
"route": [ "route": [
{ {
"stepNumber": "0", "stepNumber": "0",
...@@ -174,8 +174,8 @@ ...@@ -174,8 +174,8 @@
"J3": { "J3": {
"_class": "Dream.Job", "_class": "Dream.Job",
"name": "Job3", "name": "Job3",
"priority": "3", "priority": "12",
"dueDate": "200", "dueDate": "60",
"orderDate": "2", "orderDate": "2",
"route": [ "route": [
{ {
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
"J4": { "J4": {
"_class": "Dream.Job", "_class": "Dream.Job",
"name": "Job4", "name": "Job4",
"priority": "1", "priority": "0",
"dueDate": "99", "dueDate": "99",
"orderDate": "1.5", "orderDate": "1.5",
"route": [ "route": [
......
...@@ -387,9 +387,6 @@ def setWIP(): ...@@ -387,9 +387,6 @@ def setWIP():
object=obj object=obj
object.Res.activeQ.append(entity) object.Res.activeQ.append(entity)
entity.remainingRoute[0][0]="" #remove data from the remaining route. entity.remainingRoute[0][0]="" #remove data from the remaining route.
#sort the Entities in the WIP
for obj in G.QueueJobShopList:
obj.sortEntities()
#the main script that is ran #the main script that is ran
def main(argv=[], input_data=None): def main(argv=[], input_data=None):
......
...@@ -51,6 +51,11 @@ class Queue(CoreObject): ...@@ -51,6 +51,11 @@ class Queue(CoreObject):
self.type="Queue" #String that shows the type of object self.type="Queue" #String that shows the type of object
self.isDummy=dummy #Boolean that shows if it is the dummy first Queue self.isDummy=dummy #Boolean that shows if it is the dummy first Queue
self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows
self.multipleCriterionList=[]
if schedulingRule.startswith("MC"):
SRlist = schedulingRule.split("-")
self.schedulingRule=SRlist.pop(0)
self.multipleCriterionList=SRlist
def initialize(self): def initialize(self):
Process.__init__(self) Process.__init__(self)
...@@ -139,7 +144,8 @@ class Queue(CoreObject): ...@@ -139,7 +144,8 @@ class Queue(CoreObject):
return len(self.Res.activeQ)>0 and flag return len(self.Res.activeQ)>0 and flag
#removes an entity from the Object #removes an entity from the Object
def removeEntity(self): def removeEntity(self):
#self.sortEntities() #sort the Entities
self.outputTrace(self.Res.activeQ[0].name, "releases "+self.objName) self.outputTrace(self.Res.activeQ[0].name, "releases "+self.objName)
self.Res.activeQ.pop(0) self.Res.activeQ.pop(0)
...@@ -172,27 +178,64 @@ class Queue(CoreObject): ...@@ -172,27 +178,64 @@ class Queue(CoreObject):
def getEntity(self): def getEntity(self):
CoreObject.getEntity(self) #run the default behavior CoreObject.getEntity(self) #run the default behavior
self.outputTrace(self.Res.activeQ[-1].name, "got into "+self.objName) self.outputTrace(self.Res.activeQ[-1].name, "got into "+self.objName)
self.sortEntities() #sort the Entities
#sorts the Entities of the Queue according to the scheduling rule #sorts the Entities of the Queue according to the scheduling rule
def sortEntities(self): def sortEntities(self):
#if we have sorting according to multiple criteria we have to call the sorter many times
if self.schedulingRule=="MC":
for criterion in reversed(self.multipleCriterionList):
self.activeQSorter(criterion=criterion)
#else we just use the default scheduling rule
else:
self.activeQSorter()
#sorts the Entities of the Queue according to the scheduling rule
def activeQSorter(self, criterion=None):
activeObjectQ=self.Res.activeQ activeObjectQ=self.Res.activeQ
schedulingRule=self.schedulingRule if criterion==None:
criterion=self.schedulingRule
#if the schedulingRule is first in first out #if the schedulingRule is first in first out
if schedulingRule=="FIFO": if criterion=="FIFO":
pass pass
#if the schedulingRule is based on a pre-defined prioriy #if the schedulingRule is based on a pre-defined prioriy
elif schedulingRule=="Priority": elif criterion=="Priority":
activeObjectQ.sort(key=lambda x: x.priority, reverse=True) activeObjectQ.sort(key=lambda x: x.priority, reverse=True)
#if the schedulingRule is earliest due date #if the schedulingRule is earliest due date
elif schedulingRule=="EDD": elif criterion=="EDD":
activeObjectQ.sort(key=lambda x: x.dueDate) activeObjectQ.sort(key=lambda x: x.dueDate)
#if the schedulingRule is earliest order date #if the schedulingRule is earliest order date
elif schedulingRule=="EOD": elif criterion=="EOD":
activeObjectQ.sort(key=lambda x: x.orderDate) activeObjectQ.sort(key=lambda x: x.orderDate)
#if the schedulingRule is to short Entities according to the stations they have to visit #if the schedulingRule is to sort Entities according to the stations they have to visit
elif schedulingRule=="NumStations": elif criterion=="NumStages":
activeObjectQ.sort(key=lambda x: len(x.remainingRoute), reverse=True) activeObjectQ.sort(key=lambda x: len(x.remainingRoute), reverse=True)
#if the schedulingRule is to sort Entities according to the their remaining processing time in the system
elif criterion=="RPC":
for entity in activeObjectQ:
RPT=0
for step in entity.remainingRoute:
RPT+=step[1]
entity.remainingProcessingTime=RPT
activeObjectQ.sort(key=lambda x: x.remainingProcessingTime, reverse=True)
#if the schedulingRule is to sort Entities based on the minimum slackness
elif criterion=="MinSlack":
for entity in activeObjectQ:
RPT=0
for step in entity.remainingRoute:
RPT+=step[1]
entity.remainingProcessingTime=RPT
activeObjectQ.sort(key=lambda x: (x.dueDate-x.remainingProcessingTime))
#if the schedulingRule is to sort Entities based on the minimum slackness
elif criterion=="NextStage":
from Globals import G
for entity in activeObjectQ:
nextObjId=entity.remainingRoute[1][0]
for obj in G.ObjList:
if obj.id==nextObjId:
nextObject=obj
entity.nextQueueLength=len(nextObject.Res.activeQ)
activeObjectQ.sort(key=lambda x: x.nextQueueLength, reverse=True)
#outputs message to the trace.xls. Format is (Simulation Time | Entity Name | message) #outputs message to the trace.xls. Format is (Simulation Time | Entity Name | message)
def outputTrace(self, entityName, message): def outputTrace(self, entityName, message):
......
...@@ -63,10 +63,10 @@ class QueueJobShop(Queue): ...@@ -63,10 +63,10 @@ class QueueJobShop(Queue):
self.Res.activeQ.append(self.previousStation.Res.activeQ[0]) #get the entity from the previous object self.Res.activeQ.append(self.previousStation.Res.activeQ[0]) #get the entity from the previous object
#and put it in front of the activeQ #and put it in front of the activeQ
self.previousStation.removeEntity() #remove the entity from the previous object self.previousStation.removeEntity() #remove the entity from the previous object
self.Res.activeQ[-1].remainingRoute[0][0]="" #remove data from the remaining route. self.Res.activeQ[-1].remainingRoute[0][0]="" #remove data from the remaining route.
#This is needed so that the Queue will not request again for the Entity #This is needed so that the Queue will not request again for the Entity
self.outputTrace(self.Res.activeQ[-1].name, "got into "+self.objName) self.outputTrace(self.Res.activeQ[-1].name, "got into "+self.objName)
self.sortEntities() #sort the Entities 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