Commit 0c200e84 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

enhancements in Examples

parent 6d1d9adc
from dream.simulation.imports import Machine, Source, Exit, Part, Frame, Assembly, G from dream.simulation.imports import Machine, Source, Exit, Part, Frame, Assembly, Failure, G
from dream.simulation.imports import simulate, activate, initialize 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, item=Part) Sp=Source('SP','Parts', mean=0.5, item=Part)
Sf=Source('SF','Frames', mean=2, item=Frame) Sf=Source('SF','Frames', mean=2, item=Frame)
M=Machine('M','Machine', mean=0.25, failureDistribution='Fixed', MTTF=60, MTTR=5) M=Machine('M','Machine', mean=0.25)
A=Assembly('A','Assembly', mean=2) A=Assembly('A','Assembly', mean=2)
E=Exit('E1','Exit') E=Exit('E1','Exit')
F=Failure(victim=M, 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
G.ObjectInterruptionList=[F] #add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects #define predecessors and successors for the objects
Sp.defineRouting([A]) Sp.defineRouting([A])
Sf.defineRouting([A]) Sf.defineRouting([A])
...@@ -20,14 +24,19 @@ E.defineRouting([M]) ...@@ -20,14 +24,19 @@ E.defineRouting([M])
initialize() #initialize the simulation (SimPy method) initialize() #initialize the simulation (SimPy method)
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
for objectInterruption in G.ObjectInterruptionList:
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:
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
......
from dream.simulation.imports import Machine, Source, Exit, Part, Queue, G from dream.simulation.imports import Machine, Source, Exit, Part, Queue, G, Failure
from dream.simulation.imports import simulate, activate, initialize, infinity from dream.simulation.imports import simulate, activate, initialize, infinity
#define the objects of the model #define the objects of the model
S=Source('S','Source', mean=0.5, item=Part) S=Source('S','Source', mean=0.5, item=Part)
Q=Queue('Q','Queue', capacity=infinity) Q=Queue('Q','Queue', capacity=infinity)
M1=Machine('M1','Milling1', mean=0.25, failureDistribution='Fixed', MTTF=60, MTTR=5) M1=Machine('M1','Milling1', mean=0.25)
M2=Machine('M2','Milling2', mean=0.25) M2=Machine('M2','Milling2', mean=0.25)
E=Exit('E1','Exit') E=Exit('E1','Exit')
F=Failure(victim=M1, distributionType='Fixed', MTTF=60, MTTR=5)
G.ObjList=[S,Q,M1,M2,E] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjList=[S,Q,M1,M2,E] #add all the objects in G.ObjList so that they can be easier accessed later
G.ObjectInterruptionList=[F] #add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects #define predecessors and successors for the objects
S.defineRouting([Q]) S.defineRouting([Q])
Q.defineRouting([S],[M1,M2]) Q.defineRouting([S],[M1,M2])
...@@ -19,14 +24,19 @@ E.defineRouting([M1,M2]) ...@@ -19,14 +24,19 @@ E.defineRouting([M1,M2])
initialize() #initialize the simulation (SimPy method) initialize() #initialize the simulation (SimPy method)
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
for objectInterruption in G.ObjectInterruptionList:
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:
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
......
from dream.simulation.imports import Machine, Source, Exit, Part, Queue, G, Globals from dream.simulation.imports import Machine, Source, Exit, Part, Queue, G, Globals, Failure
from dream.simulation.imports import simulate, activate, initialize, infinity from dream.simulation.imports import simulate, activate, initialize, infinity
#the custom queue #the custom queue
...@@ -16,13 +16,18 @@ class SelectiveQueue(Queue): ...@@ -16,13 +16,18 @@ class SelectiveQueue(Queue):
#define the objects of the model #define the objects of the model
S=Source('S','Source', mean=0.5, item=Part) S=Source('S','Source', mean=0.5, item=Part)
Q=SelectiveQueue('Q','Queue', capacity=infinity) #Q is now of type SelectiveQueue Q=SelectiveQueue('Q','Queue', capacity=infinity)
M1=Machine('M1','Milling1', mean=0.25, failureDistribution='Fixed', MTTF=60, MTTR=5) M1=Machine('M1','Milling1', mean=0.25)
M2=Machine('M2','Milling2', mean=0.25) M2=Machine('M2','Milling2', mean=0.25)
E=Exit('E1','Exit') E=Exit('E1','Exit')
F=Failure(victim=M1, distributionType='Fixed', MTTF=60, MTTR=5)
G.ObjList=[S,Q,M1,M2,E] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjList=[S,Q,M1,M2,E] #add all the objects in G.ObjList so that they can be easier accessed later
G.ObjectInterruptionList=[F] #add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects #define predecessors and successors for the objects
S.defineRouting([Q]) S.defineRouting([Q])
Q.defineRouting([S],[M1,M2]) Q.defineRouting([S],[M1,M2])
...@@ -32,14 +37,19 @@ E.defineRouting([M1,M2]) ...@@ -32,14 +37,19 @@ E.defineRouting([M1,M2])
initialize() #initialize the simulation (SimPy method) initialize() #initialize the simulation (SimPy method)
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
for objectInterruption in G.ObjectInterruptionList:
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:
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
...@@ -52,5 +62,3 @@ for object in G.ObjList: ...@@ -52,5 +62,3 @@ for object in G.ObjList:
print "the system produced", E.numOfExits, "parts" print "the system produced", E.numOfExits, "parts"
print "the working ratio of", M1.objName, "is", (M1.totalWorkingTime/G.maxSimTime)*100, "%" print "the working ratio of", M1.objName, "is", (M1.totalWorkingTime/G.maxSimTime)*100, "%"
print "the working ratio of", M2.objName, "is", (M2.totalWorkingTime/G.maxSimTime)*100, "%" print "the working ratio of", M2.objName, "is", (M2.totalWorkingTime/G.maxSimTime)*100, "%"
from dream.simulation.imports import Machine, Source, Exit, Part, Queue, G, Globals from dream.simulation.imports import Machine, Source, Exit, Part, Queue, G, Globals, Failure
from dream.simulation.imports import simulate, activate, initialize, infinity from dream.simulation.imports import simulate, activate, initialize, infinity
#the custom queue #the custom queue
...@@ -36,13 +36,17 @@ class CountingExit(Exit): ...@@ -36,13 +36,17 @@ class CountingExit(Exit):
#define the objects of the model #define the objects of the model
S=Source('S','Source', mean=0.5, item=Part) S=Source('S','Source', mean=0.5, item=Part)
Q=SelectiveQueue('Q','Queue', capacity=infinity) Q=SelectiveQueue('Q','Queue', capacity=infinity)
M1=Milling('M1','Milling1', mean=0.25, failureDistribution='Fixed', MTTF=60, MTTR=5) M1=Milling('M1','Milling1', mean=0.25)
M2=Milling('M2','Milling2', mean=0.25) M2=Milling('M2','Milling2', mean=0.25)
E=CountingExit('E1','Exit') E=CountingExit('E1','Exit')
F=Failure(victim=M1, distributionType='Fixed', MTTF=60, MTTR=5)
G.ObjList=[S,Q,M1,M2,E] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjList=[S,Q,M1,M2,E] #add all the objects in G.ObjList so that they can be easier accessed later
#create the global variables G.ObjectInterruptionList=[F] #add all the objects in G.ObjList so that they can be easier accessed later
#create the global counter variables
G.NumM1=0 G.NumM1=0
G.NumM2=0 G.NumM2=0
...@@ -55,14 +59,19 @@ E.defineRouting([M1,M2]) ...@@ -55,14 +59,19 @@ E.defineRouting([M1,M2])
initialize() #initialize the simulation (SimPy method) initialize() #initialize the simulation (SimPy method)
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
for objectInterruption in G.ObjectInterruptionList:
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:
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
......
...@@ -15,7 +15,7 @@ F2=Failure(victim=M2, distributionType='Fixed', MTTF=40, MTTR=10, repairman=R) ...@@ -15,7 +15,7 @@ F2=Failure(victim=M2, distributionType='Fixed', MTTF=40, MTTR=10, repairman=R)
G.ObjList=[S,M1,M2,E,Q] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjList=[S,M1,M2,E,Q] #add all the objects in G.ObjList so that they can be easier accessed later
G.FailureList=[F1,F2] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjectInterruptionList=[F1,F2] #add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects #define predecessors and successors for the objects
S.defineRouting([M1]) S.defineRouting([M1])
...@@ -32,15 +32,16 @@ R.initialize() ...@@ -32,15 +32,16 @@ R.initialize()
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
for failure in G.FailureList: for objectInterruption in G.ObjectInterruptionList:
failure.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 failure in G.FailureList: for objectInterruption in G.ObjectInterruptionList:
activate(failure, failure.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)
......
...@@ -18,7 +18,7 @@ F2=Failure(victim=M2, distributionType='Fixed', MTTF=40, MTTR=10, repairman=R) ...@@ -18,7 +18,7 @@ F2=Failure(victim=M2, distributionType='Fixed', MTTF=40, MTTR=10, repairman=R)
G.ObjList=[S,M1,M2,E,Q] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjList=[S,M1,M2,E,Q] #add all the objects in G.ObjList so that they can be easier accessed later
G.FailureList=[F1,F2] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjectInterruptionList=[F1,F2] #add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects #define predecessors and successors for the objects
S.defineRouting([M1]) S.defineRouting([M1])
...@@ -35,15 +35,15 @@ R.initialize() ...@@ -35,15 +35,15 @@ R.initialize()
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
for failure in G.FailureList: for objectInterruption in G.ObjectInterruptionList:
failure.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 failure in G.FailureList: for objectInterruption in G.ObjectInterruptionList:
activate(failure, failure.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)
......
...@@ -15,7 +15,7 @@ F2=Failure(victim=M2, distributionType='Fixed', MTTF=40, MTTR=10, repairman=R) ...@@ -15,7 +15,7 @@ F2=Failure(victim=M2, distributionType='Fixed', MTTF=40, MTTR=10, repairman=R)
G.ObjList=[S,M1,M2,E,Q] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjList=[S,M1,M2,E,Q] #add all the objects in G.ObjList so that they can be easier accessed later
G.FailureList=[F1,F2] #add all the objects in G.ObjList so that they can be easier accessed later G.ObjectInterruptionList=[F1,F2] #add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects #define predecessors and successors for the objects
S.defineRouting([M1]) S.defineRouting([M1])
...@@ -38,16 +38,16 @@ for i in range(G.numberOfReplications): ...@@ -38,16 +38,16 @@ for i in range(G.numberOfReplications):
R.initialize() R.initialize()
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
for failure in G.FailureList: for objectInterruption in G.ObjectInterruptionList:
failure.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 failure in G.FailureList: for objectInterruption in G.ObjectInterruptionList:
activate(failure, failure.run()) activate(objectInterruption, objectInterruption.run())
simulate(until=G.maxSimTime) #run the simulation simulate(until=G.maxSimTime) #run the simulation
......
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