Commit 73cfd6a0 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

some further enhancement to the code and the documentation. Plant topologies...

some further enhancement to the code and the documentation. Plant topologies removed, no need to get those open-source I suppose. Examples folders added with one example. To be populated and described in documentation
parent 59cea657
No preview for this file type
'''
Created on 14 Oct 2013
@author: George
'''
from SimPy.Simulation import simulate, activate, initialize
from dream.simulation.Machine import Machine
from dream.simulation.Source import Source
from dream.simulation.Exit import Exit
from dream.simulation.Part import Part
from dream.simulation.Globals import G
from dream.simulation.Entity import Entity
from dream.simulation.CoreObject import CoreObject
from random import Random
#define the objects of the model
S=Source('S1','Source',distribution='Fixed', mean=0.5, item=Part)
M=Machine('M1','Machine',distribution='Fixed', mean=0.25)
E=Exit('E1','Exit')
G.ObjList=[S,M,E] #add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
S.defineRouting([M])
M.defineRouting([S],[E])
E.defineRouting([M])
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
for object in G.ObjList:
object.initialize()
#activate all the objects
for object in G.ObjList:
activate(object, object.run())
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
simulate(until=G.maxSimTime) #run the simulation
#carry on the post processing operations for every object in the topology
for object in G.ObjList:
object.postProcessing(G.maxSimTime)
#print the results
print "the system produced", E.numOfExits, "parts"
print "the total working ration of the Machine is", (M.totalWorkingTime/G.maxSimTime)*100, "%"
......@@ -45,7 +45,7 @@ class Exit(CoreObject):
#lists to hold statistics of multiple runs
self.Exits=[]
self.Lifespan=[]
self.Lifespan=[]
def initialize(self):
Process.__init__(self)
......
......@@ -51,8 +51,8 @@ except ImportError:
logger.error("Scipy cannot be imported, using dummy implementation")
from SimPy.Simulation import activate, initialize, simulate, now, infinity
from Globals import G
from Source import Source
from Globals import G
from Machine import Machine
from Exit import Exit
from Queue import Queue
......
......@@ -38,7 +38,7 @@ import scipy.stats as stat
class Machine(CoreObject):
#initialize the id the capacity, of the resource and the distribution
def __init__(self, id, name, capacity, distribution='Fixed', mean=1, stdev=0, min=0, max=10, failureDistribution='No', MTTF=0, MTTR=0, availability=0, repairman=None):
def __init__(self, id, name, capacity=1, distribution='Fixed', mean=1, stdev=0, min=0, max=10, failureDistribution='No', MTTF=0, MTTR=0, availability=0, repairman=None):
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
......
......@@ -33,7 +33,7 @@ from CoreObject import CoreObject
#the Queue object
class Queue(CoreObject):
def __init__(self, id, name, capacity, dummy=False, schedulingRule="FIFO"):
def __init__(self, id, name, capacity=1, dummy=False, schedulingRule="FIFO"):
Process.__init__(self)
self.predecessorIndex=0 #holds the index of the predecessor from which the Queue will take an entity next
self.successorIndex=0 #holds the index of the successor where the Queue will dispose an entity next
......
......@@ -33,12 +33,11 @@ from CoreObject import CoreObject
#The Source object is a Process
class Source(CoreObject):
def __init__(self, id, name, dist, time, item):
def __init__(self, id, name, distribution='Fixed', mean=1, item=Part):
Process.__init__(self)
self.id=id
self.objName=name
self.distType=dist #label that sets the distribution type
self.interArrivalTime=time #the mean interarrival time
self.distType=distribution #label that sets the distribution type
self.totalInterArrivalTime=0 #the total interarrival time
self.numberOfArrivals=0 #the number of entities that were created
self.next=[] #list with the next objects in the flow
......@@ -48,11 +47,9 @@ class Source(CoreObject):
self.type="Source" #String that shows the type of object
#self.waitToDispose=False
self.rng=RandomNumberGenerator(self, self.distType)
self.rng.avg=time
self.rng.avg=mean
self.item=item #the type of object that the Source will generate
#self.Res=Resource(capacity=infinity)
def initialize(self):
Process.__init__(self)
self.Res=Resource(capacity=infinity)
......
......@@ -21,4 +21,4 @@ try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
__path__ = extend_path(__path__, __name__)
\ 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