Commit ab327e5a authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

MachineJobShop and QueueJobShop updated so that they can act as jobshop...

MachineJobShop and QueueJobShop updated so that they can act as jobshop objects both in input and output. topologies 18 to 20 updated in the new notation
parent a5868f3a
{
"_class": "Dream.Simulation",
"edges": {
"0": [
"Q1",
"M1",
{}
],
"1": [
"Q2",
"M2",
{}
],
"2": [
"Q3",
"M3",
{}
]
},
"edges": {},
"general": {
"_class": "Dream.Configuration",
"numberOfReplications": "1",
......@@ -80,27 +64,51 @@
"stationId": "Q1",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
"mean": "0"
}
},
{
"stepNumber": "1",
"stationId": "M1",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
}
},
{
"stepNumber": "2",
"stationId": "Q3",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "3",
"stationId": "M3",
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
}
},
{
"stepNumber": "2",
"stepNumber": "4",
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "5",
"stationId": "M2",
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
}
},
{
"stepNumber": "3",
"stepNumber": "6",
"stationId": "E1",
"processingTime": {
"distributionType": "Fixed",
......
{
"_class": "Dream.Simulation",
"edges": {
"0": [
"Q1",
"M1",
{}
],
"1": [
"Q2",
"M2",
{}
],
"2": [
"Q3",
"M3",
{}
]
},
"edges": {},
"general": {
"_class": "Dream.Configuration",
"numberOfReplications": "1",
......@@ -80,27 +64,51 @@
"stationId": "Q1",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
"mean": "0"
}
},
{
"stepNumber": "1",
"stationId": "M1",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
}
},
{
"stepNumber": "2",
"stationId": "Q3",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "3",
"stationId": "M3",
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
}
},
{
"stepNumber": "2",
"stepNumber": "4",
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "5",
"stationId": "M2",
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
}
},
{
"stepNumber": "3",
"stepNumber": "6",
"stationId": "E1",
"processingTime": {
"distributionType": "Fixed",
......@@ -128,27 +136,51 @@
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
"mean": "0"
}
},
{
"stepNumber": "1",
"stationId": "M2",
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
}
},
{
"stepNumber": "2",
"stationId": "Q3",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "3",
"stationId": "M3",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
}
},
{
"stepNumber": "2",
"stepNumber": "4",
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "5",
"stationId": "M2",
"processingTime": {
"distributionType": "Fixed",
"mean": "7"
}
},
{
"stepNumber": "3",
"stepNumber": "6",
"stationId": "E1",
"processingTime": {
"distributionType": "Fixed",
......
{
"_class": "Dream.Simulation",
"edges": {
"0": [
"Q1",
"M1",
{}
],
"1": [
"Q2",
"M2",
{}
],
"2": [
"Q3",
"M3",
{}
]
},
"edges": {},
"general": {
"_class": "Dream.Configuration",
"numberOfReplications": "1",
......@@ -84,27 +68,51 @@
"stationId": "Q1",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
"mean": "0"
}
},
{
"stepNumber": "1",
"stationId": "M1",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
}
},
{
"stepNumber": "2",
"stationId": "Q3",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "3",
"stationId": "M3",
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
}
},
{
"stepNumber": "2",
"stepNumber": "4",
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "5",
"stationId": "M2",
"processingTime": {
"distributionType": "Fixed",
"mean": "4"
}
},
{
"stepNumber": "3",
"stepNumber": "6",
"stationId": "E1",
"processingTime": {
"distributionType": "Fixed",
......@@ -135,19 +143,35 @@
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
"mean": "0"
}
},
{
"stepNumber": "1",
"stationId": "M2",
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
}
},
{
"stepNumber": "2",
"stationId": "Q3",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "3",
"stationId": "M3",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
}
},
{
"stepNumber": "2",
"stepNumber": "4",
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
......@@ -155,7 +179,15 @@
}
},
{
"stepNumber": "3",
"stepNumber": "5",
"stationId": "M2",
"processingTime": {
"distributionType": "Fixed",
"mean": "7"
}
},
{
"stepNumber": "6",
"stationId": "E1",
"processingTime": {
"distributionType": "Fixed",
......@@ -177,19 +209,35 @@
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
"mean": "0"
}
},
{
"stepNumber": "1",
"stationId": "M2",
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
}
},
{
"stepNumber": "2",
"stationId": "Q3",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
{
"stepNumber": "3",
"stationId": "M3",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
}
},
{
"stepNumber": "2",
"stepNumber": "4",
"stationId": "E1",
"processingTime": {
"distributionType": "Fixed",
......@@ -211,11 +259,19 @@
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "7"
"mean": "0"
}
},
{
"stepNumber": "1",
"stationId": "M2",
"processingTime": {
"distributionType": "Fixed",
"mean": "7"
}
},
{
"stepNumber": "2",
"stationId": "E1",
"processingTime": {
"distributionType": "Fixed",
......
......@@ -536,7 +536,25 @@ def createWIP():
# get the 'mean'
mean=float(processingTime.get('mean', 'not found'))
route[stepNumber]=[nextId, mean] # finally add the 'nextId' and 'mean'
# to the job route
# to the job route
#Below it is to assign an exit if it was not assigned in JSON
#have to talk about it with NEX
exitAssigned=False
for element in route:
elementId=element[0]
for obj in G.ObjList:
if obj.id==elementId and obj.type=='Exit':
exitAssigned=True
if not exitAssigned:
exitId=None
for obj in G.ObjList:
if obj.type=='Exit':
exitId=obj.id
break
if exitId:
route.append([exitId, 0])
# initiate the job
J=Job(id, name, route, priority=priority, dueDate=dueDate, orderDate=orderDate)
G.JobList.append(J)
......@@ -557,7 +575,7 @@ def setWIP():
if obj.id==objectId:
object=obj # find the object in the 'G.ObjList
object.getActiveObjectQueue().append(entity) # append the entity to its Queue
entity.remainingRoute[0][0]="" # remove data from the remaining route.
entity.remainingRoute.pop(0) # remove data from the remaining route.
entity.schedule.append([object,now()]) #append the time to schedule so that it can be read in the result
entity.currentStation=object # update the current station of the entity
......@@ -589,8 +607,7 @@ def main(argv=[], input_data=None):
readGeneralInput()
createObjects()
createWIP()
setTopology()
setTopology()
#run the experiment (replications)
for i in xrange(G.numberOfReplications):
......@@ -598,6 +615,7 @@ def main(argv=[], input_data=None):
G.seed+=1
G.Rnd=Random(G.seed)
initialize() #initialize the simulation
createWIP()
initializeObjects()
setWIP()
activateObjects()
......
......@@ -44,12 +44,31 @@ class MachineJobShop(Machine):
#calculates the processing time
def calculateProcessingTime(self):
return self.procTime #this is the processing time for this unique entity
#checks if the Queue can accept an entity
#it checks also the next station of the Entity and returns true only if the active object is the next station
def canAccept(self, callerObject=None):
if callerObject!=None:
#check it the caller object holds an Entity that requests for current object
if len(callerObject.getActiveObjectQueue())>0:
activeEntity=callerObject.getActiveObjectQueue()[0]
if activeEntity.remainingRoute[0][0]==self.id:
return len(self.getActiveObjectQueue())<self.capacity #return according to the state of the Queue
return False
#checks if the Queue can accept an entity and there is an entity in some predecessor waiting for it
#also updates the predecessorIndex to the one that is to be taken
def canAcceptAndIsRequested(self):
if self.getGiverObject():
return self.getGiverObject().haveToDispose(self) and len(self.getActiveObjectQueue())<self.capacity\
and self.Up
else:
return False
#checks if the Machine can dispose an entity. Returns True only to the potential receiver
def haveToDispose(self, callerObject=None):
if callerObject!=None:
#check it the object that called the method holds an Entity that requests for current object
#if self.getActiveObjectQueue()[0].remainingRoute[0][0]==callerObject.id:
if self.getReceiverObject()==callerObject:
return len(self.getActiveObjectQueue())>0 and self.waitToDispose and self.Up #return according to the state of the machine
return False
......@@ -57,6 +76,9 @@ class MachineJobShop(Machine):
#get the receiver object in a removeEntity transaction.
def getReceiverObject(self):
#if there are successors use default method
if len(self.next)>0:
return Machine.getReceiverObject(self)
if len(self.getActiveObjectQueue())>0:
from Globals import G
receiverObjectId=self.getActiveObjectQueue()[0].remainingRoute[0][0]
......@@ -66,4 +88,18 @@ class MachineJobShop(Machine):
return obj
else:
return None
#get the giver object in a getEntity transaction.
def getGiverObject(self):
#if there are predecessors use default method
if len(self.previous)>0:
return Machine.getGiverObject(self)
from Globals import G
#loop through the objects to see if there is one that holds an Entity requesting for current object
for obj in G.ObjList:
if len(obj.getActiveObjectQueue())>0 and (obj!=self):
activeEntity=obj.getActiveObjectQueue()[0]
if activeEntity.remainingRoute[0][0]==self.id:
return obj
return None
\ No newline at end of file
......@@ -53,16 +53,26 @@ class QueueJobShop(Queue):
else:
return False
#checks if the Machine can dispose an entity. Returns True only to the potential receiver
def haveToDispose(self, callerObject=None):
if callerObject!=None:
#check it the object that called the method holds an Entity that requests for current object
if self.getReceiverObject()==callerObject:
return len(self.getActiveObjectQueue())>0 #return according to the state of the machine
return False
#gets an entity from the predecessor that the predecessor index points to
def getEntity(self):
activeEntity=Queue.getEntity(self)
activeEntity.remainingRoute[0][0]="" #remove data from the remaining route.
return activeEntity
self.nextStationId=activeEntity.remainingRoute[1][0] #read the next station id
activeEntity.remainingRoute.pop(0) #remove data from the remaining route of the entity
return activeEntity
#get the giver object in a getEntity transaction.
def getGiverObject(self):
#if there are predecessors use default method
if len(self.previous)>0:
return Queue.getGiverObject(self)
from Globals import G
#loop through the objects to see if there is one that holds an Entity requesting for current object
for obj in G.ObjList:
......@@ -71,5 +81,20 @@ class QueueJobShop(Queue):
if activeEntity.remainingRoute[0][0]==self.id:
return obj
return None
#get the receiver object in a removeEntity transaction.
def getReceiverObject(self):
#if there are successors use default method
if len(self.next)>0:
return Queue.getReceiverObject(self)
if len(self.getActiveObjectQueue())>0:
from Globals import G
receiverObjectId=self.getActiveObjectQueue()[0].remainingRoute[0][0]
#loop through the objects to to assign the next station to the one that has the id
for obj in G.ObjList:
if obj.id==receiverObjectId:
return obj
else:
return None
\ 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