Commit 5c2221f2 authored by Georgios Dagkakis's avatar Georgios Dagkakis

JobShop and TwoServers (except stochastic) examples running

parent 10b97050
from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G
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
Q1=QueueJobShop('Q1','Queue1', capacity=infinity) Q1=QueueJobShop('Q1','Queue1', capacity=float("inf"))
Q2=QueueJobShop('Q2','Queue2', capacity=infinity) Q2=QueueJobShop('Q2','Queue2', capacity=float("inf"))
Q3=QueueJobShop('Q3','Queue3', capacity=infinity) Q3=QueueJobShop('Q3','Queue3', capacity=float("inf"))
M1=MachineJobShop('M1','Machine1') M1=MachineJobShop('M1','Machine1')
M2=MachineJobShop('M2','Machine2') M2=MachineJobShop('M2','Machine2')
M3=MachineJobShop('M3','Machine3') M3=MachineJobShop('M3','Machine3')
...@@ -25,24 +28,26 @@ J=Job('J1','Job1',route=J1Route) ...@@ -25,24 +28,26 @@ J=Job('J1','Job1',route=J1Route)
G.EntityList=[J] #a list to hold all the jobs G.EntityList=[J] #a list to hold all the jobs
def main(): def main():
initialize() #initialize the simulation (SimPy method) #initialize all the objects
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
J.initialize() J.initialize()
#set the WIP
Globals.setWIP(G.EntityList)
#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 the WIP
Globals.setWIP(G.EntityList)
simulate(until=infinity) #run the simulation until there are no more events G.env.run(until=float("inf")) #run the simulation until there are no more events
G.maxSimTime=E.timeLastEntityLeft #calculate the maxSimTime as the time that the last Job left G.maxSimTime=E.timeLastEntityLeft #calculate the maxSimTime as the time that the last Job left
#carry on the post processing operations for every object in the topology
for object in G.ObjList:
object.postProcessing()
#loop in the schedule to print the results #loop in the schedule to print the results
returnSchedule=[] # dummy variable used just for returning values and testing returnSchedule=[] # dummy variable used just for returning values and testing
for record in J.schedule: for record in J.schedule:
......
from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G, ExcelHandler from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G, ExcelHandler
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'
G.trace="Yes" G.trace="Yes"
#define the objects of the model #define the objects of the model
Q1=QueueJobShop('Q1','Queue1', capacity=infinity) Q1=QueueJobShop('Q1','Queue1', capacity=float("inf"))
Q2=QueueJobShop('Q2','Queue2', capacity=infinity) Q2=QueueJobShop('Q2','Queue2', capacity=float("inf"))
Q3=QueueJobShop('Q3','Queue3', capacity=infinity) Q3=QueueJobShop('Q3','Queue3', capacity=float("inf"))
M1=MachineJobShop('M1','Machine1') M1=MachineJobShop('M1','Machine1')
M2=MachineJobShop('M2','Machine2') M2=MachineJobShop('M2','Machine2')
M3=MachineJobShop('M3','Machine3') M3=MachineJobShop('M3','Machine3')
...@@ -27,24 +30,26 @@ J=Job('J1','Job1',route=J1Route) ...@@ -27,24 +30,26 @@ J=Job('J1','Job1',route=J1Route)
G.EntityList=[J] #a list to hold all the jobs G.EntityList=[J] #a list to hold all the jobs
def main(): def main():
initialize() #initialize the simulation (SimPy method) #initialize all the objects
#initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
J.initialize() J.initialize()
#set the WIP
Globals.setWIP(G.EntityList)
#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 the WIP
Globals.setWIP(G.EntityList)
simulate(until=infinity) #run the simulation until there are no more events G.env.run(until=float("inf")) #run the simulation until there are no more events
G.maxSimTime=E.timeLastEntityLeft #calculate the maxSimTime as the time that the last Job left G.maxSimTime=E.timeLastEntityLeft #calculate the maxSimTime as the time that the last Job left
#carry on the post processing operations for every object in the topology
for object in G.ObjList:
object.postProcessing()
#loop in the schedule to print the results #loop in the schedule to print the results
schedule=[] schedule=[]
for record in J.schedule: for record in J.schedule:
......
from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G
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
Q1=QueueJobShop('Q1','Queue1', capacity=infinity, schedulingRule="EDD") Q1=QueueJobShop('Q1','Queue1', capacity=float("inf"), schedulingRule="EDD")
Q2=QueueJobShop('Q2','Queue2', capacity=infinity) Q2=QueueJobShop('Q2','Queue2', capacity=float("inf"))
Q3=QueueJobShop('Q3','Queue3', capacity=infinity) Q3=QueueJobShop('Q3','Queue3', capacity=float("inf"))
M1=MachineJobShop('M1','Machine1') M1=MachineJobShop('M1','Machine1')
M2=MachineJobShop('M2','Machine2') M2=MachineJobShop('M2','Machine2')
M3=MachineJobShop('M3','Machine3') M3=MachineJobShop('M3','Machine3')
...@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]}, ...@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]},
J1=Job('J1','Job1',route=J1Route, priority=1, dueDate=100) J1=Job('J1','Job1',route=J1Route, priority=1, dueDate=100)
J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90) J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90)
J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110) J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110)
G.JobList=[J1,J2,J3] #a list to hold all the jobs G.EntityList=[J1,J2,J3] #a list to hold all the jobs
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day) G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects #initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
...@@ -59,19 +61,25 @@ def main(): ...@@ -59,19 +61,25 @@ def main():
#initialize all the jobs #initialize all the jobs
for job in G.JobList: for job in G.JobList:
job.initialize() job.initialize()
#set the WIP for all the jobs #set the WIP
Globals.setWIP(G.JobList) Globals.setWIP(G.EntityList)
#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())
G.env.run(until=float("inf")) #run the simulation until there are no more events
G.maxSimTime=E.timeLastEntityLeft #calculate the maxSimTime as the time that the last Job left
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()
#output the schedule of every job #output the schedule of every job
returnSchedule=[] # dummy variable used just for returning values and testing returnSchedule=[] # dummy variable used just for returning values and testing
for job in G.JobList: for job in G.EntityList:
#loop in the schedule to print the results #loop in the schedule to print the results
for record in job.schedule: for record in job.schedule:
#schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id #schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id
......
from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G
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
Q1=QueueJobShop('Q1','Queue1', capacity=infinity, schedulingRule="MC-Priority-EDD") Q1=QueueJobShop('Q1','Queue1', capacity=float("inf"), schedulingRule="MC-Priority-EDD")
Q2=QueueJobShop('Q2','Queue2', capacity=infinity) Q2=QueueJobShop('Q2','Queue2', capacity=float("inf"))
Q3=QueueJobShop('Q3','Queue3', capacity=infinity) Q3=QueueJobShop('Q3','Queue3', capacity=float("inf"))
M1=MachineJobShop('M1','Machine1') M1=MachineJobShop('M1','Machine1')
M2=MachineJobShop('M2','Machine2') M2=MachineJobShop('M2','Machine2')
M3=MachineJobShop('M3','Machine3') M3=MachineJobShop('M3','Machine3')
...@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]}, ...@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]},
J1=Job('J1','Job1',route=J1Route, priority=1, dueDate=100) J1=Job('J1','Job1',route=J1Route, priority=1, dueDate=100)
J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90) J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90)
J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110) J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110)
G.JobList=[J1,J2,J3] #a list to hold all the jobs G.EntityList=[J1,J2,J3] #a list to hold all the jobs
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day) G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects #initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
...@@ -59,19 +61,25 @@ def main(): ...@@ -59,19 +61,25 @@ def main():
#initialize all the jobs #initialize all the jobs
for job in G.JobList: for job in G.JobList:
job.initialize() job.initialize()
#set the WIP for all the jobs #set the WIP
Globals.setWIP(G.JobList) Globals.setWIP(G.EntityList)
#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())
G.env.run(until=float("inf")) #run the simulation until there are no more events
G.maxSimTime=E.timeLastEntityLeft #calculate the maxSimTime as the time that the last Job left
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()
#output the schedule of every job #output the schedule of every job
returnSchedule=[] # dummy variable used just for returning values and testing returnSchedule=[] # dummy variable used just for returning values and testing
for job in G.JobList: for job in G.EntityList:
#loop in the schedule to print the results #loop in the schedule to print the results
for record in job.schedule: for record in job.schedule:
#schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id #schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id
......
from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G
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
Q1=QueueJobShop('Q1','Queue1', capacity=infinity, schedulingRule="Priority") Q1=QueueJobShop('Q1','Queue1', capacity=float("inf"), schedulingRule="Priority")
Q2=QueueJobShop('Q2','Queue2', capacity=infinity) Q2=QueueJobShop('Q2','Queue2', capacity=float("inf"))
Q3=QueueJobShop('Q3','Queue3', capacity=infinity) Q3=QueueJobShop('Q3','Queue3', capacity=float("inf"))
M1=MachineJobShop('M1','Machine1') M1=MachineJobShop('M1','Machine1')
M2=MachineJobShop('M2','Machine2') M2=MachineJobShop('M2','Machine2')
M3=MachineJobShop('M3','Machine3') M3=MachineJobShop('M3','Machine3')
...@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]}, ...@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]},
J1=Job('J1','Job1',route=J1Route, priority=1, dueDate=100) J1=Job('J1','Job1',route=J1Route, priority=1, dueDate=100)
J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90) J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90)
J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110) J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110)
G.JobList=[J1,J2,J3] #a list to hold all the jobs G.EntityList=[J1,J2,J3] #a list to hold all the jobs
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day) G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects #initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
...@@ -59,19 +61,25 @@ def main(): ...@@ -59,19 +61,25 @@ def main():
#initialize all the jobs #initialize all the jobs
for job in G.JobList: for job in G.JobList:
job.initialize() job.initialize()
#set the WIP for all the jobs #set the WIP
Globals.setWIP(G.JobList) Globals.setWIP(G.EntityList)
#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())
G.env.run(until=float("inf")) #run the simulation until there are no more events
G.maxSimTime=E.timeLastEntityLeft #calculate the maxSimTime as the time that the last Job left
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()
#output the schedule of every job #output the schedule of every job
returnSchedule=[] # dummy variable used just for returning values and testing returnSchedule=[] # dummy variable used just for returning values and testing
for job in G.JobList: for job in G.EntityList:
#loop in the schedule to print the results #loop in the schedule to print the results
for record in job.schedule: for record in job.schedule:
#schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id #schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id
......
from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G from dream.simulation.imports import MachineJobShop, QueueJobShop, ExitJobShop, Globals, Job, G
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
Q1=QueueJobShop('Q1','Queue1', capacity=infinity, schedulingRule="RPC") Q1=QueueJobShop('Q1','Queue1', capacity=float("inf"), schedulingRule="RPC")
Q2=QueueJobShop('Q2','Queue2', capacity=infinity) Q2=QueueJobShop('Q2','Queue2', capacity=float("inf"))
Q3=QueueJobShop('Q3','Queue3', capacity=infinity) Q3=QueueJobShop('Q3','Queue3', capacity=float("inf"))
M1=MachineJobShop('M1','Machine1') M1=MachineJobShop('M1','Machine1')
M2=MachineJobShop('M2','Machine2') M2=MachineJobShop('M2','Machine2')
M3=MachineJobShop('M3','Machine3') M3=MachineJobShop('M3','Machine3')
...@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]}, ...@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]},
J1=Job('J1','Job1',route=J1Route, priority=1, dueDate=100) J1=Job('J1','Job1',route=J1Route, priority=1, dueDate=100)
J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90) J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90)
J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110) J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110)
G.JobList=[J1,J2,J3] #a list to hold all the jobs G.EntityList=[J1,J2,J3] #a list to hold all the jobs
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day) G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects #initialize all the objects
for object in G.ObjList: for object in G.ObjList:
object.initialize() object.initialize()
...@@ -59,19 +61,25 @@ def main(): ...@@ -59,19 +61,25 @@ def main():
#initialize all the jobs #initialize all the jobs
for job in G.JobList: for job in G.JobList:
job.initialize() job.initialize()
#set the WIP for all the jobs #set the WIP
Globals.setWIP(G.JobList) Globals.setWIP(G.EntityList)
#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())
G.env.run(until=float("inf")) #run the simulation until there are no more events
G.maxSimTime=E.timeLastEntityLeft #calculate the maxSimTime as the time that the last Job left
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()
#output the schedule of every job #output the schedule of every job
returnSchedule=[] # dummy variable used just for returning values and testing returnSchedule=[] # dummy variable used just for returning values and testing
for job in G.JobList: for job in G.EntityList:
#loop in the schedule to print the results #loop in the schedule to print the results
for record in job.schedule: for record in job.schedule:
#schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id #schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id
......
from dream.simulation.imports import Machine, Source, Exit, Part, G, Repairman, Queue, Failure from dream.simulation.imports import Machine, Source, Exit, Part, G, Repairman, Queue, Failure
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
R=Repairman('R1', 'Bob') R=Repairman('R1', 'Bob')
...@@ -15,7 +18,7 @@ F2=Failure(victim=M2, distribution={'distributionType':'Fixed','MTTF':40,'MTTR': ...@@ -15,7 +18,7 @@ F2=Failure(victim=M2, distribution={'distributionType':'Fixed','MTTF':40,'MTTR':
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.MachineList=[M1,M2] G.MachineList=[M1,M2]
G.ObjectResourceList=[R]
G.ObjectInterruptionList=[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
...@@ -26,33 +29,34 @@ M2.defineRouting([Q],[E]) ...@@ -26,33 +29,34 @@ M2.defineRouting([Q],[E])
E.defineRouting([M2]) E.defineRouting([M2])
def main(): def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects #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()
for objectResource in G.ObjectResourceList:
objectResource.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())
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:
object.postProcessing() object.postProcessing()
R.postProcessing()
for objectResource in G.ObjectResourceList:
objectResource.postProcessing()
#print the results #print the results
print "the system produced", E.numOfExits, "parts" print "the system produced", E.numOfExits, "parts"
......
from dream.simulation.imports import Machine, Source, Exit, Part, G, Repairman, Queue, Failure from dream.simulation.imports import Machine, Source, Exit, Part, G, Repairman, Queue, Failure
from dream.simulation.imports import simulate, activate, initialize from dream.simulation.imports import simpy
#import Graphs #import Graphs
from dream.KnowledgeExtraction.Plots import Graphs from dream.KnowledgeExtraction.Plots import Graphs
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
R=Repairman('R1', 'Bob') R=Repairman('R1', 'Bob')
S=Source('S1','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part') S=Source('S1','Source', interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
...@@ -17,7 +20,8 @@ F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR': ...@@ -17,7 +20,8 @@ F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR':
F2=Failure(victim=M2, distribution={'distributionType':'Fixed','MTTF':40,'MTTR':10}, repairman=R) F2=Failure(victim=M2, distribution={'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.MachineList=[M1,M2]
G.ObjectResourceList=[R]
G.ObjectInterruptionList=[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
...@@ -27,34 +31,36 @@ Q.defineRouting([M1],[M2]) ...@@ -27,34 +31,36 @@ Q.defineRouting([M1],[M2])
M2.defineRouting([Q],[E]) M2.defineRouting([Q],[E])
E.defineRouting([M2]) E.defineRouting([M2])
def main():
initialize() #initialize the simulation (SimPy method)
#initialize all the objects
R.initialize()
def main():
#initialize all the objects
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()
for objectResource in G.ObjectResourceList:
objectResource.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())
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:
object.postProcessing() object.postProcessing()
R.postProcessing()
for objectResource in G.ObjectResourceList:
objectResource.postProcessing()
#print the results #print the results
print "the system produced", E.numOfExits, "parts" print "the system produced", E.numOfExits, "parts"
...@@ -63,6 +69,7 @@ def main(): ...@@ -63,6 +69,7 @@ def main():
waiting_ratio = (R.totalWaitingTime/G.maxSimTime)*100 waiting_ratio = (R.totalWaitingTime/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, "%"
#create a graph object #create a graph object
graph=Graphs() graph=Graphs()
#create the pie #create the pie
......
from dream.simulation.imports import Machine, Source, Exit, Part, G, Repairman, Queue, Failure from dream.simulation.imports import Machine, Source, Exit, Part, G, Repairman, Queue, Failure
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
R=Repairman('R1', 'Bob') R=Repairman('R1', 'Bob')
...@@ -14,7 +17,7 @@ F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR': ...@@ -14,7 +17,7 @@ F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR':
F2=Failure(victim=M2, distribution={'distributionType':'Fixed','MTTF':40,'MTTR':10}, repairman=R) F2=Failure(victim=M2, distribution={'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.ObjectResourceList=[R]
G.ObjectInterruptionList=[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
...@@ -32,29 +35,31 @@ G.confidenceLevel=0.99 #set the confidence level. 0.99=99% ...@@ -32,29 +35,31 @@ G.confidenceLevel=0.99 #set the confidence level. 0.99=99%
for i in range(G.numberOfReplications): for i in range(G.numberOfReplications):
G.seed+=1 #increment the seed so that we get different random numbers in each run. G.seed+=1 #increment the seed so that we get different random numbers in each run.
initialize() #initialize the simulation (SimPy method) #initialize all the objects
#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 for objectResource in G.ObjectResourceList:
objectResource.initialize()
#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())
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:
object.postProcessing() object.postProcessing()
R.postProcessing()
for objectResource in G.ObjectResourceList:
objectResource.postProcessing()
#output data to excel for every object #output data to excel for every object
for object in G.ObjList: for object in G.ObjList:
......
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