예제 #1
0
 def checkTopology(self, filename=None):
   file_path = os.path.join(project_path, "dream", "simulation",
                            "JSONInputs", filename)
   input_file = open(file_path, "r")
   input_data = input_file.read()
   input_file.close()
   result = LineGenerationJSON.main(input_data=input_data)
   result_data = json.loads(result)
   # Slightly change the output to make it stable
   del result_data["general"]["totalExecutionTime"]
   result_data["elementList"].sort(key=lambda x: x["id"])
   stable_result = json.dumps(result_data, indent=True, sort_keys=True)
   dump_path = os.path.join(self.dump_folder_path, "%s.result" % filename)
   if bool(os.environ.get("dump", False)):
     dump_file = open(dump_path, 'w')
     dump_file.write(stable_result)
     dump_file.close()
   dump_file = open(dump_path, "r")
   dump_result = json.dumps(json.loads(dump_file.read()), indent=True, sort_keys=True)
   dump_file.close()
   self.assertEquals(stable_result, dump_result, "outputs are different")
예제 #2
0
 def checkTopology(self, filename=None):
   file_path = os.path.join(project_path, "dream", "simulation",
                            "JSONInputs", filename)
   input_file = open(file_path, "r")
   input_data = input_file.read()
   input_file.close()
   result = LineGenerationJSON.main(input_data=input_data)
   result_data = json.loads(result)
   # Slightly change the output to make it stable
   del result_data['result']['result_list'][0]["general"]["totalExecutionTime"]
   result_data['result']['result_list'][0]["elementList"].sort(key=lambda x: x["id"])
   stable_result = json.dumps(result_data['result']['result_list'][0], indent=True, sort_keys=True)
   dump_path = os.path.join(self.dump_folder_path, "%s.result" % filename)
   if bool(os.environ.get("dump", False)):
     dump_file = open(dump_path, 'w')
     dump_file.write(stable_result)
     dump_file.close()
   dump_file = open(dump_path, "r")
   dump_result = json.dumps(json.loads(dump_file.read()), indent=True, sort_keys=True)
   dump_file.close()
   self.assertEquals(stable_result, dump_result, "outputs are different")
def main(test=0,
         ExcelFileName='inputData.xls',
         JSONFileName='JSON_AssembleDismantle.json',
         CMSDFileName='CMSD_AssemblyDismantle.xml',
         workbook=None,
         jsonFile=None,
         cmsdFile=None):
    if not workbook:
        workbook = xlrd.open_workbook(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         ExcelFileName))
    #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

    A = ImportExceldata()  #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 = ReplaceMissingValues()
    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 values prepared in the CMSD information model of this model ====================================================#
    if not cmsdFile:
        datafile = (
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         CMSDFileName)
        )  #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

    exportCMSD = CMSDOutput()
    stationId1 = 'M1'

    procTime = exportCMSD.ProcessingTimes(tree, stationId1, ProcTime_dist)
    TTF = exportCMSD.TTF(procTime, stationId1, MTTF_dist)
    TTR = exportCMSD.TTR(TTF, stationId1, MTTR_dist)

    TTR.write(
        'CMSD_AssemblyDismantle_Output.xml', encoding="utf8"
    )  #It writes the element tree to a specified file, using the 'utf8' output encoding

    #================================= Output preparation: output the updated values in the JSON file of this example =========================================================#
    if not jsonFile:
        jsonFile = open(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         JSONFileName), 'r')  #It opens the JSON file
        data = json.load(jsonFile)  #It loads the file
        jsonFile.close()
    else:
        data = json.load(jsonFile)

    exportJSON = JSONOutput()
    stationId = 'M1'

    data = exportJSON.ProcessingTimes(data, stationId, ProcTime_dist)
    data1 = exportJSON.TTF(data, stationId, MTTF_dist)
    data2 = exportJSON.TTR(data1, stationId, MTTR_dist)

    #================================ Call ManPy and run the simulation model =============================================#
    #calls ManPy main script with the input
    simulationOutput = ManPyMain.main(input_data=json.dumps(data2))
    # if we run from test return the ManPy result
    if test:
        return simulationOutput

    #===================== 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 =============================================#
    C = ExcelOutput()
    C.PrintStatisticalMeasures(ProcTime, 'ProcTime_StatResults.xls')
    C.PrintStatisticalMeasures(MTTR, 'MTTR_StatResults.xls')
    C.PrintStatisticalMeasures(MTTF, 'MTTF_StatResults.xls')
    C.PrintDistributionFit(ProcTime, 'ProcTime_DistFitResults.xls')
    C.PrintDistributionFit(MTTR, 'MTTR_DistFitResults.xls')

    #================================ Call ManPy and run the simulation model =============================================#
    #calls ManPy main script with the input
    simulationOutput = ManPyMain.main(input_data=json.dumps(data))
    # save the simulation output
    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
