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
#define the objects of the model
Frame.capacity=4
Sp=Source('SP','Parts', mean=0.5, entity='Dream.Part')
Sf=Source('SF','Frames', mean=2, entity='Dream.Frame')
M=Machine('M','Machine', mean=0.25)
A=Assembly('A','Assembly', mean=2)
Sp=Source('SP','Parts', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
Sf=Source('SF','Frames', interarrivalTime={'distributionType':'Fixed','mean':2}, entity='Dream.Frame')
M=Machine('M','Machine', processingTime={'distributionType':'Fixed','mean':0.25})
A=Assembly('A','Assembly', processingTime={'distributionType':'Fixed','mean':2})
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
......@@ -22,31 +22,37 @@ A.defineRouting([Sp,Sf],[M])
M.defineRouting([A],[E])
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:
object.initialize()
#activate all the objects
for object in G.ObjList:
activate(object, object.run())
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
#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)
for objectInterruption in G.ObjectInterruptionList:
activate(objectInterruption, objectInterruption.run())
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()
#print the results
print "the system produced", E.numOfExits, "frames"
print "the working ratio of", A.objName, "is", (A.totalWorkingTime/G.maxSimTime)*100, "%"
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()
#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])
M2.defineRouting([Q],[E])
E.defineRouting([M2])
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
R.initialize()
def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
R.initialize()
for object in G.ObjList:
object.initialize()
for object in G.ObjList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
#activate all the objects
for object in G.ObjList:
activate(object, object.run())
#activate all the objects
for object in G.ObjList:
activate(object, object.run())
for objectInterruption in G.ObjectInterruptionList:
activate(objectInterruption, objectInterruption.run())
for objectInterruption in G.ObjectInterruptionList:
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
for object in G.ObjList:
object.postProcessing()
R.postProcessing()
#carry on the post processing operations for every object in the topology
for object in G.ObjList:
object.postProcessing()
R.postProcessing()
#print the results
print "the system produced", E.numOfExits, "parts"
blockage_ratio = (M1.totalBlockageTime/G.maxSimTime)*100
working_ratio = (R.totalWorkingTime/G.maxSimTime)*100
print "the blockage ratio of", M1.objName, "is", blockage_ratio, "%"
print "the working ratio of", R.objName,"is", working_ratio, "%"
return {"parts": E.numOfExits,
#print the results
print "the system produced", E.numOfExits, "parts"
blockage_ratio = (M1.totalBlockageTime/G.maxSimTime)*100
working_ratio = (R.totalWorkingTime/G.maxSimTime)*100
print "the blockage ratio of", M1.objName, "is", blockage_ratio, "%"
print "the working ratio of", R.objName,"is", working_ratio, "%"
return {"parts": E.numOfExits,
"blockage_ratio": blockage_ratio,
"working_ratio": working_ratio}
......
......@@ -38,5 +38,10 @@ class SimulationExamples(TestCase):
from dream.simulation.Examples.TwoServers import main
result = main()
self.assertEquals(result['parts'], 732)
self.assertTrue(78 < result["blockage_ratio"] < 79)
self.assertTrue(26 < result["working_ratio"] < 27)
self.assertTrue(78.17 < result["blockage_ratio"] < 78.18)
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