Commit c81437eb authored by Georgios Dagkakis's avatar Georgios Dagkakis

examples working. Notes, testTwoServers stochastic is not working cause of the...

examples working. Notes, testTwoServers stochastic is not working cause of the multiple runs issue and DecompositionOfBatches produces one less cause SimPy3 does not process events scheduled exactly for theend simulation time
parent 5c2221f2
from dream.simulation.imports import Machine, Source, Exit, Part, Frame, Assembly, Failure, 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 simpy
G.env=simpy.Environment() # define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model #define the objects of the model
Frame.capacity=4 Frame.capacity=4
...@@ -23,8 +26,8 @@ M.defineRouting([A],[E]) ...@@ -23,8 +26,8 @@ M.defineRouting([A],[E])
E.defineRouting([M]) E.defineRouting([M])
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
...@@ -33,14 +36,14 @@ def main(): ...@@ -33,14 +36,14 @@ def main():
#activate all the objects #activate all the objects
for object in G.ObjList: for object in G.ObjList:
activate(object, object.run()) G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList: for objectInterruption in G.ObjectInterruptionList:
activate(objectInterruption, objectInterruption.run()) G.env.process(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 G.env.run(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:
......
from dream.simulation.imports import Machine, Source, Exit, Batch, BatchDecomposition,\ from dream.simulation.imports import Machine, Source, Exit, Batch, BatchDecomposition,\
BatchSource, BatchReassembly, Queue, LineClearance, ExcelHandler, G, ExcelHandler BatchSource, BatchReassembly, Queue, LineClearance, ExcelHandler, G, ExcelHandler
from dream.simulation.imports import simulate, activate, initialize from dream.simulation.imports import simpy
G.env=simpy.Environment() # define a simpy environment
# this is where all the simulation object 'live'
# choose to output trace or not # choose to output trace or not
G.trace='Yes' G.trace='Yes'
...@@ -28,18 +31,19 @@ M3.defineRouting([BRA],[E]) ...@@ -28,18 +31,19 @@ M3.defineRouting([BRA],[E])
E.defineRouting([M3]) E.defineRouting([M3])
def main(): def main():
# initialize the simulation (SimPy method)
initialize()
# initialize all the objects # initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
# activate all the objects
#activate all the objects
for object in G.ObjList: for object in G.ObjList:
activate(object,object.run()) G.env.process(object.run())
# set G.maxSimTime 1440.0 minutes (1 day) # set G.maxSimTime 1440.0 minutes (1 day)
G.maxSimTime=1440.0 G.maxSimTime=1440.0
# run the simulation # run the simulation
simulate(until=G.maxSimTime) G.env.run(until=G.maxSimTime)
# 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()
......
from dream.simulation.imports import Machine, BatchSource, Exit, Batch, BatchDecomposition, Queue, G from dream.simulation.imports import Machine, BatchSource, Exit, Batch, BatchDecomposition, Queue, G
from dream.simulation.imports import simulate, activate, initialize from dream.simulation.imports import simpy
G.env=simpy.Environment() # define a simpy environment
# this is where all the simulation object 'live'
# define the objects of the model # define the objects of the model
S=BatchSource('S','Source',interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Batch', batchNumberOfUnits=4) S=BatchSource('S','Source',interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Batch', batchNumberOfUnits=4)
...@@ -17,21 +20,23 @@ M.defineRouting([BD],[E]) ...@@ -17,21 +20,23 @@ M.defineRouting([BD],[E])
E.defineRouting([M]) E.defineRouting([M])
def main(): def main():
# initialize the simulation (SimPy method)
initialize()
# initialize all the objects # initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
# activate all the objects
#activate all the objects
for object in G.ObjList: for object in G.ObjList:
activate(object,object.run()) G.env.process(object.run())
# set G.maxSimTime 1440.0 minutes (1 day) # set G.maxSimTime 1440.0 minutes (1 day)
G.maxSimTime=1440.0 G.maxSimTime=1440.0
# run the simulation # run the simulation
simulate(until=G.maxSimTime) G.env.run(until=G.maxSimTime)
# 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()
# print the results # print the results
print "the system produced", E.numOfExits, "subbatches" print "the system produced", E.numOfExits, "subbatches"
working_ratio = (M.totalWorkingTime/G.maxSimTime)*100 working_ratio = (M.totalWorkingTime/G.maxSimTime)*100
......
from dream.simulation.imports import Machine, Source, Exit, Part, Queue, G, Failure 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 simpy
G.env=simpy.Environment() # define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model #define the objects of the model
S=Source('S','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part') S=Source('S','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
Q=Queue('Q','Queue', capacity=infinity) Q=Queue('Q','Queue', capacity=float("inf"))
M1=Machine('M1','Milling1', processingTime={'distributionType':'Fixed','mean':0.25}) M1=Machine('M1','Milling1', processingTime={'distributionType':'Fixed','mean':0.25})
M2=Machine('M2','Milling2', processingTime={'distributionType':'Fixed','mean':0.25}) M2=Machine('M2','Milling2', processingTime={'distributionType':'Fixed','mean':0.25})
E=Exit('E1','Exit') E=Exit('E1','Exit')
...@@ -23,8 +25,8 @@ M2.defineRouting([Q],[E]) ...@@ -23,8 +25,8 @@ M2.defineRouting([Q],[E])
E.defineRouting([M1,M2]) E.defineRouting([M1,M2])
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
...@@ -33,14 +35,14 @@ def main(): ...@@ -33,14 +35,14 @@ def main():
#activate all the objects #activate all the objects
for object in G.ObjList: for object in G.ObjList:
activate(object, object.run()) G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList: for objectInterruption in G.ObjectInterruptionList:
activate(objectInterruption, objectInterruption.run()) G.env.process(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 G.env.run(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:
......
from dream.simulation.imports import Machine, Source, Exit, Part, Queue, G, Globals, Failure 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 simpy
G.env=simpy.Environment() # define a simpy environment
# this is where all the simulation object 'live'
#the custom queue #the custom queue
class SelectiveQueue(Queue): class SelectiveQueue(Queue):
...@@ -13,7 +16,7 @@ class SelectiveQueue(Queue): ...@@ -13,7 +16,7 @@ class SelectiveQueue(Queue):
#define the objects of the model #define the objects of the model
S=Source('S','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part') S=Source('S','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
Q=SelectiveQueue('Q','Queue', capacity=infinity) Q=Queue('Q','Queue', capacity=float("inf"))
M1=Machine('M1','Milling1', processingTime={'distributionType':'Fixed','mean':0.25}) M1=Machine('M1','Milling1', processingTime={'distributionType':'Fixed','mean':0.25})
M2=Machine('M2','Milling2', processingTime={'distributionType':'Fixed','mean':0.25}) M2=Machine('M2','Milling2', processingTime={'distributionType':'Fixed','mean':0.25})
E=Exit('E1','Exit') E=Exit('E1','Exit')
...@@ -33,8 +36,8 @@ M2.defineRouting([Q],[E]) ...@@ -33,8 +36,8 @@ M2.defineRouting([Q],[E])
E.defineRouting([M1,M2]) E.defineRouting([M1,M2])
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
...@@ -43,14 +46,14 @@ def main(): ...@@ -43,14 +46,14 @@ def main():
#activate all the objects #activate all the objects
for object in G.ObjList: for object in G.ObjList:
activate(object, object.run()) G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList: for objectInterruption in G.ObjectInterruptionList:
activate(objectInterruption, objectInterruption.run()) G.env.process(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 G.env.run(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:
......
from dream.simulation.imports import Machine, Source, Exit, Part, Queue, G, Globals, Failure 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 simpy
G.env=simpy.Environment() # define a simpy environment
# this is where all the simulation object 'live'
#the custom queue #the custom queue
class SelectiveQueue(Queue): class SelectiveQueue(Queue):
...@@ -32,7 +36,7 @@ class CountingExit(Exit): ...@@ -32,7 +36,7 @@ class CountingExit(Exit):
#define the objects of the model #define the objects of the model
S=Source('S','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part') S=Source('S','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
Q=SelectiveQueue('Q','Queue', capacity=infinity) Q=SelectiveQueue('Q','Queue', capacity=float("inf"))
M1=Milling('M1','Milling1', processingTime={'distributionType':'Fixed','mean':0.25}) M1=Milling('M1','Milling1', processingTime={'distributionType':'Fixed','mean':0.25})
M2=Milling('M2','Milling2', processingTime={'distributionType':'Fixed','mean':0.25}) M2=Milling('M2','Milling2', processingTime={'distributionType':'Fixed','mean':0.25})
E=CountingExit('E1','Exit') E=CountingExit('E1','Exit')
...@@ -55,8 +59,8 @@ M2.defineRouting([Q],[E]) ...@@ -55,8 +59,8 @@ M2.defineRouting([Q],[E])
E.defineRouting([M1,M2]) E.defineRouting([M1,M2])
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
...@@ -65,14 +69,14 @@ def main(): ...@@ -65,14 +69,14 @@ def main():
#activate all the objects #activate all the objects
for object in G.ObjList: for object in G.ObjList:
activate(object, object.run()) G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList: for objectInterruption in G.ObjectInterruptionList:
activate(objectInterruption, objectInterruption.run()) G.env.process(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 G.env.run(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:
......
from dream.simulation.imports import Machine, BatchSource, Exit, Batch, BatchDecomposition, BatchReassembly, Queue, G from dream.simulation.imports import Machine, BatchSource, Exit, Batch, BatchDecomposition, BatchReassembly, Queue, G
from dream.simulation.imports import simulate, activate, initialize from dream.simulation.imports import simpy
G.env=simpy.Environment() # define a simpy environment
# this is where all the simulation object 'live'
# define the objects of the model # define the objects of the model
S=BatchSource('S','Source',interarrivalTime={'distributionType':'Fixed','mean':1.5}, entity='Dream.Batch', batchNumberOfUnits=100) S=BatchSource('S','Source',interarrivalTime={'distributionType':'Fixed','mean':1.5}, entity='Dream.Batch', batchNumberOfUnits=100)
Q=Queue('Q','StartQueue',capacity=100000) Q=Queue('Q','StartQueue',capacity=100000)
...@@ -25,18 +27,18 @@ M3.defineRouting([BRA],[E]) ...@@ -25,18 +27,18 @@ M3.defineRouting([BRA],[E])
E.defineRouting([M3]) E.defineRouting([M3])
def main(): def main():
# initialize the simulation (SimPy method)
initialize()
# initialize all the objects # initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
# activate all the objects
#activate all the objects
for object in G.ObjList: for object in G.ObjList:
activate(object,object.run()) G.env.process(object.run())
# set G.maxSimTime 1440.0 minutes (1 day) # set G.maxSimTime 1440.0 minutes (1 day)
G.maxSimTime=1440.0 G.maxSimTime=1440.0
# run the simulation # run the simulation
simulate(until=G.maxSimTime) G.env.run(until=G.maxSimTime)
# 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()
......
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