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

first working version of routing Jobs. From the trace it seems to work ok....

first working version of routing Jobs. From the trace it seems to work ok. Cleanup to be done. Also there are ways to make this more generic
parent e9ef6832
......@@ -25,7 +25,7 @@ Created on 12 Jul 2012
Class that acts as an abstract. It should have no instances. All the core-objects should inherit from it
'''
from SimPy.Simulation import Process, Resource
from SimPy.Simulation import Process, Resource, now
#the core object
class CoreObject(Process):
......@@ -76,7 +76,7 @@ class CoreObject(Process):
#gets an entity from the predecessor that the predecessor index points to
def getEntity(self):
self.Res.activeQ=[self.previous[self.predecessorIndex].Res.activeQ[0]]+self.Res.activeQ #get the entity from the previous object
self.Res.activeQ.append(self.previous[self.predecessorIndex].Res.activeQ[0]) #get the entity from the previous object
#and put it in front of the activeQ
self.previous[self.predecessorIndex].removeEntity() #remove the entity from the previous object
......
......@@ -2,18 +2,18 @@
"_class": "Dream.Simulation",
"edges": {
"0": [
"M1",
"Q1",
"M1",
{}
],
"1": [
"M2",
"Q2",
"M2",
{}
],
"2": [
"M3",
"Q3",
"M3",
{}
]
},
......@@ -26,7 +26,7 @@
},
"nodes": {
"M1": {
"_class": "Dream.Machine",
"_class": "Dream.MachineJobShop",
"name": "Machine1",
"processingTime": {
"distributionType": "Fixed",
......@@ -39,7 +39,7 @@
}
},
"M2": {
"_class": "Dream.Machine",
"_class": "Dream.MachineJobShop",
"name": "Machine2",
"processingTime": {
"distributionType": "Fixed",
......@@ -52,7 +52,7 @@
}
},
"M3": {
"_class": "Dream.Machine",
"_class": "Dream.MachineJobShop",
"name": "Machine3",
"processingTime": {
"distributionType": "Fixed",
......@@ -65,20 +65,20 @@
}
},
"Q1": {
"_class": "Dream.Queue",
"_class": "Dream.QueueJobShop",
"name": "Queue1",
"isDummy": "0",
"capacity": "1000"
},
"Q2": {
"_class": "Dream.Queue",
"_class": "Dream.QueueJobShop",
"id": "Q2",
"name": "Queue2",
"isDummy": "0",
"capacity": "1000"
},
"Q3": {
"_class": "Dream.Queue",
"_class": "Dream.QueueJobShop",
"name": "Queue3",
"isDummy": "0",
"capacity": "1000"
......
{
"_class": "Dream.Simulation",
"edges": {
"0": [
"Q1",
"M1",
{}
],
"1": [
"Q2",
"M2",
{}
],
"2": [
"Q3",
"M3",
{}
]
},
"general": {
"_class": "Dream.Configuration",
"numberOfReplications": "1",
"maxSimTime": "1000",
"trace": "Yes",
"confidenceLevel": "0.95"
},
"nodes": {
"M1": {
"_class": "Dream.MachineJobShop",
"name": "Machine1",
"processingTime": {
"distributionType": "Fixed",
"mean": "0.25"
},
"failures": {
"failureDistribution": "No",
"MTTF": "60",
"MTTR": "5"
}
},
"M2": {
"_class": "Dream.MachineJobShop",
"name": "Machine2",
"processingTime": {
"distributionType": "Fixed",
"mean": "1.5"
},
"failures": {
"failureDistribution": "No",
"MTTF": "40",
"MTTR": "10"
}
},
"M3": {
"_class": "Dream.MachineJobShop",
"name": "Machine3",
"processingTime": {
"distributionType": "Fixed",
"mean": "1.5"
},
"failures": {
"failureDistribution": "No",
"MTTF": "40",
"MTTR": "10"
}
},
"Q1": {
"_class": "Dream.QueueJobShop",
"name": "Queue1",
"isDummy": "0",
"capacity": "1000"
},
"Q2": {
"_class": "Dream.QueueJobShop",
"id": "Q2",
"name": "Queue2",
"isDummy": "0",
"capacity": "1000"
},
"Q3": {
"_class": "Dream.QueueJobShop",
"name": "Queue3",
"isDummy": "0",
"capacity": "1000"
},
"E1": {
"_class": "Dream.Exit",
"name": "Exit"
},
"J1": {
"_class": "Dream.Job",
"name": "Job1",
"route": [
{
"stationId": "Q1",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
}
},
{
"stationId": "Q3",
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
}
},
{
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
}
},
{
"stationId": "E1",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
}
]
},
"J2": {
"_class": "Dream.Job",
"name": "Job2",
"route": [
{
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
}
},
{
"stationId": "Q3",
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
}
},
{
"stationId": "Q2",
"processingTime": {
"distributionType": "Fixed",
"mean": "7"
}
},
{
"stationId": "E1",
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
}
]
}
}
}
\ No newline at end of file
......@@ -41,7 +41,7 @@
"_class": "Dream.Configuration",
"confidenceLevel": "0.95",
"maxSimTime": "1440",
"numberOfReplications": "1",
"numberOfReplications": "2",
"trace": "Yes"
},
"nodes": {
......
......@@ -64,8 +64,8 @@ from Assembly import Assembly
from Dismantle import Dismantle
from Conveyer import Conveyer
from Job import Job
#from MachineJobShop import MachineJobShop
#from QueueJobShop import QueueJobShop
from MachineJobShop import MachineJobShop
from QueueJobShop import QueueJobShop
#from ExitJobShop import ExitJobShop
import xlwt
import xlrd
......@@ -214,6 +214,16 @@ def createObjects():
G.QueueList.append(Q)
G.ObjList.append(Q)
elif objClass=='Dream.QueueJobShop':
id=element.get('id', 'not found')
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)
Q.nextIds=getSuccessorList(id)
G.QueueList.append(Q)
G.ObjList.append(Q)
elif objClass=='Dream.QueueLIFO':
id=element.get('id', 'not found')
name=element.get('name', 'not found')
......@@ -366,7 +376,7 @@ def setWIP():
#the main script that is ran
def main(argv=[], input_data=None):
argv = argv or sys.argv[1:]
#create an empty list to store all the objects in
G.ObjList=[]
......
......@@ -17,7 +17,7 @@
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 8 Nov 2012
Created on 1 oct 2012
@author: George
'''
......@@ -35,5 +35,35 @@ from RandomNumberGenerator import RandomNumberGenerator
#the MachineJobShop object
class MachineJobShop(Machine):
\ No newline at end of file
#gets an entity from the predecessor that the predecessor index points to
def getEntity(self):
Machine.getEntity(self) #run the default code
avtiveEntity=self.Res.activeQ[0]
self.procTime=avtiveEntity.remainingRoute[0][1]
self.nextStationId=avtiveEntity.remainingRoute[1][0]
avtiveEntity.remainingRoute.pop(0)
from Globals import G
for obj in G.ObjList:
if obj.id==self.nextStationId:
self.nextStation=obj
#checks if the machine down or it can dispose the object
def ifCanDisposeOrHaveFailure(self):
return self.Up==False or self.nextStation.canAccept(self) or len(self.Res.activeQ)==0
#the last part is added so that it is not removed and stack
#gotta think of it again
#calculates the processing time
def calculateProcessingTime(self):
return self.procTime #this is the processing time for this unique entity
#checks if the Machine can dispose an entity. Returns True only to the potential receiver
def haveToDispose(self, callerObject=None):
if callerObject!=None:
if self.Res.activeQ[0].remainingRoute[0][0]==callerObject.id:
return len(self.Res.activeQ)>0 and self.waitToDispose and self.Up
return False
\ No newline at end of file
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 1 oct 2012
@author: George
'''
'''
extends the Queue object so that it can act as a jobshop station. Preceding station from the Entity
'''
from SimPy.Simulation import Process, Resource
from SimPy.Simulation import activate, passivate, waituntil, now, hold
from Queue import Queue
from RandomNumberGenerator import RandomNumberGenerator
#the MachineJobShop object
class QueueJobShop(Queue):
#checks if the Queue can accept an entity
#it checks also who called it and returns TRUE only to the object that will give the entity.
def canAccept(self, callerObject=None):
if callerObject!=None:
if len(callerObject.Res.activeQ)>0:
activeEntity=callerObject.Res.activeQ[0]
if activeEntity.remainingRoute[0][0]==self.id:
return len(self.Res.activeQ)<self.capacity
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):
from Globals import G
for obj in G.ObjList:
if len(obj.Res.activeQ)>0 and now()!=0:
activeEntity=obj.Res.activeQ[0]
if activeEntity.remainingRoute[0][0]==self.id:
self.previousStation=obj
return len(self.Res.activeQ)<self.capacity and self.previousStation.haveToDispose(self)
return False
#gets an entity from the predecessor that the predecessor index points to
def getEntity(self):
self.Res.activeQ.append(self.previousStation.Res.activeQ[0]) #get the entity from the previous object
#and put it in front of the activeQ
self.previousStation.removeEntity() #remove the entity from the previous object
self.Res.activeQ[0].remainingRoute[0][0]=""
\ 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