예제 #4
0
def main(test=0, ExcelFileName='inputsTwoServers.xls',
                JSONFileName='JSON_TwoServers.json',
                CMSDFileName='CMSD_TwoServers.xml',
                workbook=None,
                jsonFile=None, cmsdFile=None):
    if not workbook:
        workbook = xlrd.open_workbook(os.path.join(os.path.dirname(os.path.realpath(__file__)), ExcelFileName))      #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=ImportExceldata()                                    #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=ReplaceMissingValues()                                     #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 ====================================================#
    if not cmsdFile:
        datafile=(os.path.join(os.path.dirname(os.path.realpath(__file__)), CMSDFileName))       #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
    
    exportCMSD=CMSDOutput()
    stationId1='A020'
    stationId2='A040'
    procTime1=exportCMSD.ProcessingTimes(tree, stationId1, M1) 
    procTime2=exportCMSD.ProcessingTimes(procTime1, stationId2, M2)
    
    procTime2.write('CMSD_TwoServers_Output.xml',encoding="utf8")                         #It writes the element tree to a specified file, using the 'utf8' output encoding
    #================================= Output preparation: output the updated values in the JSON file of Topology10 =========================================================#
    if not jsonFile:
        jsonFile = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), JSONFileName),'r')      #It opens the JSON file 
        data = json.load(jsonFile)             #It loads the file
        jsonFile.close()
    else:
        data = json.load(jsonFile) 
    
    exportJSON=JSONOutput()
    stationId1='M1'
    stationId2='M2'
    data=exportJSON.ProcessingTimes(data, stationId1, M1)                           
    data1=exportJSON.ProcessingTimes(data, stationId2, M2)         
    
    #================================ Call ManPy and run the simulation model =============================================#
    #calls ManPy main script with the input
    simulationOutput=ManPyMain.main(input_data=json.dumps(data1))
    
    # if we run from test return the ManPy result
    if test:
        return simulationOutput
    
    #=================== Ouput the JSON file ==========================#
    jsonFile = open('JSON_TwoServers_Output.json',"w")     #It opens the JSON file
    jsonFile.write(json.dumps(data1, 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 Excel files =============================================#
    C=ExcelOutput()
    C.PrintDistributionFit(Machine1_OpearationTimes,'Machine1_DistFitResults.xls')   
    C.PrintStatisticalMeasures(Machine1_OpearationTimes,'Machine1_StatResults.xls')
    C.PrintDistributionFit(Machine2_OpearationTimes,'Machine2_DistFitResults.xls')   
    C.PrintStatisticalMeasures(Machine2_OpearationTimes,'Machine2_StatResults.xls')
    
    #================================ Call ManPy and run the simulation model =============================================#
    #calls ManPy main script with the input
    simulationOutput=ManPyMain.main(input_data=json.dumps(data))
    # save the simulation output
    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
예제 #5
0
E=Distributions()      #Call the DistFittest object

dictProc={}
dictProc['P1']= E.Normal_distrfit(P1_Proc)
dictProc['P2']= E.Normal_distrfit(P2_Proc)
dictProc['P3']= E.Normal_distrfit(P3_Proc)
dictProc['P4']= E.Normal_distrfit(P1_Proc)
dictProc['P5']= E.Normal_distrfit(P2_Proc)
dictProc['P6']= E.Normal_distrfit(P3_Proc)
dictProc['P7']= E.Normal_distrfit(P7_Proc)
dictProc['P8']= E.Normal_distrfit(P8_Proc)
dictProc['P9']= E.Normal_distrfit(P8_Proc)
dictProc['P10']= E.Normal_distrfit(P9_Proc)
dictProc['P11']= E.Normal_distrfit(P9_Proc)


D=Output()
D.PrintDistributionFit(P2_Proc,"DistributionFittingResults_P2Proc.xls")
D.PrintStatisticalMeasures(P2_Proc, "StatisticalMeasuresResults_P2Proc.xls")

CMSD_example(dictProc,dictScrap)    #Print the CMSD document, calling the CMSD_example method with arguments the dictProc and dictScrap dictionaries
JSON_example(dictProc,dictScrap)    #Print the JSON file, calling the JSON_example method


#calls ManPy main script with the input

simulationOutput=ManPyMain.main(input_data=str((JSON_example(dictProc,dictScrap))))
# save the simulation output
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
예제 #6
0
def main(test=0,
         ExcelFileName='inputData.xls',
         JSONFileName='JSON_ParallelStations.json',
         workbook=None,
         jsonFile=None):

    #Read from the given directory the Excel document with the input data
    if not workbook:
        workbook = xlrd.open_workbook(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         ExcelFileName))
    worksheets = workbook.sheet_names()
    worksheet_ProcessingTimes = worksheets[
        0]  #Define the worksheet with the Processing times data

    inputData = ImportExceldata()  #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 = ReplaceMissingValues()
    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 ================================#
    if not jsonFile:
        jsonFile = open(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         JSONFileName), 'r')  #It opens the JSON file
        data = json.load(jsonFile)  #It loads the file
        jsonFile.close()
    else:
        data = json.load(jsonFile)

    exportJSON = JSONOutput()
    stationId1 = 'St1'
    stationId2 = 'St2'
    data1 = exportJSON.ProcessingTimes(data, stationId1, M1ProcTime_dist)
    data2 = exportJSON.ProcessingTimes(data1, stationId2, M2ProcTime_dist)

    #================================ Call ManPy and run the simulation model =============================================#
    #calls ManPy main script with the input
    simulationOutput = ManPyMain.main(input_data=json.dumps(data2))

    # if we run from test return the ManPy result
    if test:
        return simulationOutput

    #=================== Ouput the JSON file ==========================#
    jsonFile = open('JSON_ParallelStations_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 ==========================#
    export = ExcelOutput()

    export.PrintStatisticalMeasures(M1_ProcTime, 'M1_ProcTime_StatResults.xls')
    export.PrintStatisticalMeasures(M2_ProcTime, 'M2_ProcTime_StatResults.xls')

    export.PrintDistributionFit(M1_ProcTime, 'M1_ProcTime_DistFitResults.xls')
    export.PrintDistributionFit(M2_ProcTime, 'M2_ProcTime_DistFitResults.xls')

    # save the simulation output
    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
    )  #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'

    jsonFile = open('JSON_ParallelStations_Output.json',
                    "w")  #It opens the JSON file
    jsonFile.write(json.dumps(
        data, 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 ==========================#
export = Output()

export.PrintStatisticalMeasures(M1_ProcTime, 'M1_ProcTime_StatResults.xls')
export.PrintStatisticalMeasures(M2_ProcTime, 'M2_ProcTime_StatResults.xls')

export.PrintDistributionFit(M1_ProcTime, 'M1_ProcTime_DistFitResults.xls')
export.PrintDistributionFit(M2_ProcTime, 'M2_ProcTime_DistFitResults.xls')

#calls ManPy main script with the input
simulationOutput = ManPyMain.main(input_data=json.dumps(data))
# save the simulation output
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
예제 #8
0
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")

CMSD_example(dictProc,dictScrap)    #Print the CMSD document, calling the CMSD_example method with arguments the dictProc and dictScrap dictionaries
JSON_example(dictProc,dictScrap)    #Print the JSON file, calling the JSON_example method


#calls ManPy main script with the input
 
simulationOutput=ManPyMain.main(input_data=str((JSON_example(dictProc,dictScrap))))
# save the simulation output
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
예제 #9
0
def main(test=0, ExcelFileName='inputData.xls',
                JSONFileName='JSON_AssembleDismantle.json',
                CMSDFileName='CMSD_AssemblyDismantle.xml',
                workbook=None,
                jsonFile=None, cmsdFile=None):
    if not workbook:
        workbook = xlrd.open_workbook(os.path.join(os.path.dirname(os.path.realpath(__file__)), ExcelFileName))
    #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
    
    A = ImportExceldata()                              #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 = ReplaceMissingValues()
    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 values prepared in the CMSD information model of this model ====================================================#
    if not cmsdFile:
        datafile=(os.path.join(os.path.dirname(os.path.realpath(__file__)), CMSDFileName))       #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
    
    exportCMSD=CMSDOutput()
    stationId1='M1'
    
    procTime=exportCMSD.ProcessingTimes(tree, stationId1, ProcTime_dist) 
    TTF=exportCMSD.TTF(procTime, stationId1, MTTF_dist)
    TTR=exportCMSD.TTR(TTF, stationId1, MTTR_dist)
    
    TTR.write('CMSD_AssemblyDismantle_Output.xml',encoding="utf8")                         #It writes the element tree to a specified file, using the 'utf8' output encoding
    
    #================================= Output preparation: output the updated values in the JSON file of this example =========================================================#
    if not jsonFile:
        jsonFile = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), JSONFileName),'r')      #It opens the JSON file 
        data = json.load(jsonFile)             #It loads the file
        jsonFile.close()
    else:
        data = json.load(jsonFile) 
    
    exportJSON=JSONOutput()
    stationId='M1'
    
    data=exportJSON.ProcessingTimes(data, stationId, ProcTime_dist)
    data1=exportJSON.TTF(data, stationId, MTTF_dist)
    data2=exportJSON.TTR(data1, stationId, MTTR_dist)
    
    #================================ Call ManPy and run the simulation model =============================================#
    #calls ManPy main script with the input
    simulationOutput=ManPyMain.main(input_data=json.dumps(data2))
    # if we run from test return the ManPy result
    if test:
        return simulationOutput
    
    #===================== 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 =============================================#
    C=ExcelOutput()
    C.PrintStatisticalMeasures(ProcTime,'ProcTime_StatResults.xls')   
    C.PrintStatisticalMeasures(MTTR,'MTTR_StatResults.xls')
    C.PrintStatisticalMeasures(MTTF,'MTTF_StatResults.xls')   
    C.PrintDistributionFit(ProcTime,'ProcTime_DistFitResults.xls')
    C.PrintDistributionFit(MTTR,'MTTR_DistFitResults.xls')
    
    #================================ Call ManPy and run the simulation model =============================================#
    #calls ManPy main script with the input
    simulationOutput=ManPyMain.main(input_data=json.dumps(data))
    # save the simulation output
    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
