Commit 94b3db2d authored by Jérome Perrin's avatar Jérome Perrin

simplify some outputResultJSON

parent d71a5c7e
...@@ -350,50 +350,37 @@ class Conveyer(CoreObject): ...@@ -350,50 +350,37 @@ class Conveyer(CoreObject):
#outputs results to JSON File #outputs results to JSON File
def outputResultsJSON(self): def outputResultsJSON(self):
from Globals import G from Globals import G
json={}
json['_class'] = 'Dream.Conveyer';
json['id'] = str(self.id)
json['results'] = {}
if(G.numberOfReplications==1): #if we had just one replication output the results to excel if(G.numberOfReplications==1): #if we had just one replication output the results to excel
json={}
json['_class'] = 'Dream.Conveyer';
json['id'] = str(self.id)
json['results'] = {}
json['results']['working_ratio']=100*self.totalWorkingTime/G.maxSimTime json['results']['working_ratio']=100*self.totalWorkingTime/G.maxSimTime
json['results']['blockage_ratio']=100*self.totalBlockageTime/G.maxSimTime json['results']['blockage_ratio']=100*self.totalBlockageTime/G.maxSimTime
json['results']['waiting_ratio']=100*self.totalWaitingTime/G.maxSimTime json['results']['waiting_ratio']=100*self.totalWaitingTime/G.maxSimTime
else: #if we had multiple replications we output confidence intervals to excel 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 #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 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 #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 #if yes we output the Confidence Intervals. if not we output just the fix value
json={} for ratio, measureList in (
json['_class'] = 'Dream.Conveyer'; ('failure_ratio', self.Failure),
json['id'] = str(self.id) ('working_ratio', self.Working),
json['results'] = {} ('blockage_ratio', self.Blockage),
json['results']['working_ratio']={} ('waiting_ratio', self.Waiting), ):
if self.checkIfArrayHasDifValues(self.Working): json['results'][ratio] = {}
json['results']['working_ratio']['min']=stat.bayes_mvs(self.Working, G.confidenceLevel)[0][1][0] if self.checkIfArrayHasDifValues(measureList):
json['results']['working_ratio']['avg']=stat.bayes_mvs(self.Working, G.confidenceLevel)[0][0] json['results'][ratio]['min'] = stat.bayes_mvs(
json['results']['working_ratio']['max']=stat.bayes_mvs(self.Working, G.confidenceLevel)[0][1][1] measureList, G.confidenceLevel)[0][1][0]
else: json['results'][ratio]['avg'] = stat.bayes_mvs(
json['results']['working_ratio']['min']=self.Working[0] measureList, G.confidenceLevel)[0][0]
json['results']['working_ratio']['avg']=self.Working[0] json['results'][ratio]['max'] = stat.bayes_mvs(
json['results']['working_ratio']['max']=self.Working[0] measureList, G.confidenceLevel)[0][1][1]
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: else:
json['results']['waiting_ratio']['min']=self.Waiting[0] json['results'][ratio]['min'] = \
json['results']['waiting_ratio']['avg']=self.Waiting[0] json['results'][ratio]['avg'] = \
json['results']['waiting_ratio']['max']=self.Waiting[0] json['results'][ratio]['max'] = measureList[0]
G.outputJSON['elementList'].append(json) G.outputJSON['elementList'].append(json)
#Process that handles the moves of the conveyer #Process that handles the moves of the conveyer
......
...@@ -865,51 +865,25 @@ class Machine(CoreObject): ...@@ -865,51 +865,25 @@ class Machine(CoreObject):
json['_class'] = 'Dream.Machine'; json['_class'] = 'Dream.Machine';
json['id'] = str(self.id) json['id'] = str(self.id)
json['results'] = {} json['results'] = {}
json['results']['failure_ratio']={}
if self.checkIfArrayHasDifValues(self.Failure): for ratio, measureList in (
json['results']['failure_ratio']['min']=stat.bayes_mvs(self.Failure, G.confidenceLevel)[0][1][0] ('failure_ratio', self.Failure),
json['results']['failure_ratio']['avg']=stat.bayes_mvs(self.Failure, G.confidenceLevel)[0][0] ('working_ratio', self.Working),
json['results']['failure_ratio']['max']=stat.bayes_mvs(self.Failure, G.confidenceLevel)[0][1][1] ('blockage_ratio', self.Blockage),
else: ('waiting_ratio', self.Waiting),
json['results']['failure_ratio']['min']=self.Failure[0] ('off_shift_ratio', self.OffShift), ):
json['results']['failure_ratio']['avg']=self.Failure[0] json['results'][ratio] = {}
json['results']['failure_ratio']['max']=self.Failure[0] if self.checkIfArrayHasDifValues(measureList):
json['results']['working_ratio']={} json['results'][ratio]['min'] = stat.bayes_mvs(
if self.checkIfArrayHasDifValues(self.Working): measureList, G.confidenceLevel)[0][1][0]
json['results']['working_ratio']['min']=stat.bayes_mvs(self.Working, G.confidenceLevel)[0][1][0] json['results'][ratio]['avg'] = stat.bayes_mvs(
json['results']['working_ratio']['avg']=stat.bayes_mvs(self.Working, G.confidenceLevel)[0][0] measureList, G.confidenceLevel)[0][0]
json['results']['working_ratio']['max']=stat.bayes_mvs(self.Working, G.confidenceLevel)[0][1][1] json['results'][ratio]['max'] = stat.bayes_mvs(
else: measureList, G.confidenceLevel)[0][1][1]
json['results']['working_ratio']['min']=self.Working[0] else:
json['results']['working_ratio']['avg']=self.Working[0] json['results'][ratio]['min'] = \
json['results']['working_ratio']['max']=self.Working[0] json['results'][ratio]['avg'] = \
json['results']['blockage_ratio']={} json['results'][ratio]['max'] = measureList[0]
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]
json['results']['off_shifts_ratio']={}
if self.checkIfArrayHasDifValues(self.OffShift):
json['results']['off_shifts_ratio']['min']=stat.bayes_mvs(self.OffShift, G.confidenceLevel)[0][1][0]
json['results']['off_shifts_ratio']['avg']=stat.bayes_mvs(self.OffShift, G.confidenceLevel)[0][0]
json['results']['off_shifts_ratio']['max']=stat.bayes_mvs(self.OffShift, G.confidenceLevel)[0][1][1]
else:
json['results']['off_shifts_ratio']['min']=self.OffShift[0]
json['results']['off_shifts_ratio']['avg']=self.OffShift[0]
json['results']['off_shifts_ratio']['max']=self.OffShift[0]
G.outputJSON['elementList'].append(json) G.outputJSON['elementList'].append(json)
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