Commit 3fc5f7e3 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by panos

example that got damaged in rebase recovered

parent 01b66b72
...@@ -31,15 +31,16 @@ from dream.KnowledgeExtraction.JSONOutput import JSONOutput ...@@ -31,15 +31,16 @@ from dream.KnowledgeExtraction.JSONOutput import JSONOutput
import xlrd import xlrd
import json import json
import dream.simulation.LineGenerationJSON as ManPyMain #import ManPy main JSON script import dream.simulation.LineGenerationJSON as ManPyMain #import ManPy main JSON script
import os
def main(test=0, ExcelFileName='KEtool_examples/TwoParallelStations/inputData.xls', def main(test=0, ExcelFileName='inputData.xls',
JSONFileName='KEtool_examples/TwoParallelStations/JSON_TwoParallelStations.json', JSONFileName='JSON_ParallelStations.json',
workbook=None, workbook=None,
jsonFile=None): jsonFile=None):
#Read from the given directory the Excel document with the input data #Read from the given directory the Excel document with the input data
if not workbook: if not workbook:
workbook = xlrd.open_workbook(ExcelFileName) workbook = xlrd.open_workbook(os.path.join(os.path.dirname(os.path.realpath(__file__)), ExcelFileName))
worksheets = workbook.sheet_names() worksheets = workbook.sheet_names()
worksheet_ProcessingTimes = worksheets[0] #Define the worksheet with the Processing times data worksheet_ProcessingTimes = worksheets[0] #Define the worksheet with the Processing times data
...@@ -63,51 +64,41 @@ def main(test=0, ExcelFileName='KEtool_examples/TwoParallelStations/inputData.xl ...@@ -63,51 +64,41 @@ def main(test=0, ExcelFileName='KEtool_examples/TwoParallelStations/inputData.xl
#======================= Output preparation: output the updated values in the JSON file of this example ================================# #======================= Output preparation: output the updated values in the JSON file of this example ================================#
jsonFile = open('JSON_ParallelStations.json','r') #It opens the JSON file if not jsonFile:
jsonFile = open(JSONFileName,'r') #It opens the JSON file 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 data = json.load(jsonFile) #It loads the file
jsonFile.close() jsonFile.close()
else: else:
data = json.load(jsonFile) data = json.load(jsonFile)
nodes = data['graph']['node'] #It creates a variable that holds the 'nodes' dictionary
procTimeM1dict={} exportJSON=JSONOutput()
procTimeM2dict={} stationId1='St1'
dist=M1ProcTime_dist['distributionType'] stationId2='St2'
del M1ProcTime_dist['distributionType'] data1=exportJSON.ProcessingTimes(data, stationId1, M1ProcTime_dist)
procTimeM1dict[dist]=M1ProcTime_dist data2=exportJSON.ProcessingTimes(data1, stationId2, M2ProcTime_dist)
dist=M2ProcTime_dist['distributionType'] #================================ Call ManPy and run the simulation model =============================================#
del M2ProcTime_dist['distributionType'] #calls ManPy main script with the input
procTimeM2dict[dist]=M2ProcTime_dist simulationOutput=ManPyMain.main(input_data=json.dumps(data2))
for element in nodes: # if we run from test return the ManPy result
if test:
return simulationOutput
exportJSON=JSONOutput() #=================== Ouput the JSON file ==========================#
stationId1='St1' jsonFile = open('JSON_ParallelStations_Output.json',"w") #It opens the JSON file
stationId2='St2' jsonFile.write(json.dumps(data2, indent=True)) #It writes the updated data to the JSON file
data1=exportJSON.ProcessingTimes(data, stationId1, M1ProcTime_dist) jsonFile.close() #It closes the file
data2=exportJSON.ProcessingTimes(data1, stationId2, M2ProcTime_dist)
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 ==========================# #=================== Calling the ExcelOutput object, outputs the outcomes of the statistical analysis in xls files ==========================#
# save the KE output in xls
export=Output() export=Output()
# save KE results in Excel
export.PrintStatisticalMeasures(M1_ProcTime,'M1_ProcTime_StatResults.xls') export.PrintStatisticalMeasures(M1_ProcTime,'M1_ProcTime_StatResults.xls')
export.PrintStatisticalMeasures(M2_ProcTime,'M2_ProcTime_StatResults.xls') export.PrintStatisticalMeasures(M2_ProcTime,'M2_ProcTime_StatResults.xls')
export.PrintDistributionFit(M1_ProcTime,'M1_ProcTime_DistFitResults.xls') export.PrintDistributionFit(M1_ProcTime,'M1_ProcTime_DistFitResults.xls')
export.PrintDistributionFit(M2_ProcTime,'M2_ProcTime_DistFitResults.xls') export.PrintDistributionFit(M2_ProcTime,'M2_ProcTime_DistFitResults.xls')
# save the KE output in JSON
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
# save the simulation output # save the simulation output
jsonFile = open('ManPyOutput.json',"w") #It opens the JSON file jsonFile = open('ManPyOutput.json',"w") #It opens the JSON file
......
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