Commit 82ae41c1 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

Machine and Exit updated so that they output in JSON also confidence...

Machine and Exit updated so that they output in JSON also confidence intervals. Got to check with Nex the notation
parent c3edd94b
......@@ -195,6 +195,42 @@ class Exit(Process):
json['results']['throughput']=self.numOfExits
json['results']['lifespan']=((self.totalLifespan)/self.numOfExits)/G.Base
json['results']['takt_time']=((self.totalTaktTime)/self.numOfExits)/G.Base
else: #if we had multiple replications we output confidence intervals to excel
#for some outputs the results may be the same for each run (eg model is stochastic but failures fixed
#so failurePortion will be exactly the same in each run). That will give 0 variability and errors.
#so for each output value we check if there was difference in the runs' results
#if yes we output the Confidence Intervals. if not we output just the fix value
json={}
json['_class'] = 'Dream.Exit';
json['id'] = str(self.id)
json['results'] = {}
json['results']['throughput']={}
if self.checkIfArrayHasDifValues(self.Exits):
json['results']['throughput']['min']=stat.bayes_mvs(self.Exits, G.confidenceLevel)[0][1][0]
json['results']['throughput']['avg']=stat.bayes_mvs(self.Exits, G.confidenceLevel)[0][0]
json['results']['throughput']['max']=stat.bayes_mvs(self.Exits, G.confidenceLevel)[0][1][1]
else:
json['results']['throughput']['min']=self.Exits[0]
json['results']['throughput']['avg']=self.Exits[0]
json['results']['throughput']['max']=self.Exits[0]
json['results']['lifespan']={}
if self.checkIfArrayHasDifValues(self.Lifespan):
json['results']['lifespan']['min']=stat.bayes_mvs(self.Lifespan, G.confidenceLevel)[0][1][0]
json['results']['lifespan']['avg']=stat.bayes_mvs(self.Lifespan, G.confidenceLevel)[0][0]
json['results']['lifespan']['max']=stat.bayes_mvs(self.Lifespan, G.confidenceLevel)[0][1][1]
else:
json['results']['lifespan']['min']=self.Lifespan[0]
json['results']['lifespan']['avg']=self.Lifespan[0]
json['results']['lifespan']['max']=self.Lifespan[0]
json['results']['taktTime']={}
if self.checkIfArrayHasDifValues(self.TaktTime):
json['results']['taktTime']['min']=stat.bayes_mvs(self.TaktTime, G.confidenceLevel)[0][1][0]
json['results']['taktTime']['avg']=stat.bayes_mvs(self.TaktTime, G.confidenceLevel)[0][0]
json['results']['taktTime']['max']=stat.bayes_mvs(self.TaktTime, G.confidenceLevel)[0][1][1]
else:
json['results']['taktTime']['min']=self.TaktTime[0]
json['results']['taktTime']['avg']=self.TaktTime[0]
json['results']['taktTime']['max']=self.TaktTime[0]
G.outputJSON['coreObject'].append(json)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
......
{"_class": "Dream.Simulation",
"general": {
"_class": "Dream.Configuration",
"numberOfReplications": "1",
"numberOfReplications": "10",
"maxSimTime": "1440",
"trace": "Yes",
"confidenceLevel": "0.95"
......@@ -19,7 +19,7 @@
"name": "Raw Material",
"interarrivalTime":
{
"distributionType": "Fixed",
"distributionType": "Exp",
"mean": "0.5"
},
"entity": "Part",
......@@ -29,8 +29,11 @@
"id": "M1",
"name": "Machine1",
"processingTime": {
"distributionType": "Fixed",
"mean": "0.25"
"distributionType": "Normal",
"mean": "0.25",
"stdev": "0.1",
"min": "0.1",
"max": "1"
},
"failures":{
"failureDistribution": "Fixed",
......
......@@ -89,7 +89,7 @@ def createObjects():
mean=float(processingTime.get('mean', '0'))
stdev=float(processingTime.get('stdev', '0'))
min=float(processingTime.get('min', '0'))
max=float(processingTime.get('stdev', '0'))
max=float(processingTime.get('max', '0'))
failures=core_object.get('failures', 'not found')
failureDistribution=failures.get('failureDistribution', 'not found')
MTTF=float(failures.get('MTTF', '0'))
......
......@@ -432,8 +432,55 @@ class Machine(Process):
json['results']['working_ratio']=100*self.totalWorkingTime/G.maxSimTime
json['results']['blockage_ratio']=100*self.totalBlockageTime/G.maxSimTime
json['results']['waiting_ratio']=100*self.totalWaitingTime/G.maxSimTime
else: #if we had multiple replications we output confidence intervals to excel
#for some outputs the results may be the same for each run (eg model is stochastic but failures fixed
#so failurePortion will be exactly the same in each run). That will give 0 variability and errors.
#so for each output value we check if there was difference in the runs' results
#if yes we output the Confidence Intervals. if not we output just the fix value
json={}
json['_class'] = 'Dream.Machine';
json['id'] = str(self.id)
json['results'] = {}
json['results']['failure_ratio']={}
if self.checkIfArrayHasDifValues(self.Failure):
json['results']['failure_ratio']['min']=stat.bayes_mvs(self.Failure, G.confidenceLevel)[0][1][0]
json['results']['failure_ratio']['avg']=stat.bayes_mvs(self.Failure, G.confidenceLevel)[0][0]
json['results']['failure_ratio']['max']=stat.bayes_mvs(self.Failure, G.confidenceLevel)[0][1][1]
else:
json['results']['failure_ratio']['min']=self.Failure[0]
json['results']['failure_ratio']['avg']=self.Failure[0]
json['results']['failure_ratio']['max']=self.Failure[0]
json['results']['working_ratio']={}
if self.checkIfArrayHasDifValues(self.Working):
json['results']['working_ratio']['min']=stat.bayes_mvs(self.Working, G.confidenceLevel)[0][1][0]
json['results']['working_ratio']['avg']=stat.bayes_mvs(self.Working, G.confidenceLevel)[0][0]
json['results']['working_ratio']['max']=stat.bayes_mvs(self.Working, G.confidenceLevel)[0][1][1]
else:
json['results']['working_ratio']['min']=self.Working[0]
json['results']['working_ratio']['avg']=self.Working[0]
json['results']['working_ratio']['max']=self.Working[0]
json['results']['blockage_ratio']={}
if self.checkIfArrayHasDifValues(self.Blockage):
json['results']['blockage_ratio']['min']=stat.bayes_mvs(self.Blockage, G.confidenceLevel)[0][1][0]
json['results']['blockage_ratio']['avg']=stat.bayes_mvs(self.Blockage, G.confidenceLevel)[0][0]
json['results']['blockage_ratio']['max']=stat.bayes_mvs(self.Blockage, G.confidenceLevel)[0][1][1]
else:
json['results']['blockage_ratio']['min']=self.Blockage[0]
json['results']['blockage_ratio']['avg']=self.Blockage[0]
json['results']['blockage_ratio']['max']=self.Blockage[0]
json['results']['waiting_ratio']={}
if self.checkIfArrayHasDifValues(self.Waiting):
json['results']['waiting_ratio']['min']=stat.bayes_mvs(self.Waiting, G.confidenceLevel)[0][1][0]
json['results']['waiting_ratio']['avg']=stat.bayes_mvs(self.Waiting, G.confidenceLevel)[0][0]
json['results']['waiting_ratio']['max']=stat.bayes_mvs(self.Waiting, G.confidenceLevel)[0][1][1]
else:
json['results']['waiting_ratio']['min']=self.Waiting[0]
json['results']['waiting_ratio']['avg']=self.Waiting[0]
json['results']['waiting_ratio']['max']=self.Waiting[0]
G.outputJSON['coreObject'].append(json)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def checkIfArrayHasDifValues(self, array):
......
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