Commit 18c17e72 authored by panos's avatar panos

Bugs fixed in the Production Line example

parent b1591dfd
...@@ -359,14 +359,14 @@ def CMSD_example(list1,list2): ...@@ -359,14 +359,14 @@ def CMSD_example(list1,list2):
Name.text=str(list1['P1']['distributionType']) Name.text=str(list1['P1']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='mean' Name.text='shape'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P1']['mean']) Value.text=str(list1['P1']['shape'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='stdev' Name.text='rate'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P1']['stdev']) Value.text=str(list1['P1']['rate'])
Property=SubElement(Process,'Property') Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name') Name=SubElement(Property,'Name')
...@@ -420,14 +420,14 @@ def CMSD_example(list1,list2): ...@@ -420,14 +420,14 @@ def CMSD_example(list1,list2):
Name.text=str(list1['P2']['distributionType']) Name.text=str(list1['P2']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='mean' Name.text='shape'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P2']['mean']) Value.text=str(list1['P2']['shape'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='stdev' Name.text='rate'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P2']['stdev']) Value.text=str(list1['P2']['rate'])
Property=SubElement(Process,'Property') Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name') Name=SubElement(Property,'Name')
...@@ -606,14 +606,14 @@ def CMSD_example(list1,list2): ...@@ -606,14 +606,14 @@ def CMSD_example(list1,list2):
Name.text=str(list1['P5']['distributionType']) Name.text=str(list1['P5']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='mean' Name.text='shape'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P5']['mean']) Value.text=str(list1['P5']['shape'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='stdev' Name.text='rate'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P5']['mean']) Value.text=str(list1['P5']['rate'])
Property=SubElement(Process,'Property') Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name') Name=SubElement(Property,'Name')
...@@ -792,14 +792,14 @@ def CMSD_example(list1,list2): ...@@ -792,14 +792,14 @@ def CMSD_example(list1,list2):
Name.text=str(list1['P8']['distributionType']) Name.text=str(list1['P8']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='mean' Name.text='shape'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P8']['mean']) Value.text=str(list1['P8']['shape'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='stdev' Name.text='rate'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P8']['stdev']) Value.text=str(list1['P8']['rate'])
Property=SubElement(Process,'Property') Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name') Name=SubElement(Property,'Name')
...@@ -854,14 +854,14 @@ def CMSD_example(list1,list2): ...@@ -854,14 +854,14 @@ def CMSD_example(list1,list2):
Name.text=str(list1['P9']['distributionType']) Name.text=str(list1['P9']['distributionType'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='mean' Name.text='shape'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P9']['mean']) Value.text=str(list1['P9']['shape'])
DistributionParameter=SubElement(Distribution,'DistributionParameter') DistributionParameter=SubElement(Distribution,'DistributionParameter')
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='stdev' Name.text='rate'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P9']['stdev']) Value.text=str(list1['P9']['rate'])
Property=SubElement(Process,'Property') Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name') Name=SubElement(Property,'Name')
...@@ -923,7 +923,7 @@ def CMSD_example(list1,list2): ...@@ -923,7 +923,7 @@ def CMSD_example(list1,list2):
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='stdev' Name.text='stdev'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P9']['mean']) Value.text=str(list1['P10']['stdev'])
Property=SubElement(Process,'Property') Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name') Name=SubElement(Property,'Name')
...@@ -985,7 +985,7 @@ def CMSD_example(list1,list2): ...@@ -985,7 +985,7 @@ def CMSD_example(list1,list2):
Name=SubElement(DistributionParameter,'Name') Name=SubElement(DistributionParameter,'Name')
Name.text='stdev' Name.text='stdev'
Value=SubElement(DistributionParameter,'Value') Value=SubElement(DistributionParameter,'Value')
Value.text=str(list1['P11']['mean']) Value.text=str(list1['P11']['stdev'])
Property=SubElement(Process,'Property') Property=SubElement(Process,'Property')
Name=SubElement(Property,'Name') Name=SubElement(Property,'Name')
......
'''
Created on 9 Oct 2014
@author: Panos
'''
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
import json
def JSON_example(list1,list2):
jsonFile= open('JSON_example.json','r')
data = json.load(jsonFile)
jsonFile.close()
nodes=data.get('nodes',{})
for (element_id,element) in nodes.iteritems():
name=element.get('name')
scrapQuantity=element.get('scrapQuantity',{})
processingTime=element.get('processingTime',{})
if name in list1.keys():
element['processingTime']= list1[name]
else:
continue
if name in list2.keys():
element['scrapQuantity']= list2[name]
else:
continue
jsonFile = open('JSON_exampleOutput.json',"w")
jsonFile.write(json.dumps(data, indent=True))
jsonFile.close()
return json.dumps(data, indent=True)
\ No newline at end of file
...@@ -24,6 +24,7 @@ Created on 19 Feb 2014 ...@@ -24,6 +24,7 @@ Created on 19 Feb 2014
from StatisticalMeasures import BasicStatisticalMeasures from StatisticalMeasures import BasicStatisticalMeasures
from DataManipulation import DataManagement from DataManipulation import DataManagement
from DistributionFitting import DistFittest
from DistributionFitting import Distributions from DistributionFitting import Distributions
from CMSD_Output import CMSD_example from CMSD_Output import CMSD_example
from JSON_Output import JSON_example from JSON_Output import JSON_example
...@@ -36,7 +37,7 @@ import dream.simulation.LineGenerationJSON as ManPyMain ...@@ -36,7 +37,7 @@ import dream.simulation.LineGenerationJSON as ManPyMain
#================= Main script of KE tool =====================================# #================= Main script of KE tool =====================================#
#Read from the given directory the Excel document with the input data #Read from the given directory the Excel document with the input data
workbook = xlrd.open_workbook('inputData.xls') workbook = xlrd.open_workbook('input_Data.xls')
worksheets = workbook.sheet_names() worksheets = workbook.sheet_names()
worksheet_ProcessingTimes = worksheets[1] #Define the worksheet with the Processing times data worksheet_ProcessingTimes = worksheets[1] #Define the worksheet with the Processing times data
worksheet_ScrapQuantity = worksheets[0] #Define the worksheet with the Scrap Quantity data worksheet_ScrapQuantity = worksheets[0] #Define the worksheet with the Scrap Quantity data
...@@ -46,38 +47,57 @@ ProcessingTimes= A.Input_data(worksheet_ProcessingTimes, workbook) #Create the ...@@ -46,38 +47,57 @@ ProcessingTimes= A.Input_data(worksheet_ProcessingTimes, workbook) #Create the
ScrapQuantity=A.Input_data(worksheet_ScrapQuantity, workbook) #Create the Scrap Quantity dictionary with keys the different stations in the line and values the scrap quantity data of different batches in these stations ScrapQuantity=A.Input_data(worksheet_ScrapQuantity, workbook) #Create the Scrap Quantity dictionary with keys the different stations in the line and values the scrap quantity data of different batches in these stations
##Get from the Scrap Quantity dictionary the different keys and define the following lists with the scrap quantity data of the different stations in the topology ##Get from the Scrap Quantity dictionary the different keys and define the following lists with the scrap quantity data of the different stations in the topology
P7_Scrap = ScrapQuantity.get('P7',[])
P1_Scrap = ScrapQuantity.get('P1',[]) P1_Scrap= ScrapQuantity.get('P1',[])
P2_Scrap= ScrapQuantity.get('P3',[]) P2_Scrap= ScrapQuantity.get('P2',[])
P3_Scrap=ScrapQuantity.get('P3',[]) P3_Scrap= ScrapQuantity.get('P3',[])
P8_Scrap=ScrapQuantity.get('P8',[]) P4_Scrap= ScrapQuantity.get('P4',[])
P5_Scrap= ScrapQuantity.get('P5',[])
P6_Scrap= ScrapQuantity.get('P6',[])
P7_Scrap= ScrapQuantity.get('P7',[])
P8_Scrap= ScrapQuantity.get('P8',[])
P9_Scrap= ScrapQuantity.get('P9',[]) P9_Scrap= ScrapQuantity.get('P9',[])
P10_Scrap= ScrapQuantity.get('P10',[])
P11_Scrap= ScrapQuantity.get('P11',[])
##Get from the Processing times dictionary the different keys and define the following lists with the processing times data of the different stations in the topology ##Get from the Processing times dictionary the different keys and define the following lists with the processing times data of the different stations in the topology
P7_Proc = ProcessingTimes.get('P7',[])
P1_Proc = ProcessingTimes.get('P1',[]) P1_Proc= ProcessingTimes.get('P1',[])
P2_Proc= ProcessingTimes.get('P2',[]) P2_Proc= ProcessingTimes.get('P2',[])
P3_Proc=ProcessingTimes.get('P3',[]) P3_Proc= ProcessingTimes.get('P3',[])
P8_Proc=ProcessingTimes.get('P8',[]) P4_Proc= ProcessingTimes.get('P4',[])
P5_Proc= ProcessingTimes.get('P5',[])
P6_Proc= ProcessingTimes.get('P6',[])
P7_Proc= ProcessingTimes.get('P7',[])
P8_Proc= ProcessingTimes.get('P8',[])
P9_Proc= ProcessingTimes.get('P9',[]) P9_Proc= ProcessingTimes.get('P9',[])
P10_Proc= ProcessingTimes.get('P10',[])
P11_Proc= ProcessingTimes.get('P11',[])
#Call the HandleMissingValues object and replace with zero the missing values in the lists with the scrap quantity data #Call the HandleMissingValues object and replace with zero the missing values in the lists with the scrap quantity data
B=HandleMissingValues() B=HandleMissingValues()
P7_Scrap= B.ReplaceWithZero(P7_Scrap)
P1_Scrap= B.ReplaceWithZero(P1_Scrap) P1_Scrap= B.ReplaceWithZero(P1_Scrap)
P2_Scrap= B.ReplaceWithZero(P2_Scrap) P2_Scrap= B.ReplaceWithZero(P2_Scrap)
P3_Scrap= B.ReplaceWithZero(P3_Scrap) P3_Scrap= B.ReplaceWithZero(P3_Scrap)
P4_Scrap= B.ReplaceWithZero(P4_Scrap)
P5_Scrap= B.ReplaceWithZero(P5_Scrap)
P6_Scrap= B.ReplaceWithZero(P6_Scrap)
P7_Scrap= B.ReplaceWithZero(P7_Scrap)
P8_Scrap= B.ReplaceWithZero(P8_Scrap) P8_Scrap= B.ReplaceWithZero(P8_Scrap)
P9_Scrap= B.ReplaceWithZero(P9_Scrap) P9_Scrap= B.ReplaceWithZero(P9_Scrap)
P10_Scrap= B.ReplaceWithZero(P10_Scrap)
P11_Scrap= B.ReplaceWithZero(P11_Scrap)
# #Call the BasicSatatisticalMeasures object # #Call the BasicSatatisticalMeasures object
C=BasicStatisticalMeasures() C=BasicStatisticalMeasures()
#Create a list with values the calculated mean value of scrap quantity on the different stations in the line #Create a list with values the calculated mean value of scrap quantity on the different stations in the line
listScrap=[C.mean(P1_Scrap),C.mean(P2_Scrap),C.mean(P3_Scrap),C.mean(P1_Scrap),C.mean(P2_Scrap),C.mean(P3_Scrap),C.mean(P7_Scrap),C.mean(P8_Scrap),C.mean(P8_Scrap),C.mean(P9_Scrap), C.mean(P9_Scrap)] listScrap=[C.mean(P1_Scrap),C.mean(P2_Scrap),C.mean(P3_Scrap),C.mean(P4_Scrap),C.mean(P5_Scrap),C.mean(P6_Scrap),C.mean(P7_Scrap),C.mean(P8_Scrap),C.mean(P9_Scrap),C.mean(P10_Scrap), C.mean(P11_Scrap)]
F=DataManagement() D= DataManagement()
listScrap=F.round(listScrap) #Round the mean values of the list so as to get integers listScrap=D.round(listScrap) #Round the mean values of the list so as to get integers
dictScrap={} dictScrap={}
dictScrap['P1']= listScrap[0] dictScrap['P1']= listScrap[0]
...@@ -92,35 +112,30 @@ dictScrap['P9']= listScrap[8] ...@@ -92,35 +112,30 @@ dictScrap['P9']= listScrap[8]
dictScrap['P10']= listScrap[9] dictScrap['P10']= listScrap[9]
dictScrap['P11']= listScrap[10] dictScrap['P11']= listScrap[10]
#Create a tuple with the Processing times data lists of the different stations E= DistFittest()
a=(P1_Proc,P2_Proc,P3_Proc,P1_Proc,P2_Proc,P3_Proc,P7_Proc,P8_Proc,P8_Proc,P9_Proc,P9_Proc)
E=Distributions() #Call the DistFittest object
dictProc={} dictProc={}
dictProc['P1']= E.Normal_distrfit(P1_Proc) dictProc['P1']= E.ks_test(P1_Proc)
dictProc['P2']= E.Normal_distrfit(P2_Proc) dictProc['P2']= E.ks_test(P2_Proc)
dictProc['P3']= E.Normal_distrfit(P3_Proc) dictProc['P3']= E.ks_test(P3_Proc)
dictProc['P4']= E.Normal_distrfit(P1_Proc) dictProc['P4']= E.ks_test(P4_Proc)
dictProc['P5']= E.Normal_distrfit(P2_Proc) dictProc['P5']= E.ks_test(P5_Proc)
dictProc['P6']= E.Normal_distrfit(P3_Proc) dictProc['P6']= E.ks_test(P6_Proc)
dictProc['P7']= E.Normal_distrfit(P7_Proc) dictProc['P7']= E.ks_test(P7_Proc)
dictProc['P8']= E.Normal_distrfit(P8_Proc) dictProc['P8']= E.ks_test(P8_Proc)
dictProc['P9']= E.Normal_distrfit(P8_Proc) dictProc['P9']= E.ks_test(P9_Proc)
dictProc['P10']= E.Normal_distrfit(P9_Proc) dictProc['P10']= E.ks_test(P10_Proc)
dictProc['P11']= E.Normal_distrfit(P9_Proc) dictProc['P11']= E.ks_test(P11_Proc)
F= Output()
D=Output() F.PrintDistributionFit(P2_Proc,"DistributionFittingResults_P2Proc.xls")
D.PrintDistributionFit(P2_Proc,"DistributionFittingResults_P2Proc.xls") F.PrintStatisticalMeasures(P2_Proc, "StatisticalMeasuresResults_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 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 JSON_example(dictProc,dictScrap) #Print the JSON file, calling the JSON_example method
#calls ManPy main script with the input #calls ManPy main script with the input
simulationOutput=ManPyMain.main(input_data=str((JSON_example(dictProc,dictScrap)))) simulationOutput=ManPyMain.main(input_data=str((JSON_example(dictProc,dictScrap))))
# 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