Commit 8e47f2ba authored by Jérome Perrin's avatar Jérome Perrin

Merge branch 'george3'

parents 1b6c0b9f fa2b8625
......@@ -21,8 +21,6 @@ Created on 18 Feb 2013
@author: George
'''
'''
Models an assembly object
it gathers frames and parts which are loaded to the frames
......@@ -32,9 +30,10 @@ from SimPy.Simulation import *
import xlwt
from RandomNumberGenerator import RandomNumberGenerator
import scipy.stats as stat
from CoreObject import CoreObject
#the Assembly object
class Assembly(Process):
class Assembly(CoreObject):
#initialize the object
def __init__(self, id, name, dist, time):
......@@ -181,18 +180,12 @@ class Assembly(Process):
#checks if the Assembly can dispose an entity to the following object
def haveToDispose(self):
return len(self.Res.activeQ)>0 and self.waitToDispose
#sets the routing in and out elements for the Assembly
def defineRouting(self, p, n):
self.next=n
self.previous=p
#removes an entity from the Assembly
def removeEntity(self):
self.outputTrace(self.Res.activeQ[0].name, "releases "+ self.objName)
self.Res.activeQ.pop(0)
self.waitToDispose=False
#gets an entity from the predecessor
#it may handle both Parts and Frames
......@@ -341,15 +334,5 @@ class Assembly(Process):
json['results']['waiting_ratio']['avg']=self.Waiting[0]
json['results']['waiting_ratio']['max']=self.Waiting[0]
G.outputJSON['coreObject'].append(json)
#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):
difValuesFlag=False
for i in range(1, len(array)):
if(array[i]!=array[1]):
difValuesFlag=True
return difValuesFlag
G.outputJSON['elementList'].append(json)
\ No newline at end of file
......@@ -29,9 +29,10 @@ it gathers entities and transfers them with a certain speed
from SimPy.Simulation import *
import xlwt
import scipy.stats as stat
from CoreObject import CoreObject
#The conveyer object
class Conveyer(Process):
class Conveyer(CoreObject):
def __init__(self, id, name,length,speed):
self.id=id
......@@ -223,11 +224,6 @@ class Conveyer(Process):
#only when an entity is at the end of it
else:
return False
#sets the routing in and out elements for the Conveyer
def defineRouting(self, p, n):
self.next=n
self.previous=p
#checks if the conveyer is full to count the blockage. for some reason Plant regards
#the conveyer full even when it has one place
......@@ -252,7 +248,6 @@ class Conveyer(Process):
return self.canAcceptAndIsRequested()
else:
return self.canAcceptAndIsRequested()
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime):
......@@ -382,16 +377,7 @@ class Conveyer(Process):
json['results']['waiting_ratio']['min']=self.Waiting[0]
json['results']['waiting_ratio']['avg']=self.Waiting[0]
json['results']['waiting_ratio']['max']=self.Waiting[0]
G.outputJSON['coreObject'].append(json)
#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):
difValuesFlag=False
for i in range(1, len(array)):
if(array[i]!=array[1]):
difValuesFlag=True
return difValuesFlag
G.outputJSON['elementList'].append(json)
#Process that handles the moves of the conveyer
class ConveyerMover(Process):
......
# ===========================================================================
# Copyright 2013 Georgios Dagkakis
#
# 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 12 Jul 2012
@author: George
'''
'''
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
#the core object
class CoreObject(Process):
def initilize(self):
Process.__init__(self)
self.predecessorIndex=0 #holds the index of the predecessor from which the Machine will take an entity next
self.successorIndex=0 #holds the index of the successor where the Machine will dispose an entity next
self.Up=True #Boolean that shows if the machine is in failure ("Down") or not ("up")
self.currentEntity=None
self.totalBlockageTime=0 #holds the total blockage time
self.totalFailureTime=0 #holds the total failure time
self.totalWaitingTime=0 #holds the total waiting time
self.totalWorkingTime=0 #holds the total working time
self.completedJobs=0 #holds the number of completed jobs
self.timeLastEntityEnded=0 #holds the last time that an entity ended processing in the object
self.nameLastEntityEnded="" #holds the name of the last entity that ended processing in the object
self.timeLastEntityEntered=0 #holds the last time that an entity entered in the object
self.nameLastEntityEntered="" #holds the name of the last entity that entered in the object
self.timeLastFailure=0 #holds the time that the last failure of the object started
self.timeLastFailureEnded=0 #holds the time that the last failure of the object Ended
self.downTimeProcessingCurrentEntity=0 #holds the time that the machine was down while processing the current entity
self.downTimeInTryingToReleaseCurrentEntity=0 #holds the time that the object was down while trying
#to release the current entity
self.downTimeInCurrentEntity=0 #holds the total time that the object was down while holding current entity
self.timeLastEntityLeft=0 #holds the last time that an entity left the object
self.processingTimeOfCurrentEntity=0 #holds the total processing time that the current entity required
self.waitToDispose=False #shows if the object waits to dispose an entity
#the main process of the core object
#this is dummy, every object must have its own implementation
def run(self):
raise NotImplementedError("Subclass must define 'run' method")
#sets the routing in and out elements for the Object
def defineRouting(self, p, n):
self.next=n
self.previous=p
#removes an entity from the Object
def removeEntity(self):
self.Res.activeQ.pop(0)
#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
#and put it in front of the activeQ
self.previous[self.predecessorIndex].removeEntity() #remove the entity from the previous object
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime):
pass
#outputs message to the trace.xls
def outputTrace(self, message):
pass
#outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime):
pass
#outputs results to JSON File
def outputResultsJSON(self):
pass
#checks if the Object can dispose an entity to the following object
def haveToDispose(self):
return len(self.Res.activeQ)>0
#checks if the Object can accept an entity and there is an entity in some predecessor waiting for it
def canAcceptAndIsRequested(self):
pass
#checks if the Object can accept an entity
def canAccept(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):
difValuesFlag=False
for i in range(1, len(array)):
if(array[i]!=array[1]):
difValuesFlag=True
return difValuesFlag
\ No newline at end of file
......@@ -30,9 +30,10 @@ from SimPy.Simulation import *
import xlwt
from RandomNumberGenerator import RandomNumberGenerator
import scipy.stats as stat
from CoreObject import CoreObject
#the Dismantle object
class Dismantle(Process):
class Dismantle(CoreObject):
#initialize the object
def __init__(self, id, name, dist, time):
......@@ -52,6 +53,7 @@ class Dismantle(Process):
self.nextIds=[] #list with the ids of the next objects in the flow
self.nextPartIds=[] #list with the ids of the next objects that receive parts
self.nextFrameIds=[] #list with the ids of the next objects that receive frames
self.next=[]
#lists to hold statistics of multiple runs
self.Waiting=[]
......@@ -131,9 +133,8 @@ class Dismantle(Process):
def canAccept(self):
return len(self.Res.activeQ)==0
#sets the routing in and out elements for the Dismantle
def defineRouting(self, p, np, nf):
self.previous=p
#defines where parts and frames go after they leave the object
def definePartFrameRouting(self, np, nf):
self.nextPart=np
self.nextFrame=nf
......@@ -339,7 +340,7 @@ class Dismantle(Process):
json['results']['waiting_ratio']['avg']=self.Waiting[0]
json['results']['waiting_ratio']['max']=self.Waiting[0]
G.outputJSON['coreObject'].append(json)
G.outputJSON['elementList'].append(json)
#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!
......
# ===========================================================================
# Copyright 2013 Georgios Dagkakis
#
# 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 18 Aug 2013
@author: George
'''
'''
Class that acts as an abstract. It should have no instances. All the Entities should inherit from it
'''
#The entity object
class Entity(object):
def __init__(self, name):
self.type="Entity"
self.name=name
self.currentStop=None #contains the current object that the material is in
self.creationTime=0
self.startTime=0 #holds the startTime for the lifespan
#dimension data
self.width=1.0
self.height=1.0
self.length=1.0
\ No newline at end of file
......@@ -28,9 +28,10 @@ models the exit of the model
from SimPy.Simulation import *
import xlwt
import scipy.stats as stat
from CoreObject import CoreObject
#The exit object
class Exit(Process):
class Exit(CoreObject):
def __init__(self, id, name):
Process.__init__(self)
......@@ -212,9 +213,10 @@ class Exit(Process):
json['_class'] = 'Dream.Exit';
json['id'] = str(self.id)
json['results'] = {}
json['results']['throughput']=self.numOfExits
json['results']['lifespan']=((self.totalLifespan)/self.numOfExits)/G.Base
json['results']['takt_time']=((self.totalTaktTime)/self.numOfExits)/G.Base
json['results']['throughput']=self.numOfExits
json['results']['lifespan']=self.Lifespan[0]
json['results']['takt_time']=self.TaktTime[0]
else: #if we had multiple replications we output confidence intervals to excel
#for some outputs the results may be the same for each run (eg model is stochastic but failures fixed
#so failurePortion will be exactly the same in each run). That will give 0 variability and errors.
......@@ -251,13 +253,5 @@ class Exit(Process):
json['results']['taktTime']['min']=self.TaktTime[0]
json['results']['taktTime']['avg']=self.TaktTime[0]
json['results']['taktTime']['max']=self.TaktTime[0]
G.outputJSON['coreObject'].append(json)
G.outputJSON['elementList'].append(json)
#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):
difValuesFlag=False
for i in range(1, len(array)):
if(array[i]!=array[1]):
difValuesFlag=True
return difValuesFlag
\ No newline at end of file
......@@ -26,12 +26,12 @@ Created on 9 Nov 2012
models the failures that servers can have
'''
from SimPy.Simulation import *
import math
from RandomNumberGenerator import RandomNumberGenerator
from ObjectInterruption import ObjectInterruption
class Failure(Process):
class Failure(ObjectInterruption):
def __init__(self, victim, dist, MTTF, MTTR, availability, index, repairman):
Process.__init__(self)
......@@ -122,6 +122,3 @@ class Failure(Process):
G.sheetIndex+=1
G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True)
#outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime):
pass
\ No newline at end of file
......@@ -28,13 +28,15 @@ models a frame entity. This can flow through the system and carry parts
from SimPy.Simulation import *
from Globals import G
from Entity import Entity
#The entity object
class Frame(object):
class Frame(Entity):
type="Frame"
numOfParts=4 #the number of parts that the frame can take
def __init__(self, name):
self.type="Frame"
self.name=name
self.currentStop=None #contains the current object that the material is in
self.creationTime=0
......
......@@ -6,14 +6,13 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
{"_class": "Dream.Repairman",
"elementList": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1"
}
],
"coreObject": [
"name": "W1",
"capacity": "1",
"successorList": ["M1", "M2"]
},
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material",
......@@ -35,8 +34,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "60",
"MTTR": "5",
"repairman": "W1"
"MTTR": "5"
},
"successorList": ["Q1"]
},
......@@ -50,8 +48,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "40",
"MTTR": "10",
"repairman": "W1"
"MTTR": "10"
},
"successorList": ["E1"]
},
......
......@@ -6,9 +6,7 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
],
"coreObject": [
"elementList": [
{"_class": "Dream.Source",
"id": "S1",
"name": "Parts",
......
......@@ -6,14 +6,13 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1"
}
],
"coreObject": [
"elementList": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1",
"successorList": ["M1", "M2"]
},
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material",
......@@ -35,8 +34,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "60",
"MTTR": "5",
"repairman": "W1"
"MTTR": "5"
},
"successorList": ["M2"]
},
......@@ -50,8 +48,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "40",
"MTTR": "10",
"repairman": "W1"
"MTTR": "10"
},
"successorList": ["E1"]
},
......
......@@ -6,14 +6,13 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
{"_class": "Dream.Repairman",
"elementList": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1"
}
],
"coreObject": [
"name": "W1",
"capacity": "1",
"successorList": ["M1", "M2"]
},
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material",
......@@ -35,8 +34,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "60",
"MTTR": "5",
"repairman": "W1"
"MTTR": "5"
},
"successorList": ["E1"]
},
......@@ -50,8 +48,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "40",
"MTTR": "10",
"repairman": "W1"
"MTTR": "10"
},
"successorList": ["Q1"]
},
......
......@@ -6,9 +6,7 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
],
"coreObject": [
"elementList": [
{"_class": "Dream.Source",
"id": "S1",
"name": "Parts",
......
......@@ -6,14 +6,13 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
{"_class": "Dream.Repairman",
"elementList": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1"
}
],
"coreObject": [
"name": "W1",
"capacity": "1",
"successorList": ["M1", "M2"]
},
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material",
......@@ -35,8 +34,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "60",
"MTTR": "5",
"repairman": "W1"
"MTTR": "5"
},
"successorList": ["Q1"]
},
......@@ -50,8 +48,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "40",
"MTTR": "10",
"repairman": "W1"
"MTTR": "10"
},
"successorList": ["M3"]
},
......
......@@ -6,9 +6,7 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
],
"coreObject": [
"elementList": [
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material 1",
......
......@@ -6,9 +6,7 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
],
"coreObject": [
"elementList": [
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material 1",
......
......@@ -6,9 +6,7 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
],
"coreObject": [
"elementList": [
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material",
......
......@@ -6,9 +6,7 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
],
"coreObject": [
"elementList": [
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material 1",
......
......@@ -7,15 +7,13 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
{
"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1"
}
],
"coreObject": [
"elementList": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1",
"successorList": ["M1", "M2"]
},
{
"_class": "Dream.Source",
"id": "S1",
......@@ -38,8 +36,7 @@
"failures": {
"failureDistribution": "No",
"MTTF": "60",
"MTTR": "5",
"repairman": "W1"
"MTTR": "5"
},
"successorList": ["M3"]
},
......@@ -54,8 +51,7 @@
"failures": {
"failureDistribution": "No",
"MTTF": "40",
"MTTR": "10",
"repairman": "W1"
"MTTR": "10"
},
"successorList": ["M3"]
},
......
......@@ -7,16 +7,14 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
{
"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1"
}
],
"coreObject": [
{
"elementList": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1",
"successorList": []
},
{
"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material",
......@@ -38,8 +36,7 @@
"failures": {
"failureDistribution": "No",
"MTTF": "60",
"MTTR": "5",
"repairman": "W1"
"MTTR": "5"
},
"successorList": ["M3","M4"]
},
......@@ -54,8 +51,7 @@
"failures": {
"failureDistribution": "No",
"MTTF": "40",
"MTTR": "10",
"repairman": "W1"
"MTTR": "10"
},
"successorList": ["M3","M4"]
},
......
......@@ -6,9 +6,7 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
],
"coreObject": [
"elementList": [
{"_class": "Dream.Source",
"id": "S1",
"name": "Parts",
......
......@@ -6,9 +6,7 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
],
"coreObject": [
"elementList": [
{"_class": "Dream.Source",
"id": "S1",
"name": "Parts",
......
......@@ -6,14 +6,13 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1"
}
],
"coreObject": [
"elementList": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1",
"successorList": ["M1", "M2"]
},
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material",
......@@ -35,8 +34,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "60",
"MTTR": "5",
"repairman": "W1"
"MTTR": "5"
},
"successorList": ["C1"]
},
......@@ -50,8 +48,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "40",
"MTTR": "10",
"repairman": "W1"
"MTTR": "10"
},
"successorList": ["E1"]
},
......
......@@ -6,14 +6,13 @@
"trace": "No",
"confidenceLevel": "0.95"
},
"modelResource": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1"
}
],
"coreObject": [
"elementList": [
{"_class": "Dream.Repairman",
"id": "W1",
"name": "W1",
"capacity": "1",
"successorList": ["M1", "M2"]
},
{"_class": "Dream.Source",
"id": "S1",
"name": "Raw Material",
......@@ -35,8 +34,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "60",
"MTTR": "5",
"repairman": "W1"
"MTTR": "5"
},
"successorList": ["C1"]
},
......@@ -50,8 +48,7 @@
"failures":{
"failureDistribution": "Fixed",
"MTTF": "40",
"MTTR": "10",
"repairman": "W1"
"MTTR": "10"
},
"successorList": ["M3"]
},
......@@ -77,10 +74,7 @@
"mean": "3"
},
"failures":{
"failureDistribution": "No",
"MTTF": "40",
"MTTR": "10",
"repairman": "W1"
"failureDistribution": "No"
},
"successorList": ["E1"]
},
......
This diff is collapsed.
......@@ -29,12 +29,14 @@ from SimPy.Simulation import Process, Resource
from SimPy.Simulation import activate, passivate, waituntil, now, hold
from Failure import Failure
from CoreObject import CoreObject
from RandomNumberGenerator import RandomNumberGenerator
import scipy.stats as stat
import sys
#the Machine object
class Machine(Process):
class Machine(CoreObject):
#initialize the id the capacity, of the resource and the distribution
def __init__(self, id, name, capacity, dist, time, fDist, MTTF, MTTR, availability, repairman):
......@@ -185,13 +187,7 @@ class Machine(Process):
blockageTime=totalTime-(tinMStart+failureTime)
self.totalBlockageTime+=totalTime-(tinMStart+failureTime) #the time of blockage is derived from
#the whole time in the machine
#minus the processing time and the failure time
#sets the routing in and out elements for the queue
def defineRouting(self, p, n):
self.next=n
self.previous=p
#minus the processing time and the failure time
#checks if the waitQ of the machine is empty
def checkIfWaitQEmpty(self):
return len(self.M.waitQ)==0
......@@ -259,6 +255,14 @@ class Machine(Process):
def ifCanDisposeOrHaveFailure(self):
return self.Up==False or self.next[0].canAccept() or len(self.Res.activeQ)==0 #the last part is added so that it is not removed and stack
#gotta think of it again
#removes an entity from the Machine
def removeEntity(self):
self.timeLastEntityLeft=now()
self.outputTrace("releases "+self.objName)
self.waitToDispose=False
self.Res.activeQ.pop(0)
self.downTimeInTryingToReleaseCurrentEntity=0
#checks if the Machine can dispose an entity to the following object
def haveToDispose(self):
......@@ -295,19 +299,6 @@ class Machine(Process):
flag=True
return len(self.Res.activeQ)>0 and self.waitToDispose and self.Up and flag
#removes an entity from the Machine
def removeEntity(self):
self.timeLastEntityLeft=now()
self.outputTrace("releases "+self.objName)
self.waitToDispose=False
self.Res.activeQ.pop(0)
self.downTimeInTryingToReleaseCurrentEntity=0
#gets an entity from the predecessor that the predecessor index points to
def getEntity(self):
self.Res.activeQ.append(self.previous[self.predecessorIndex].Res.activeQ[0]) #get the entity from the predecessor
self.previous[self.predecessorIndex].removeEntity()
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime):
......@@ -496,14 +487,5 @@ class Machine(Process):
json['results']['waiting_ratio']['avg']=self.Waiting[0]
json['results']['waiting_ratio']['max']=self.Waiting[0]
G.outputJSON['coreObject'].append(json)
#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):
difValuesFlag=False
for i in range(1, len(array)):
if(array[i]!=array[1]):
difValuesFlag=True
return difValuesFlag
\ No newline at end of file
G.outputJSON['elementList'].append(json)
\ No newline at end of file
# ===========================================================================
# Copyright 2013 Georgios Dagkakis
#
# 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 18 Aug 2013
@author: George
'''
'''
Class that acts as an abstract. It should have no instances. All object interruptions (eg failures, breaks) should inherit from it
'''
from SimPy.Simulation import Process, Resource
class ObjectInterruption(Process):
#the main process of the core object
#this is dummy, every object must have its own implementation
def run(self):
raise NotImplementedError("Subclass must define 'run' method")
#outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime):
pass
\ No newline at end of file
# ===========================================================================
# Copyright 2013 Georgios Dagkakis
#
# 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 18 Aug 2013
@author: George
'''
'''
Class that acts as an abstract. It should have no instances. All the Resources should inherit from it
'''
from SimPy.Simulation import Resource
#the resource that repairs the machines
class ObjectResource(object):
def initialize(self):
self.totalWorkingTime=0 #holds the total working time
self.totalWaitingTime=0 #holds the total waiting time
self.timeLastRepairStarted=0 #holds the time that the last repair was started
self.Res=Resource(self.capacity)
#checks if the worker is available
def checkIfResourceIsAvailable(self):
return len(self.W.activeQ)<self.capacity
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime):
pass
#outputs message to the trace.xls
def outputTrace(self, message):
pass
#outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime):
pass
#outputs results to JSON File
def outputResultsJSON(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):
difValuesFlag=False
for i in range(1, len(array)):
if(array[i]!=array[1]):
difValuesFlag=True
return difValuesFlag
\ No newline at end of file
......@@ -29,10 +29,11 @@ models a part entity that flows through the system
from SimPy.Simulation import *
from Globals import G
from Entity import Entity
#The entity object
class Part(object):
class Part(Entity):
type="Part"
def __init__(self, name):
......
......@@ -27,10 +27,12 @@ Models a FIFO queue where entities can wait in order to get into a server
from SimPy.Simulation import *
from CoreObject import CoreObject
#import sys
#the Queue object
class Queue(Process):
class Queue(CoreObject):
def __init__(self, id, name, capacity, dummy):
Process.__init__(self)
......@@ -77,7 +79,7 @@ class Queue(Process):
self.processingTimeOfCurrentEntity=0 #holds the total processing time that the current entity required
self.waitToDispose=False #shows if the object waits to dispose an entity
def run(self):
while 1:
yield waituntil, self, self.canAcceptAndIsRequested #wait until the Queue can accept an entity
......@@ -86,12 +88,7 @@ class Queue(Process):
#if entity just got to the dummyQ set its startTime as the current time
if self.isDummy:
self.Res.activeQ[0].startTime=now()
#sets the routing in and out elements for the queue
def defineRouting(self, p, n):
self.next=n
self.previous=p
self.Res.activeQ[0].startTime=now()
#checks if the Q has one available place
def checkIfQHasPlace(self):
......@@ -183,20 +180,6 @@ class Queue(Process):
self.predecessorIndex=i
maxTimeWaiting=timeWaiting
return len(self.Res.activeQ)<self.capacity and isRequested
#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
#and put it in front of the activeQ
self.previous[self.predecessorIndex].removeEntity() #remove the entity from the previous object
#removes an entity from the Queue (this is FIFO for now)
def removeEntity(self):
self.Res.activeQ.pop(0)
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime):
pass #no actions for the Queue
#outputs message to the trace.xls. Format is (Simulation Time | Entity Name | message)
def outputTrace(self, message):
......@@ -212,11 +195,3 @@ class Queue(Process):
G.traceIndex=0
G.sheetIndex+=1
G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True)
#outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime):
pass
#outputs results to JSON File
def outputResultsJSON(self):
pass
\ No newline at end of file
......@@ -26,12 +26,13 @@ Created on 14 Nov 2012
models a repairman that can fix a machine when it gets failures
'''
from SimPy.Simulation import *
from SimPy.Simulation import Resource
import xlwt
import scipy.stats as stat
from ObjectResource import ObjectResource
#the resource that repairs the machines
class Repairman(object):
class Repairman(ObjectResource):
def __init__(self, id, name, capacity):
self.id=id
......@@ -42,17 +43,10 @@ class Repairman(object):
#lists to hold statistics of multiple runs
self.Waiting=[]
self.Working=[]
def initialize(self):
self.totalWorkingTime=0 #holds the total working time
self.totalWaitingTime=0 #holds the total waiting time
self.timeLastRepairStarted=0 #holds the time that the last repair was started
self.Res=Resource(self.capacity)
#checks if the worker is available
def checkIfWorkerIsAvailable(self):
return len(self.W.activeQ)<self.capacity
self.coreObjectIds=[] #list with the coreObjects that the repairman repairs
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime):
#if the repairman is currently working we have to count the time of this work
......@@ -140,13 +134,5 @@ class Repairman(object):
json['results']['waiting_ratio']['avg']=self.Waiting[0]
json['results']['waiting_ratio']['max']=self.Waiting[0]
G.outputJSON['coreObject'].append(json)
G.outputJSON['elementList'].append(json)
#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):
difValuesFlag=False
for i in range(1, len(array)):
if(array[i]!=array[1]):
difValuesFlag=True
return difValuesFlag
\ No newline at end of file
......@@ -29,9 +29,10 @@ models the source object that generates the entities
from SimPy.Simulation import *
from Part import Part
from RandomNumberGenerator import RandomNumberGenerator
from CoreObject import CoreObject
#The Source object is a Process
class Source(Process):
class Source(CoreObject):
def __init__(self, id, name, dist, time, item):
Process.__init__(self)
self.id=id
......@@ -122,21 +123,6 @@ class Source(Process):
#sets the routing out element for the Source
def defineRouting(self, n):
self.next=n
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime):
pass #no actions for the Source
#checks if the Source can dispose an entity to the following object
def haveToDispose(self):
#return self.waitToDispose
return len(self.Res.activeQ)>0
#removes an entity from the Source
def removeEntity(self):
self.Res.activeQ.pop(0)
#if(len(self.Res.activeQ)==0):
#self.waitToDispose=False
#outputs message to the trace.xls. Format is (Simulation Time | Entity Name | "generated")
def outputTrace(self, message):
......@@ -153,11 +139,3 @@ class Source(Process):
G.traceIndex=0
G.sheetIndex+=1
G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True)
#outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime):
pass
#outputs results to JSON File
def outputResultsJSON(self):
pass
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