예제 #10
0
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'
      
    
    jsonFile = open('JSON_ParallelStations_Output.json',"w")     #It opens the JSON file
    jsonFile.write(json.dumps(data, 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 ==========================#
export=Output()

export.PrintStatisticalMeasures(M1_ProcTime,'M1_ProcTime_StatResults.xls')   
export.PrintStatisticalMeasures(M2_ProcTime,'M2_ProcTime_StatResults.xls')

export.PrintDistributionFit(M1_ProcTime,'M1_ProcTime_DistFitResults.xls')
export.PrintDistributionFit(M2_ProcTime,'M2_ProcTime_DistFitResults.xls')

#calls ManPy main script with the input
simulationOutput=ManPyMain.main(input_data=json.dumps(data))
# save the simulation output
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

예제 #11
0
def main(test=0, ExcelFileName='inputData.xls',
                JSONFileName='JSON_ParallelStations.json',
                workbook=None,
                jsonFile=None):
    
    #Read from the given directory the Excel document with the input data
    if not workbook:
        workbook = xlrd.open_workbook(os.path.join(os.path.dirname(os.path.realpath(__file__)), ExcelFileName))
    worksheets = workbook.sheet_names()
    worksheet_ProcessingTimes = worksheets[0]     #Define the worksheet with the Processing times data
    
    inputData = ImportExceldata()                              #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 = ReplaceMissingValues()
    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 ================================#
    if not jsonFile:
        jsonFile = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), JSONFileName),'r')      #It opens the JSON file 
        data = json.load(jsonFile)                                                              #It loads the file
        jsonFile.close()
    else:
        data = json.load(jsonFile) 
    
    exportJSON=JSONOutput()
    stationId1='St1'
    stationId2='St2'
    data1=exportJSON.ProcessingTimes(data, stationId1, M1ProcTime_dist)
    data2=exportJSON.ProcessingTimes(data1, stationId2, M2ProcTime_dist)
        
    #================================ Call ManPy and run the simulation model =============================================#
    #calls ManPy main script with the input
    simulationOutput=ManPyMain.main(input_data=json.dumps(data2))
    
    # if we run from test return the ManPy result
    if test:
        return simulationOutput

    #=================== Ouput the JSON file ==========================#
    jsonFile = open('JSON_ParallelStations_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 ==========================#
    export=ExcelOutput()
    
    export.PrintStatisticalMeasures(M1_ProcTime,'M1_ProcTime_StatResults.xls')   
    export.PrintStatisticalMeasures(M2_ProcTime,'M2_ProcTime_StatResults.xls')
    
    export.PrintDistributionFit(M1_ProcTime,'M1_ProcTime_DistFitResults.xls')
    export.PrintDistributionFit(M2_ProcTime,'M2_ProcTime_DistFitResults.xls')


    # save the simulation output
    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
예제 #12
0
procTime7 = exportCMSD.ProcessingTimes(procTime6, 'P7', dictProc['MM'])
procTime8 = exportCMSD.ProcessingTimes(procTime7, 'P8', dictProc['PrA'])
procTime9 = exportCMSD.ProcessingTimes(procTime8, 'P9', dictProc['PrB'])
procTime10 = exportCMSD.ProcessingTimes(procTime9, 'P10', dictProc['PaA'])
procTime11 = exportCMSD.ProcessingTimes(procTime10, 'P11', dictProc['PaB'])

scrapQuant1 = exportCMSD.ScrapQuantity(procTime11, 'P1', dictScrap['M1A'])
scrapQuant2 = exportCMSD.ScrapQuantity(scrapQuant1, 'P4', dictScrap['M1B'])
scrapQuant3 = exportCMSD.ScrapQuantity(scrapQuant2, 'P2', dictScrap['M2A'])
scrapQuant4 = exportCMSD.ScrapQuantity(scrapQuant3, 'P5', dictScrap['M2B'])
scrapQuant5 = exportCMSD.ScrapQuantity(scrapQuant4, 'P3', dictScrap['M3A'])
scrapQuant6 = exportCMSD.ScrapQuantity(scrapQuant5, 'P6', dictScrap['M3B'])
scrapQuant7 = exportCMSD.ScrapQuantity(scrapQuant6, 'P7', dictScrap['MM'])
scrapQuant8 = exportCMSD.ScrapQuantity(scrapQuant7, 'P8', dictScrap['PrA'])
scrapQuant9 = exportCMSD.ScrapQuantity(scrapQuant8, 'P9', dictScrap['PrB'])
scrapQuant10 = exportCMSD.ScrapQuantity(scrapQuant9, 'P10', dictScrap['PaA'])
scrapQuant11 = exportCMSD.ScrapQuantity(scrapQuant10, 'P11', dictScrap['PaA'])

scrapQuant11.write('CMSD_example_Output.xml', encoding="utf8")

data1 = open('CMSD_example_Output.xml', 'r')
#Call the JSONOutput object giving as attributes the dictionaries with the processing times distributions and the scrap quantities distributions and the WIP levels in the assembly line
exportJSON = JSONOutput()
data2 = exportJSON.JSONOutput(dictProc, dictScrap, WIP)

simulationOutput = ManPyMain.main(input_data=str(data2))
# simulationOutput=ManPyMain.main(input_data=data1)
# save the simulation output
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
예제 #13
0
procTime7=exportCMSD.ProcessingTimes(procTime6, 'P7', dictProc['MM'])
procTime8=exportCMSD.ProcessingTimes(procTime7, 'P8', dictProc['PrA'])
procTime9=exportCMSD.ProcessingTimes(procTime8, 'P9', dictProc['PrB'])
procTime10=exportCMSD.ProcessingTimes(procTime9, 'P10', dictProc['PaA'])
procTime11=exportCMSD.ProcessingTimes(procTime10, 'P11', dictProc['PaB'])

scrapQuant1=exportCMSD.ScrapQuantity(procTime11, 'P1', dictScrap['M1A'])
scrapQuant2=exportCMSD.ScrapQuantity(scrapQuant1, 'P4', dictScrap['M1B'])
scrapQuant3=exportCMSD.ScrapQuantity(scrapQuant2, 'P2', dictScrap['M2A'])
scrapQuant4=exportCMSD.ScrapQuantity(scrapQuant3, 'P5', dictScrap['M2B'])
scrapQuant5=exportCMSD.ScrapQuantity(scrapQuant4, 'P3', dictScrap['M3A'])
scrapQuant6=exportCMSD.ScrapQuantity(scrapQuant5, 'P6', dictScrap['M3B'])
scrapQuant7=exportCMSD.ScrapQuantity(scrapQuant6, 'P7', dictScrap['MM'])
scrapQuant8=exportCMSD.ScrapQuantity(scrapQuant7, 'P8', dictScrap['PrA'])
scrapQuant9=exportCMSD.ScrapQuantity(scrapQuant8, 'P9', dictScrap['PrB'])
scrapQuant10=exportCMSD.ScrapQuantity(scrapQuant9, 'P10', dictScrap['PaA'])
scrapQuant11=exportCMSD.ScrapQuantity(scrapQuant10, 'P11', dictScrap['PaA'])

scrapQuant11.write('CMSD_example_Output.xml',encoding="utf8")

data1 = open('CMSD_example_Output.xml','r')
#Call the JSONOutput object giving as attributes the dictionaries with the processing times distributions and the scrap quantities distributions and the WIP levels in the assembly line
exportJSON=JSONOutput()
data2 = exportJSON.JSONOutput(dictProc,dictScrap,WIP)

simulationOutput=ManPyMain.main(input_data=str(data2))
# simulationOutput=ManPyMain.main(input_data=data1)
    # save the simulation output
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