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):
def canAccept(self, callerObject=None):
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)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def checkIfArrayHasDifValues(self, array):
......
......@@ -29,7 +29,7 @@ Class that acts as an abstract. It should have no instances. All the Entities sh
class Entity(object):
type="Entity"
def __init__(self, name):
def __init__(self, name, priority=0):
self.name=name
self.currentStop=None #contains the current object that the material is in
self.creationTime=0
......@@ -38,3 +38,4 @@ class Entity(object):
self.width=1.0
self.height=1.0
self.length=1.0
self.priority=priority
\ No newline at end of file
......@@ -67,19 +67,21 @@
"Q1": {
"_class": "Dream.QueueJobShop",
"name": "Queue1",
"schedulingRule": "FIFO",
"isDummy": "0",
"capacity": "1000"
},
"Q2": {
"_class": "Dream.QueueJobShop",
"id": "Q2",
"name": "Queue2",
"schedulingRule": "Priority",
"isDummy": "0",
"capacity": "1000"
},
"Q3": {
"_class": "Dream.QueueJobShop",
"name": "Queue3",
"schedulingRule": "FIFO",
"isDummy": "0",
"capacity": "1000"
},
......@@ -90,6 +92,7 @@
"J1": {
"_class": "Dream.Job",
"name": "Job1",
"priority": "1",
"route": [
{
"stepNumber": "0",
......@@ -128,6 +131,7 @@
"J2": {
"_class": "Dream.Job",
"name": "Job2",
"priority": "7",
"route": [
{
"stepNumber": "0",
......@@ -166,6 +170,7 @@
"J3": {
"_class": "Dream.Job",
"name": "Job3",
"priority": "3",
"route": [
{
"stepNumber": "0",
......@@ -196,6 +201,7 @@
"J4": {
"_class": "Dream.Job",
"name": "Job4",
"priority": "1",
"route": [
{
"stepNumber": "0",
......
......@@ -33,8 +33,8 @@ from Entity import Entity
class Job(Entity):
type="Job"
def __init__(self, id, name, route):
Entity.__init__(self, name)
def __init__(self, id, name, route, priority=0):
Entity.__init__(self, name, priority)
self.id=id
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
......@@ -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():
name=element.get('name', 'not found')
capacity=int(element.get('capacity', '1'))
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)
G.QueueList.append(Q)
G.ObjList.append(Q)
......@@ -228,7 +229,8 @@ def createObjects():
name=element.get('name', 'not found')
capacity=int(element.get('capacity', '1'))
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)
G.QueueJobShopList.append(Q)
G.ObjList.append(Q)
......@@ -253,11 +255,7 @@ def createObjects():
stdev=float(processingTime.get('stdev', '0'))
min=float(processingTime.get('min', '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.previousPartIds=predecessorPartList
#A.previousFrameIds=predecessorFrameList
A.nextIds=getSuccessorList(id)
G.AssemblyList.append(A)
G.ObjList.append(A)
......@@ -291,6 +289,7 @@ def createObjects():
elif objClass=='Dream.Job':
id=element.get('id', 'not found')
name=element.get('name', 'not found')
priority=int(element.get('priority', '0'))
JSONRoute=element.get('route', [])
route=[]
for i in range(len(JSONRoute)):
......@@ -302,7 +301,7 @@ def createObjects():
distributionType=processingTime.get('distributionType', 'not found')
mean=int(processingTime.get('mean', 'not found'))
route[stepNumber]=[nextId, mean]
J=Job(id, name, route)
J=Job(id, name, route, priority=priority)
G.JobList.append(J)
G.WipList.append(J)
G.EntityList.append(J)
......@@ -377,6 +376,7 @@ def activateObjects():
#sets the WIP in the corresponding stations
def setWIP():
#read the start station of the Entities and assign them to it
for entity in G.WipList:
objectId=entity.currentStop
object=None
......@@ -385,6 +385,9 @@ def setWIP():
object=obj
object.Res.activeQ.append(entity)
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
def main(argv=[], input_data=None):
......
......@@ -176,9 +176,11 @@ class Queue(CoreObject):
#sorts the Entities of the Queue according to the scheduling rule
def sortEntities(self):
activeObjectQ=self.Res.activeQ
if self.schedulingRule=="FIFO":
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)
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