Commit 85b7051e authored by Georgios Dagkakis's avatar Georgios Dagkakis

AssemblyLine example also updated and added in test

parent 7a0a1f88
...@@ -3,13 +3,13 @@ from dream.simulation.imports import simulate, activate, initialize ...@@ -3,13 +3,13 @@ from dream.simulation.imports import simulate, activate, initialize
#define the objects of the model #define the objects of the model
Frame.capacity=4 Frame.capacity=4
Sp=Source('SP','Parts', mean=0.5, entity='Dream.Part') Sp=Source('SP','Parts', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
Sf=Source('SF','Frames', mean=2, entity='Dream.Frame') Sf=Source('SF','Frames', interarrivalTime={'distributionType':'Fixed','mean':2}, entity='Dream.Frame')
M=Machine('M','Machine', mean=0.25) M=Machine('M','Machine', processingTime={'distributionType':'Fixed','mean':0.25})
A=Assembly('A','Assembly', mean=2) A=Assembly('A','Assembly', processingTime={'distributionType':'Fixed','mean':2})
E=Exit('E1','Exit') E=Exit('E1','Exit')
F=Failure(victim=M, distributionType='Fixed', MTTF=60, MTTR=5) F=Failure(victim=M, distribution={'distributionType':'Fixed','MTTF':60,'MTTR':5})
G.ObjList=[Sp,Sf,M,A,E] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjList=[Sp,Sf,M,A,E] #add all the objects in G.ObjList so that they can be easier accessed later
...@@ -22,31 +22,37 @@ A.defineRouting([Sp,Sf],[M]) ...@@ -22,31 +22,37 @@ A.defineRouting([Sp,Sf],[M])
M.defineRouting([A],[E]) M.defineRouting([A],[E])
E.defineRouting([M]) E.defineRouting([M])
initialize() #initialize the simulation (SimPy method) def main():
initialize() #initialize the simulation (SimPy method)
for object in G.ObjList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
for object in G.ObjList: #activate all the objects
object.initialize() for object in G.ObjList:
activate(object, object.run())
for objectInterruption in G.ObjectInterruptionList: for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize() activate(objectInterruption, objectInterruption.run())
#activate all the objects
for object in G.ObjList:
activate(object, object.run())
for objectInterruption in G.ObjectInterruptionList:
activate(objectInterruption, objectInterruption.run())
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
simulate(until=G.maxSimTime) #run the simulation G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
#carry on the post processing operations for every object in the topology simulate(until=G.maxSimTime) #run the simulation
for object in G.ObjList:
object.postProcessing() #carry on the post processing operations for every object in the topology
for object in G.ObjList:
#print the results object.postProcessing()
print "the system produced", E.numOfExits, "frames"
print "the working ratio of", A.objName, "is", (A.totalWorkingTime/G.maxSimTime)*100, "%" #print the results
print "the system produced", E.numOfExits, "frames"
working_ratio=(A.totalWorkingTime/G.maxSimTime)*100
print "the working ratio of", A.objName, "is", working_ratio, "%"
return {"frames": E.numOfExits,
"working_ratio": working_ratio}
if __name__ == '__main__':
main()
...@@ -25,42 +25,42 @@ Q.defineRouting([M1],[M2]) ...@@ -25,42 +25,42 @@ Q.defineRouting([M1],[M2])
M2.defineRouting([Q],[E]) M2.defineRouting([Q],[E])
E.defineRouting([M2]) E.defineRouting([M2])
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
R.initialize()
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
R.initialize()
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
for objectInterruption in G.ObjectInterruptionList: for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize() objectInterruption.initialize()
#activate all the objects #activate all the objects
for object in G.ObjList: for object in G.ObjList:
activate(object, object.run()) activate(object, object.run())
for objectInterruption in G.ObjectInterruptionList: for objectInterruption in G.ObjectInterruptionList:
activate(objectInterruption, objectInterruption.run()) activate(objectInterruption, objectInterruption.run())
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day) G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
simulate(until=G.maxSimTime) #run the simulation simulate(until=G.maxSimTime) #run the simulation
#carry on the post processing operations for every object in the topology #carry on the post processing operations for every object in the topology
for object in G.ObjList: for object in G.ObjList:
object.postProcessing() object.postProcessing()
R.postProcessing() R.postProcessing()
#print the results #print the results
print "the system produced", E.numOfExits, "parts" print "the system produced", E.numOfExits, "parts"
blockage_ratio = (M1.totalBlockageTime/G.maxSimTime)*100 blockage_ratio = (M1.totalBlockageTime/G.maxSimTime)*100
working_ratio = (R.totalWorkingTime/G.maxSimTime)*100 working_ratio = (R.totalWorkingTime/G.maxSimTime)*100
print "the blockage ratio of", M1.objName, "is", blockage_ratio, "%" print "the blockage ratio of", M1.objName, "is", blockage_ratio, "%"
print "the working ratio of", R.objName,"is", working_ratio, "%" print "the working ratio of", R.objName,"is", working_ratio, "%"
return {"parts": E.numOfExits, return {"parts": E.numOfExits,
"blockage_ratio": blockage_ratio, "blockage_ratio": blockage_ratio,
"working_ratio": working_ratio} "working_ratio": working_ratio}
......
...@@ -38,5 +38,10 @@ class SimulationExamples(TestCase): ...@@ -38,5 +38,10 @@ class SimulationExamples(TestCase):
from dream.simulation.Examples.TwoServers import main from dream.simulation.Examples.TwoServers import main
result = main() result = main()
self.assertEquals(result['parts'], 732) self.assertEquals(result['parts'], 732)
self.assertTrue(78 < result["blockage_ratio"] < 79) self.assertTrue(78.17 < result["blockage_ratio"] < 78.18)
self.assertTrue(26 < result["working_ratio"] < 27) self.assertTrue(26.73 < result["working_ratio"] < 27.74)
from dream.simulation.Examples.AssemblyLine import main
result = main()
self.assertEquals(result['frames'], 664)
self.assertTrue(92.36 < result["working_ratio"] < 93.37)
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