@@ -31,62 +31,83 @@ from dream.KnowledgeExtraction.JSONOutput import JSONOutput
importdream.simulation.LineGenerationJSONasManPyMain#import ManPy main JSON script
importxlrd
importjson
importos
#Read from the given directory the Excel document with the input data
workbook=xlrd.open_workbook('inputData.xls')
worksheets=workbook.sheet_names()
worksheet_ProcessingTimes=worksheets[0]#Define the worksheet with the Processing times data
worksheet_MTTF=worksheets[1]#Define the worksheet with Time-to-Failure data
worksheet_MTTR=worksheets[2]#Define the worksheet with Time-to-Repair data
A=Import_Excel()#Call the Python object Import_Excel
ProcessingTimes=A.Input_data(worksheet_ProcessingTimes,workbook)#Create the Processing Times dictionary with key the Machine 1 and values the processing time data
MTTF=A.Input_data(worksheet_MTTF,workbook)#Create the MTTF dictionary with key the Machine 1 and time-to-failure data
MTTR=A.Input_data(worksheet_MTTR,workbook)#Create the MTTR Quantity dictionary with key the Machine 1 and time-to-repair data
##Get from the above dictionaries the M1 key and define the following lists with data
ProcTime=ProcessingTimes.get('M1',[])
MTTF=MTTF.get('M1',[])
MTTR=MTTR.get('M1',[])
#Call the HandleMissingValues object and replace the missing values in the lists with the mean of the non-missing values
B=HandleMissingValues()
ProcTime=B.ReplaceWithMean(ProcTime)
MTTF=B.ReplaceWithMean(MTTF)
MTTR=B.ReplaceWithMean(MTTR)
C=Distributions()#Call the Distributions object
D=DistFittest()#Call the DistFittest object
ProcTime_dist=D.ks_test(ProcTime)
MTTF_dist=C.Exponential_distrfit(MTTF)
MTTR_dist=C.Exponential_distrfit(MTTR)
#================================= Output preparation: output the updated values in the JSON file of this example =========================================================#
jsonFile=open('JSON_AssembleDismantle.json','r')#It opens the JSON file
#Read from the given directory the Excel document with the input data
worksheets=workbook.sheet_names()
worksheet_ProcessingTimes=worksheets[0]#Define the worksheet with the Processing times data
worksheet_MTTF=worksheets[1]#Define the worksheet with Time-to-Failure data
worksheet_MTTR=worksheets[2]#Define the worksheet with Time-to-Repair data
jsonFile=open('JSON_AssembleDismantle_Output.json',"w")#It opens the JSON file
jsonFile.write(json.dumps(data2,indent=True))#It writes the updated data to the JSON file
jsonFile.close()#It closes the file
#================================ Calling the ExcelOutput object, outputs the outcomes of the statistical analysis in xls files =============================================#
jsonFile=open('ManPyOutput.json',"w")#It opens the JSON file
jsonFile.write(simulationOutput)#It writes the updated data to the JSON file
jsonFile.close()#It closes the file
\ No newline at end of file
A=Import_Excel()#Call the Python object Import_Excel
ProcessingTimes=A.Input_data(worksheet_ProcessingTimes,workbook)#Create the Processing Times dictionary with key the Machine 1 and values the processing time data
MTTF=A.Input_data(worksheet_MTTF,workbook)#Create the MTTF dictionary with key the Machine 1 and time-to-failure data
MTTR=A.Input_data(worksheet_MTTR,workbook)#Create the MTTR Quantity dictionary with key the Machine 1 and time-to-repair data
##Get from the above dictionaries the M1 key and define the following lists with data
ProcTime=ProcessingTimes.get('M1',[])
MTTF=MTTF.get('M1',[])
MTTR=MTTR.get('M1',[])
#Call the HandleMissingValues object and replace the missing values in the lists with the mean of the non-missing values
B=HandleMissingValues()
ProcTime=B.ReplaceWithMean(ProcTime)
MTTF=B.ReplaceWithMean(MTTF)
MTTR=B.ReplaceWithMean(MTTR)
C=Distributions()#Call the Distributions object
D=DistFittest()#Call the DistFittest object
ProcTime_dist=D.ks_test(ProcTime)
MTTF_dist=C.Exponential_distrfit(MTTF)
MTTR_dist=C.Exponential_distrfit(MTTR)
#================================= Output preparation: output the updated values in the JSON file of this example =========================================================#
ifnotjsonFile:
jsonFile=open(os.path.join(os.path.dirname(os.path.realpath(__file__)),JSONFileName),'r')#It opens the JSON file
#===================== Output the JSON file ========================================#
jsonFile=open('JSON_AssembleDismantle_Output.json',"w")#It opens the JSON file
jsonFile.write(json.dumps(data2,indent=True))#It writes the updated data to the JSON file
jsonFile.close()#It closes the file
#================================ Calling the ExcelOutput object, outputs the outcomes of the statistical analysis in xls files =============================================#