Commit d00beedd authored by Georgios Dagkakis's avatar Georgios Dagkakis

Examples in a cleaner way

parent adb92ea1
......@@ -14,9 +14,9 @@ E=Exit('E1','Exit')
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.ObjectInterruptionList=[F] #add all the objects in G.ObjList so that they can be easier accessed later
#add objects in lists so that they can be easier accessed later
G.ObjList=[Sp,Sf,M,A,E]
G.ObjectInterruptionList=[F]
#define predecessors and successors for the objects
Sp.defineRouting([A])
......@@ -27,20 +27,14 @@ E.defineRouting([M])
def main():
#initialize all the objects
for object in G.ObjList:
#initialize all the objects
for object in G.ObjList + G.ObjectInterruptionList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
#activate all the objects
for object in G.ObjList:
#activate all the objects
for object in G.ObjList + G.ObjectInterruptionList:
G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList:
G.env.process(objectInterruption.run())
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
G.env.run(until=G.maxSimTime) #run the simulation
......
......@@ -25,13 +25,12 @@ J1Route=[{"stationIdsList": ["Q1"]},
{"stationIdsList": ["E"],}]
#define the Jobs
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 entities
def main():
#initialize all the objects
for object in G.ObjList:
#initialize all the objects
for object in G.ObjList + G.EntityList:
object.initialize()
J.initialize()
#activate all the objects
for object in G.ObjList:
......
......@@ -30,10 +30,9 @@ J=Job('J1','Job1',route=J1Route)
G.EntityList=[J] #a list to hold all the jobs
def main():
#initialize all the objects
for object in G.ObjList:
#initialize all the objects
for object in G.ObjList + G.EntityList:
object.initialize()
J.initialize()
#activate all the objects
for object in G.ObjList:
......
......@@ -48,20 +48,14 @@ J3Route=[{"stationIdsList": ["Q1"]},
J1=Job('J1','Job1',route=J1Route, priority=1, dueDate=100)
J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90)
J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110)
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.EntityList=[J1,J2,J3] #a list to hold all the entities
def main():
#initialize all the objects
for object in G.ObjList:
for object in G.ObjList + G.EntityList:
object.initialize()
#initialize all the jobs
for job in G.JobList:
job.initialize()
#set the WIP
Globals.setWIP(G.EntityList)
......
......@@ -50,17 +50,11 @@ J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90)
J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110)
G.EntityList=[J1,J2,J3] #a list to hold all the jobs
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
def main():
#initialize all the objects
for object in G.ObjList:
for object in G.ObjList + G.EntityList:
object.initialize()
#initialize all the jobs
for job in G.JobList:
job.initialize()
#set the WIP
Globals.setWIP(G.EntityList)
......
......@@ -50,17 +50,11 @@ J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90)
J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110)
G.EntityList=[J1,J2,J3] #a list to hold all the jobs
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
def main():
#initialize all the objects
for object in G.ObjList:
for object in G.ObjList + G.EntityList:
object.initialize()
#initialize all the jobs
for job in G.JobList:
job.initialize()
#set the WIP
Globals.setWIP(G.EntityList)
......
......@@ -50,17 +50,11 @@ J2=Job('J2','Job2',route=J2Route, priority=1, dueDate=90)
J3=Job('J3','Job3',route=J3Route, priority=0, dueDate=110)
G.EntityList=[J1,J2,J3] #a list to hold all the jobs
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
def main():
#initialize all the objects
for object in G.ObjList:
for object in G.ObjList + G.EntityList:
object.initialize()
#initialize all the jobs
for job in G.JobList:
job.initialize()
#set the WIP
Globals.setWIP(G.EntityList)
......
......@@ -12,10 +12,9 @@ E=Exit('E1','Exit')
F=Failure(victim=M1, distribution={'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.ObjectInterruptionList=[F] #add all the objects in G.ObjList so that they can be easier accessed later
#add objects in lists so that they can be easier accessed later
G.ObjList=[S,Q,M1,M2,E]
G.ObjectInterruptionList=[F]
#define predecessors and successors for the objects
S.defineRouting([Q])
......@@ -27,19 +26,13 @@ E.defineRouting([M1,M2])
def main():
#initialize all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
#activate all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList:
G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList:
G.env.process(objectInterruption.run())
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
G.env.run(until=G.maxSimTime) #run the simulation
......
......@@ -23,10 +23,9 @@ E=Exit('E1','Exit')
F=Failure(victim=M1, distribution={'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.ObjectInterruptionList=[F] #add all the objects in G.ObjList so that they can be easier accessed later
#add objects in lists so that they can be easier accessed later
G.ObjList=[S,Q,M1,M2,E]
G.ObjectInterruptionList=[F]
#define predecessors and successors for the objects
S.defineRouting([Q])
......@@ -37,20 +36,14 @@ E.defineRouting([M1,M2])
def main():
#initialize all the objects
for object in G.ObjList:
#initialize all the objects
for object in G.ObjList + G.ObjectInterruptionList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
#activate all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList:
G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList:
G.env.process(objectInterruption.run())
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
G.env.run(until=G.maxSimTime) #run the simulation
......
......@@ -43,9 +43,9 @@ E=CountingExit('E1','Exit')
F=Failure(victim=M1, distribution={'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.ObjectInterruptionList=[F] #add all the objects in G.ObjList so that they can be easier accessed later
#add objects in lists so that they can be easier accessed later
G.ObjList=[S,Q,M1,M2,E]
G.ObjectInterruptionList=[F]
#create the global counter variables
G.NumM1=0
......@@ -60,20 +60,14 @@ E.defineRouting([M1,M2])
def main():
#initialize all the objects
for object in G.ObjList:
#initialize all the objects
for object in G.ObjList + G.ObjectInterruptionList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
#activate all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList:
G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList:
G.env.process(objectInterruption.run())
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
G.env.run(until=G.maxSimTime) #run the simulation
......
from dream.simulation.imports import Machine, Source, Exit, Part, G, ShiftScheduler
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
S=Source('S1','Source',interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
M=Machine('M1','Machine', processingTime={'distributionType':'Fixed','mean':1})
E=Exit('E1','Exit')
G.ObjList=[S,M,E] #add all the objects in a list so that they can be easier accessed later
#create the shift
SS=ShiftScheduler(victim=M, shiftPattern=[[0,5],[10,15]])
G.ObjectInterruptionList=[SS] #add all the interruptions in a list so that they can be easier accessed later
#define predecessors and successors for the objects
S.defineRouting(successorList=[M])
M.defineRouting(predecessorList=[S],successorList=[E])
E.defineRouting(predecessorList=[M])
def main():
#initialize all the objects
for object in G.ObjList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
#activate all the objects
for object in G.ObjList:
G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList:
G.env.process(objectInterruption.run())
G.maxSimTime=20 #set G.maxSimTime 1440.0 minutes (1 day)
G.env.run(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, "parts"
working_ratio = (M.totalWorkingTime/G.maxSimTime)*100
off_shift_ratio=(M.totalOffShiftTime/G.maxSimTime)*100
print "the total working ratio of the Machine is", working_ratio, "%"
print "the total off-shift ratio of the Machine is", off_shift_ratio, "%"
return {"parts": E.numOfExits,
"working_ratio": working_ratio}
if __name__ == '__main__':
main()
\ No newline at end of file
......@@ -16,10 +16,10 @@ E=Exit('E1','Exit')
F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR':5}, 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.MachineList=[M1,M2]
#add objects in lists so that they can be easier accessed later
G.ObjList=[S,M1,M2,E,Q]
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]
#define predecessors and successors for the objects
S.defineRouting([M1])
......@@ -31,32 +31,20 @@ E.defineRouting([M2])
def main():
#initialize all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList + G.ObjectResourceList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
for objectResource in G.ObjectResourceList:
objectResource.initialize()
#activate all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList:
G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList:
G.env.process(objectInterruption.run())
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
G.env.run(until=G.maxSimTime) #run the simulation
#carry on the post processing operations for every object in the topology
for object in G.ObjList:
for object in G.ObjList + G.ObjectResourceList:
object.postProcessing()
for objectResource in G.ObjectResourceList:
objectResource.postProcessing()
#print the results
print "the system produced", E.numOfExits, "parts"
......
......@@ -19,10 +19,10 @@ E=Exit('E1','Exit')
F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR':5}, 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.MachineList=[M1,M2]
#add objects in lists so that they can be easier accessed later
G.ObjList=[S,M1,M2,E,Q]
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]
#define predecessors and successors for the objects
S.defineRouting([M1])
......@@ -35,32 +35,20 @@ E.defineRouting([M2])
def main():
#initialize all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList + G.ObjectResourceList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
for objectResource in G.ObjectResourceList:
objectResource.initialize()
#activate all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList:
G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList:
G.env.process(objectInterruption.run())
G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
G.env.run(until=G.maxSimTime) #run the simulation
#carry on the post processing operations for every object in the topology
for object in G.ObjList:
for object in G.ObjList + G.ObjectResourceList:
object.postProcessing()
for objectResource in G.ObjectResourceList:
objectResource.postProcessing()
#print the results
print "the system produced", E.numOfExits, "parts"
......
......@@ -13,9 +13,10 @@ E=Exit('E1','Exit')
F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR':5}, 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
#add objects in lists so that they can be easier accessed later
G.ObjList=[S,M1,M2,E,Q]
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]
#define predecessors and successors for the objects
S.defineRouting([M1])
......@@ -39,32 +40,20 @@ def main():
# this is where all the simulation object 'live'
#initialize all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList + G.ObjectResourceList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
for objectResource in G.ObjectResourceList:
objectResource.initialize()
#activate all the objects
for object in G.ObjList:
for object in G.ObjList + G.ObjectInterruptionList:
G.env.process(object.run())
for objectInterruption in G.ObjectInterruptionList:
G.env.process(objectInterruption.run())
G.env.run(until=G.maxSimTime) #run the simulation
#carry on the post processing operations for every object in the topology
for object in G.ObjList:
for object in G.ObjList + G.ObjectResourceList:
object.postProcessing()
for objectResource in G.ObjectResourceList:
objectResource.postProcessing()
# append the numbe of exits in the throughputList
# append the number of exits in the throughputList
throughputList.append(E.numOfExits)
print 'The exit of each replication is:'
......
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