data = Import_Excel() failures = data.Input_data(worksheet_Fail, workbook) #Create the failures dictionary with key the MTTF and MTTR data points MTTF = failures.get('MTTF',[]) MTTR = failures.get('MTTR',[]) #======================= Fit data to probability distributions ================================# #The Distributions and DistFittest objects are called to fit statistical distributions to the in scope data dist = Distributions() act2Proc = dist.Weibull_distrfit(Activity2_Proc) act3Proc = dist.Weibull_distrfit(Activity3_Proc) s1Times = dist.Exponential_distrfit(S1) distFit = DistFittest() act1MTTF = distFit.ks_test(MTTF) act1MTTR = distFit.ks_test(MTTR) #======================= Output preparation: output the updated values in the XML file of this example ================================# datafile = ('Topology1.xml') #define the input xml file tree = et.parse(datafile) simul8 = Simul8Output() #Call the Simul8Output object #Assign the statistical distribution calculated above in the XML file using methods of the Simul8Output object interTimes = simul8.InterArrivalTime(tree,'Source', s1Times) procTimes2 = simul8.ProcTimes(interTimes,'Activity 2', act2Proc) procTimes3 = simul8.ProcTimes(procTimes2,'Activity 3', act3Proc) #Again assign the MTTF and MTTR probability distributions calling the relevant methods from the Simul8Output object MTTF1 = simul8.MTBF(procTimes3,'Activity 1', act1MTTF)
worksheet_Fail, workbook ) #Create the failures dictionary with key the MTTF and MTTR data points MTTF = failures.get('MTTF', []) MTTR = failures.get('MTTR', []) #======================= Fit data to probability distributions ================================# #The Distributions and DistFittest objects are called to fit statistical distributions to the in scope data dist = Distributions() act2Proc = dist.Weibull_distrfit(Activity2_Proc) act3Proc = dist.Weibull_distrfit(Activity3_Proc) s1Times = dist.Exponential_distrfit(S1) distFit = DistFittest() act1MTTF = distFit.ks_test(MTTF) act1MTTR = distFit.ks_test(MTTR) #======================= Output preparation: output the updated values in the XML file of this example ================================# datafile = ('Topology1.xml') #define the input xml file tree = et.parse(datafile) simul8 = Simul8Output() #Call the Simul8Output object #Assign the statistical distribution calculated above in the XML file using methods of the Simul8Output object interTimes = simul8.InterArrivalTime(tree, 'Source', s1Times) procTimes2 = simul8.ProcTimes(interTimes, 'Activity 2', act2Proc) procTimes3 = simul8.ProcTimes(procTimes2, 'Activity 3', act3Proc) #Again assign the MTTF and MTTR probability distributions calling the relevant methods from the Simul8Output object MTTF1 = simul8.MTBF(procTimes3, 'Activity 1', act1MTTF)
from xml.etree import ElementTree as et from Simul8XML import Simul8Output #Read from the given directory the Excel document with the processing times data workbook = xlrd.open_workbook('ProcData.xls') worksheets = workbook.sheet_names() worksheet_Proc = worksheets[0] #Define the worksheet with the Processing time data importData = Import_Excel() #Call the Python object Import_Excel procTimes = importData.Input_data(worksheet_Proc, workbook) #Create the Processing times dictionary with key the M1 and values the processing time data #Get from the above dictionaries the M1 key and the Source key and define the following lists with data M1 = procTimes.get('M1',[]) distFitting = DistFittest() #Call the DistFittest object M1 = distFitting.ks_test(M1) #Read from the given directory the Excel document with the inter-arrivals data workbook = xlrd.open_workbook('InterarrivalsData.xls') worksheets = workbook.sheet_names() worksheet_Inter = worksheets[0] #Define the worksheet with the Inter-arrivals time data data = Import_Excel() interTimes = data.Input_data(worksheet_Inter, workbook) #Create the Inter-arrival times dictionary with key the Source and values the inter-arrival time data S1 = interTimes.get('Source',[]) distMLE = Distributions() #Call the Distributions object S1 = distMLE.Exponential_distrfit(S1) datafile=('SingleServer.xml') #define the input xml file
workbook = xlrd.open_workbook('Mockup_ProcessingTimes.xls') #Using xlrd library opens the Excel document with the input data worksheets = workbook.sheet_names() worksheet_ProcessingTimes = worksheets[0] #It defines the worksheet_ProcessingTimes as the first sheet of the Excel file A=Import_Excel() #Call the Import_Excel object B=DistFittest() #Call the Distribution Fitting object ProcessingTimes= A.Input_data(worksheet_ProcessingTimes, workbook) #Create a dictionary with the imported data from the Excel file jsonFile= open('BatchesInput.json','r') #open the json file data = json.load(jsonFile) #It loads the file jsonFile.close() nodes = data['nodes'] lista=[] for (element_id, element) in nodes.iteritems(): #This loop appends in a list the id's of the json file element['id'] = element_id lista.append(element ['id']) fittingDict={} for element in ProcessingTimes: #This loop searches the elements of the Excel imported data and if these elements exist in json file append the distribution fitting results in a dictionary if element in lista: fittingDict[element]=B.ks_test(ProcessingTimes[element]) for (element_id, element) in nodes.iteritems(): #This loop searches the ids in the json file and if the id exist in the dictionary with the distribution fitting results, replace the processing time node if element_id in fittingDict: element['processingTime']=fittingDict[element_id] jsonFile = open('BatchesOutput.json',"w") #It opens the JSON file jsonFile.write(json.dumps(data, indent=4)) #It writes the updated data to the JSON file jsonFile.close() #It closes the file
MTTR_MILL1=[] MTTR_MILL2=[] for j in range(c.rowcount): #get the next line ind3=c.fetchone() if ind3.stat_code == 'MILL1': MTTR_MILL1.append(ind3.MTTR_hour) elif ind3.stat_code == 'MILL2': MTTR_MILL2.append(ind3.MTTR_hour) else: continue #======================= Fit data to statistical distributions ================================# dist_proctime = DistFittest() distProcTime_MILL1 = dist_proctime.ks_test(procTime_MILL1) distProcTime_MILL2 = dist_proctime.ks_test(procTime_MILL2) dist_MTTF = Distributions() dist_MTTR = Distributions() distMTTF_MILL1 = dist_MTTF.Weibull_distrfit(MTTF_MILL1) distMTTF_MILL2 = dist_MTTF.Weibull_distrfit(MTTF_MILL2) distMTTR_MILL1 = dist_MTTR.Poisson_distrfit(MTTR_MILL1) distMTTR_MILL2 = dist_MTTR.Poisson_distrfit(MTTR_MILL2) #======================= Output preparation: output the updated values in the JSON file of this example ================================# jsonFile = open('JSON_example.json','r') #It opens the JSON file data = json.load(jsonFile) #It loads the file jsonFile.close() nodes = data.get('nodes',[]) #It creates a variable that holds the 'nodes' dictionary
workbook = xlrd.open_workbook('inputsTwoServers.xls') #Using xlrd library opens the Excel document with the input data worksheets = workbook.sheet_names() worksheet_OperationTime = worksheets[0] #It creates a variable that holds the first Excel worksheet X=Import_Excel() #Call the import_Excel object OperationTimes= X.Input_data(worksheet_OperationTime,workbook) #It defines a Python dictionary, giving as name OpearationTimes and as value the returned dictionary from the import_Excel object Machine1_OpearationTimes = OperationTimes.get('Machine1',[]) #Two lists are defined (Machine1_OpearationTimes, Machine2_OpearationTimes) with the operation times data of each machine Machine2_OpearationTimes = OperationTimes.get('Machine2',[]) A=HandleMissingValues() #Call the HandleMissingValues object Machine1_OpearationTimes= A.DeleteMissingValue(Machine1_OpearationTimes) #It deletes the missing values in the lists with the operation times data Machine2_OpearationTimes= A.DeleteMissingValue(Machine2_OpearationTimes) Dict={} B=DistFittest() #It calls the DistFittest object Dict['M1']=B.ks_test(Machine1_OpearationTimes) #It conducts the Kolmogorov-Smirnov test in the list with the operation times data Dict['M2']=B.ks_test(Machine2_OpearationTimes) M1=Dict.get('M1') M2=Dict.get('M2') #==================================== Output preparation: output the updated values in the CMSD information model of Topology10 ====================================================# datafile=('CMSD_TwoServers.xml') #It defines the name or the directory of the XML file that is manually written the CMSD information model tree = et.parse(datafile) #This file will be parsed using the XML.ETREE Python library M1Parameters=[] M1ParameterValue=[] for index in list(Dict['M1'].keys()): if index is not 'distributionType': M1Parameters.append(index)
minutes = int(secs / 60) unitsToProcess = round(batchSize - (minutes / meanPaA_Proc)) WIP[key].append(unitsToProcess) elif WIP[key][0] == 'PaB': secs = WIP[key][1].total_seconds() minutes = int(secs / 60) unitsToProcess = round(batchSize - (minutes / meanPaB_Proc)) WIP[key].append(unitsToProcess) except IndexError: continue # Call the DistFittest object and conduct Kolmogorov-Smirnov distribution fitting test in the processing times lists of each station D = DistFittest() dictProc = { } #Create a dictionary that holds the statistical distributions of the processing times of each station dictProc['MA'] = D.ks_test(MA_Proc) dictProc['M1A'] = D.ks_test(M1A_Proc) dictProc['M1B'] = D.ks_test(M1B_Proc) dictProc['M2A'] = D.ks_test(M2A_Proc) dictProc['M2B'] = D.ks_test(M2B_Proc) dictProc['M3A'] = D.ks_test(M3A_Proc) dictProc['M3B'] = D.ks_test(M3B_Proc) dictProc['MM'] = D.ks_test(MM_Proc) dictProc['PrA'] = D.ks_test(PrA_Proc) dictProc['PrB'] = D.ks_test(PrB_Proc) dictProc['PaA'] = D.ks_test(PaA_Proc) dictProc['PaB'] = D.ks_test(PaB_Proc) #Call the Distributions object and fit (using the Maximum Likelihood Estimation) the lists with the scrap quantity into a discrete statistical distribution, i.e. Geometric distribution D = Distributions() dictScrap = { } #Create a dictionary that holds the Geometric, which is a discrete statistical distribution of the processing times of each station
##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 data = json.load(jsonFile) #It loads the file jsonFile.close() nodes = data.get('nodes',[]) #It creates a variable that holds the 'nodes' dictionary for element in nodes: processingTime = nodes[element].get('processingTime',{}) #It creates a variable that gets the element attribute 'processingTime' MTTF_Nodes = nodes[element].get('MTTF',{}) #It creates a variable that gets the element attribute 'MTTF' MTTR_Nodes = nodes[element].get('MTTR',{}) #It creates a variable that gets the element attribute 'MTTR' if element == 'M1':
) #Create the Processing Times dictionary with key Machines 1,2 and values the processing time data ##Get from the above dictionaries the M1 key and define the following lists with data M1_ProcTime = ProcessingTimes.get('M1', []) M2_ProcTime = ProcessingTimes.get('M2', []) #Call the HandleMissingValues object and replace the missing values in the lists with the mean of the non-missing values misValues = HandleMissingValues() M1_ProcTime = misValues.ReplaceWithMean(M1_ProcTime) M2_ProcTime = misValues.ReplaceWithMean(M2_ProcTime) MLE = Distributions( ) #Call the Distributions object (Maximum Likelihood Estimation - MLE) KS = DistFittest() #Call the DistFittest object (Kolmoghorov-Smirnov test) M1ProcTime_dist = KS.ks_test(M1_ProcTime) M2ProcTime_dist = MLE.Normal_distrfit(M2_ProcTime) #======================= Output preparation: output the updated values in the JSON file of this example ================================# jsonFile = open('JSON_TwoParallelStations.json', 'r') #It opens the JSON file data = json.load(jsonFile) #It loads the file jsonFile.close() nodes = data.get('nodes', []) #It creates a variable that holds the 'nodes' dictionary for element in nodes: processingTime = nodes[element].get( 'processingTime', {} ) #It creates a variable that gets the element attribute 'processingTime' if element == 'St1':
secs = WIP[key][1].total_seconds() minutes= int(secs / 60) unitsToProcess= round(batchSize - (minutes / meanPaA_Proc)) WIP[key].append(unitsToProcess) elif WIP[key][0]=='PaB': secs = WIP[key][1].total_seconds() minutes= int(secs / 60) unitsToProcess= round(batchSize - (minutes / meanPaB_Proc)) WIP[key].append(unitsToProcess) except IndexError: continue # Call the DistFittest object and conduct Kolmogorov-Smirnov distribution fitting test in the processing times lists of each station D=DistFittest() dictProc={} #Create a dictionary that holds the statistical distributions of the processing times of each station dictProc['MA']= D.ks_test(MA_Proc) dictProc['M1A']= D.ks_test(M1A_Proc) dictProc['M1B']= D.ks_test(M1B_Proc) dictProc['M2A']= D.ks_test(M2A_Proc) dictProc['M2B']= D.ks_test(M2B_Proc) dictProc['M3A']= D.ks_test(M3A_Proc) dictProc['M3B']= D.ks_test(M3B_Proc) dictProc['MM']= D.ks_test(MM_Proc) dictProc['PrA']= D.ks_test(PrA_Proc) dictProc['PrB']= D.ks_test(PrB_Proc) dictProc['PaA']= D.ks_test(PaA_Proc) dictProc['PaB']= D.ks_test(PaB_Proc) #Call the Distributions object and fit (using the Maximum Likelihood Estimation) the lists with the scrap quantity into a discrete statistical distribution, i.e. Geometric distribution D=Distributions() dictScrap={} #Create a dictionary that holds the Geometric, which is a discrete statistical distribution of the processing times of each station dictScrap['MA']= D.Geometric_distrfit(MA_Scrap)
#Read from the given directory the Excel document with the processing times data workbook = xlrd.open_workbook('ProcData.xls') worksheets = workbook.sheet_names() worksheet_Proc = worksheets[ 0] #Define the worksheet with the Processing time data importData = Import_Excel() #Call the Python object Import_Excel procTimes = importData.Input_data( worksheet_Proc, workbook ) #Create the Processing times dictionary with key the M1 and values the processing time data #Get from the above dictionaries the M1 key and the Source key and define the following lists with data M1 = procTimes.get('M1', []) distFitting = DistFittest() #Call the DistFittest object M1 = distFitting.ks_test(M1) #Read from the given directory the Excel document with the inter-arrivals data workbook = xlrd.open_workbook('InterarrivalsData.xls') worksheets = workbook.sheet_names() worksheet_Inter = worksheets[ 0] #Define the worksheet with the Inter-arrivals time data data = Import_Excel() interTimes = data.Input_data( worksheet_Inter, workbook ) #Create the Inter-arrival times dictionary with key the Source and values the inter-arrival time data S1 = interTimes.get('Source', []) distMLE = Distributions() #Call the Distributions object
dictScrap={} dictScrap['P1']= listScrap[0] dictScrap['P2']= listScrap[1] dictScrap['P3']= listScrap[2] dictScrap['P4']= listScrap[3] dictScrap['P5']= listScrap[4] dictScrap['P6']= listScrap[5] dictScrap['P7']= listScrap[6] dictScrap['P8']= listScrap[7] dictScrap['P9']= listScrap[8] dictScrap['P10']= listScrap[9] dictScrap['P11']= listScrap[10] E= DistFittest() dictProc={} dictProc['P1']= E.ks_test(P1_Proc) dictProc['P2']= E.ks_test(P2_Proc) dictProc['P3']= E.ks_test(P3_Proc) dictProc['P4']= E.ks_test(P4_Proc) dictProc['P5']= E.ks_test(P5_Proc) dictProc['P6']= E.ks_test(P6_Proc) dictProc['P7']= E.ks_test(P7_Proc) dictProc['P8']= E.ks_test(P8_Proc) dictProc['P9']= E.ks_test(P9_Proc) dictProc['P10']= E.ks_test(P10_Proc) dictProc['P11']= E.ks_test(P11_Proc) F= Output() F.PrintDistributionFit(P2_Proc,"DistributionFittingResults_P2Proc.xls") F.PrintStatisticalMeasures(P2_Proc, "StatisticalMeasuresResults_P2Proc.xls")
inputData = Import_Excel() #Call the Python object Import_Excel ProcessingTimes = inputData.Input_data(worksheet_ProcessingTimes, workbook) #Create the Processing Times dictionary with key Machines 1,2 and values the processing time data ##Get from the above dictionaries the M1 key and define the following lists with data M1_ProcTime = ProcessingTimes.get('M1',[]) M2_ProcTime = ProcessingTimes.get('M2',[]) #Call the HandleMissingValues object and replace the missing values in the lists with the mean of the non-missing values misValues =HandleMissingValues() M1_ProcTime = misValues.ReplaceWithMean(M1_ProcTime) M2_ProcTime = misValues.ReplaceWithMean(M2_ProcTime) MLE = Distributions() #Call the Distributions object (Maximum Likelihood Estimation - MLE) KS = DistFittest() #Call the DistFittest object (Kolmoghorov-Smirnov test) M1ProcTime_dist = KS.ks_test(M1_ProcTime) M2ProcTime_dist = MLE.Normal_distrfit(M2_ProcTime) #======================= Output preparation: output the updated values in the JSON file of this example ================================# jsonFile = open('JSON_TwoParallelStations.json','r') #It opens the JSON file data = json.load(jsonFile) #It loads the file jsonFile.close() nodes = data.get('nodes',[]) #It creates a variable that holds the 'nodes' dictionary for element in nodes: processingTime = nodes[element].get('processingTime',{}) #It creates a variable that gets the element attribute 'processingTime' if element == 'St1': nodes['St1']['processingTime'] = M1ProcTime_dist #It checks using if syntax if the element is 'M1' elif element == 'St2': nodes['St2']['processingTime'] = M2ProcTime_dist #It checks using if syntax if the element is 'M2'