Commit 54b61177 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

priority implemented as first scheduling rule. priority is optional argument...

priority implemented as first scheduling rule. priority is optional argument for entities and schedulingRoute optional argument for Queue. sortEntities() method in Queue does the sorting and it is called every time a Queue receives an Entity
parent 8917c0af
...@@ -108,6 +108,9 @@ class CoreObject(Process): ...@@ -108,6 +108,9 @@ class CoreObject(Process):
def canAccept(self, callerObject=None): def canAccept(self, callerObject=None):
pass pass
#sorts the Entities in the activeQ of the objects
def sortEntities(self):
pass
#takes the array and checks if all its values are identical (returns false) or not (returns true) #takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash! #needed because if somebody runs multiple runs in deterministic case it would crash!
def checkIfArrayHasDifValues(self, array): def checkIfArrayHasDifValues(self, array):
......
...@@ -29,7 +29,7 @@ Class that acts as an abstract. It should have no instances. All the Entities sh ...@@ -29,7 +29,7 @@ Class that acts as an abstract. It should have no instances. All the Entities sh
class Entity(object): class Entity(object):
type="Entity" type="Entity"
def __init__(self, name): def __init__(self, name, priority=0):
self.name=name self.name=name
self.currentStop=None #contains the current object that the material is in self.currentStop=None #contains the current object that the material is in
self.creationTime=0 self.creationTime=0
...@@ -38,3 +38,4 @@ class Entity(object): ...@@ -38,3 +38,4 @@ class Entity(object):
self.width=1.0 self.width=1.0
self.height=1.0 self.height=1.0
self.length=1.0 self.length=1.0
self.priority=priority
\ No newline at end of file
...@@ -67,19 +67,21 @@ ...@@ -67,19 +67,21 @@
"Q1": { "Q1": {
"_class": "Dream.QueueJobShop", "_class": "Dream.QueueJobShop",
"name": "Queue1", "name": "Queue1",
"schedulingRule": "FIFO",
"isDummy": "0", "isDummy": "0",
"capacity": "1000" "capacity": "1000"
}, },
"Q2": { "Q2": {
"_class": "Dream.QueueJobShop", "_class": "Dream.QueueJobShop",
"id": "Q2",
"name": "Queue2", "name": "Queue2",
"schedulingRule": "Priority",
"isDummy": "0", "isDummy": "0",
"capacity": "1000" "capacity": "1000"
}, },
"Q3": { "Q3": {
"_class": "Dream.QueueJobShop", "_class": "Dream.QueueJobShop",
"name": "Queue3", "name": "Queue3",
"schedulingRule": "FIFO",
"isDummy": "0", "isDummy": "0",
"capacity": "1000" "capacity": "1000"
}, },
...@@ -90,6 +92,7 @@ ...@@ -90,6 +92,7 @@
"J1": { "J1": {
"_class": "Dream.Job", "_class": "Dream.Job",
"name": "Job1", "name": "Job1",
"priority": "1",
"route": [ "route": [
{ {
"stepNumber": "0", "stepNumber": "0",
...@@ -128,6 +131,7 @@ ...@@ -128,6 +131,7 @@
"J2": { "J2": {
"_class": "Dream.Job", "_class": "Dream.Job",
"name": "Job2", "name": "Job2",
"priority": "7",
"route": [ "route": [
{ {
"stepNumber": "0", "stepNumber": "0",
...@@ -166,6 +170,7 @@ ...@@ -166,6 +170,7 @@
"J3": { "J3": {
"_class": "Dream.Job", "_class": "Dream.Job",
"name": "Job3", "name": "Job3",
"priority": "3",
"route": [ "route": [
{ {
"stepNumber": "0", "stepNumber": "0",
...@@ -196,6 +201,7 @@ ...@@ -196,6 +201,7 @@
"J4": { "J4": {
"_class": "Dream.Job", "_class": "Dream.Job",
"name": "Job4", "name": "Job4",
"priority": "1",
"route": [ "route": [
{ {
"stepNumber": "0", "stepNumber": "0",
......
...@@ -33,8 +33,8 @@ from Entity import Entity ...@@ -33,8 +33,8 @@ from Entity import Entity
class Job(Entity): class Job(Entity):
type="Job" type="Job"
def __init__(self, id, name, route): def __init__(self, id, name, route, priority=0):
Entity.__init__(self, name) Entity.__init__(self, name, priority)
self.id=id self.id=id
self.fullRoute=route #the route that the job follows, also contains the processing times in each station self.fullRoute=route #the route that the job follows, also contains the processing times in each station
self.remainingRoute=route #the remaining route. in the beginning this should be the same as the full route self.remainingRoute=route #the remaining route. in the beginning this should be the same as the full route
...@@ -45,5 +45,3 @@ class Job(Entity): ...@@ -45,5 +45,3 @@ class Job(Entity):
\ No newline at end of file
\ No newline at end of file
...@@ -218,7 +218,8 @@ def createObjects(): ...@@ -218,7 +218,8 @@ def createObjects():
name=element.get('name', 'not found') name=element.get('name', 'not found')
capacity=int(element.get('capacity', '1')) capacity=int(element.get('capacity', '1'))
isDummy=bool(int(element.get('isDummy', '0'))) isDummy=bool(int(element.get('isDummy', '0')))
Q=Queue(id, name, capacity, isDummy) schedulingRule=element.get('schedulingRule', 'FIFO')
Q=Queue(id, name, capacity, isDummy, schedulingRule=schedulingRule)
Q.nextIds=getSuccessorList(id) Q.nextIds=getSuccessorList(id)
G.QueueList.append(Q) G.QueueList.append(Q)
G.ObjList.append(Q) G.ObjList.append(Q)
...@@ -228,7 +229,8 @@ def createObjects(): ...@@ -228,7 +229,8 @@ def createObjects():
name=element.get('name', 'not found') name=element.get('name', 'not found')
capacity=int(element.get('capacity', '1')) capacity=int(element.get('capacity', '1'))
isDummy=bool(int(element.get('isDummy', '0'))) isDummy=bool(int(element.get('isDummy', '0')))
Q=QueueJobShop(id, name, capacity, isDummy) schedulingRule=element.get('schedulingRule', 'FIFO')
Q=QueueJobShop(id, name, capacity, isDummy, schedulingRule=schedulingRule)
Q.nextIds=getSuccessorList(id) Q.nextIds=getSuccessorList(id)
G.QueueJobShopList.append(Q) G.QueueJobShopList.append(Q)
G.ObjList.append(Q) G.ObjList.append(Q)
...@@ -253,11 +255,7 @@ def createObjects(): ...@@ -253,11 +255,7 @@ def createObjects():
stdev=float(processingTime.get('stdev', '0')) stdev=float(processingTime.get('stdev', '0'))
min=float(processingTime.get('min', '0')) min=float(processingTime.get('min', '0'))
max=float(processingTime.get('max', '0')) max=float(processingTime.get('max', '0'))
#predecessorPartList=element.get('predecessorPartList', 'not found')
#predecessorFrameList=element.get('predecessorFrameList', 'not found')
A=Assembly(id, name, distributionType, [mean,stdev,min,max]) A=Assembly(id, name, distributionType, [mean,stdev,min,max])
#A.previousPartIds=predecessorPartList
#A.previousFrameIds=predecessorFrameList
A.nextIds=getSuccessorList(id) A.nextIds=getSuccessorList(id)
G.AssemblyList.append(A) G.AssemblyList.append(A)
G.ObjList.append(A) G.ObjList.append(A)
...@@ -291,6 +289,7 @@ def createObjects(): ...@@ -291,6 +289,7 @@ def createObjects():
elif objClass=='Dream.Job': elif objClass=='Dream.Job':
id=element.get('id', 'not found') id=element.get('id', 'not found')
name=element.get('name', 'not found') name=element.get('name', 'not found')
priority=int(element.get('priority', '0'))
JSONRoute=element.get('route', []) JSONRoute=element.get('route', [])
route=[] route=[]
for i in range(len(JSONRoute)): for i in range(len(JSONRoute)):
...@@ -302,7 +301,7 @@ def createObjects(): ...@@ -302,7 +301,7 @@ def createObjects():
distributionType=processingTime.get('distributionType', 'not found') distributionType=processingTime.get('distributionType', 'not found')
mean=int(processingTime.get('mean', 'not found')) mean=int(processingTime.get('mean', 'not found'))
route[stepNumber]=[nextId, mean] route[stepNumber]=[nextId, mean]
J=Job(id, name, route) J=Job(id, name, route, priority=priority)
G.JobList.append(J) G.JobList.append(J)
G.WipList.append(J) G.WipList.append(J)
G.EntityList.append(J) G.EntityList.append(J)
...@@ -377,6 +376,7 @@ def activateObjects(): ...@@ -377,6 +376,7 @@ def activateObjects():
#sets the WIP in the corresponding stations #sets the WIP in the corresponding stations
def setWIP(): def setWIP():
#read the start station of the Entities and assign them to it
for entity in G.WipList: for entity in G.WipList:
objectId=entity.currentStop objectId=entity.currentStop
object=None object=None
...@@ -385,6 +385,9 @@ def setWIP(): ...@@ -385,6 +385,9 @@ 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):
......
...@@ -176,9 +176,11 @@ class Queue(CoreObject): ...@@ -176,9 +176,11 @@ class Queue(CoreObject):
#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):
activeObjectQ=self.Res.activeQ
if self.schedulingRule=="FIFO": if self.schedulingRule=="FIFO":
pass pass
elif self.schedulingRule=="Priority":
activeObjectQ.sort(key=lambda x: x.priority, 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):
......
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