Commit 618b8084 authored by Georgios Dagkakis's avatar Georgios Dagkakis

TwoServersStochastic example updated to match the new notation. Also in the documentation

parent 99719b39
No preview for this file type
No preview for this file type
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 simpy 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')
S=Source('S1','Source', interarrivalTime={'distributionType':'Exp','mean':0.5}, entity='Dream.Part') S=Source('S1','Source', interarrivalTime={'distributionType':'Exp','mean':0.5}, entity='Dream.Part')
...@@ -31,40 +28,57 @@ G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day) ...@@ -31,40 +28,57 @@ G.maxSimTime=1440.0 #set G.maxSimTime 1440.0 minutes (1 day)
G.numberOfReplications=10 #set 10 replications G.numberOfReplications=10 #set 10 replications
G.confidenceLevel=0.99 #set the confidence level. 0.99=99% G.confidenceLevel=0.99 #set the confidence level. 0.99=99%
#run the replications def main():
for i in range(G.numberOfReplications): throughputList=[] # a list to hold the throughput of each replication
G.seed+=1 #increment the seed so that we get different random numbers in each run.
#initialize all the objects
for object in G.ObjList:
object.initialize()
for objectInterruption in G.ObjectInterruptionList: #run the replications
objectInterruption.initialize() for i in range(G.numberOfReplications):
G.seed+=1 #increment the seed so that we get different random numbers in each run.
for objectResource in G.ObjectResourceList: G.env=simpy.Environment() # define a simpy environment
objectResource.initialize() # this is where all the simulation object 'live'
#activate all the objects #initialize all the objects
for object in G.ObjList: for object in G.ObjList:
G.env.process(object.run()) object.initialize()
for objectInterruption in G.ObjectInterruptionList:
G.env.process(objectInterruption.run())
G.env.run(until=G.maxSimTime) #run the simulation for objectInterruption in G.ObjectInterruptionList:
objectInterruption.initialize()
#carry on the post processing operations for every object in the topology
for object in G.ObjList: for objectResource in G.ObjectResourceList:
object.postProcessing() objectResource.initialize()
for objectResource in G.ObjectResourceList: #activate all the objects
objectResource.postProcessing() for object in G.ObjList:
G.env.process(object.run())
#output data to excel for every object
for object in G.ObjList: for objectInterruption in G.ObjectInterruptionList:
object.outputResultsXL() G.env.process(objectInterruption.run())
R.outputResultsXL()
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:
object.postProcessing()
for objectResource in G.ObjectResourceList:
objectResource.postProcessing()
G.outputFile.save("output.xls") # append the numbe of exits in the throughputList
throughputList.append(E.numOfExits)
print 'The exit of each replication is:'
print throughputList
# calculate confidence interval using the Knowledge Extraction tool
from dream.KnowledgeExtraction.ConfidenceIntervals import Intervals
from dream.KnowledgeExtraction.StatisticalMeasures import BasicStatisticalMeasures
BSM=BasicStatisticalMeasures()
lb, ub = Intervals().ConfidIntervals(throughputList, 0.95)
print 'the 95% confidence interval for the throughput is:'
print 'lower bound:', lb
print 'mean:', BSM.mean(throughputList)
print 'upper bound:', ub
if __name__ == '__main__':
main()
\ No newline at end of file
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