Commit 8ee61ac9 authored by panos's avatar panos Committed by Jérome Perrin

Create a folder for the knowledge extraction tool example

parent c7bfa857
{
"edges": {
"con_140": [
"S1",
"QStart",
{}
],
"con_145": [
"QStart",
"BDA",
{}
],
"con_150": [
"QStart",
"BDB",
{}
],
"con_155": [
"BDA",
"M1A",
{}
],
"con_160": [
"M1A",
"Q2A",
{}
],
"con_165": [
"Q2A",
"M2A",
{}
],
"con_170": [
"M2A",
"Q3A",
{}
],
"con_175": [
"Q3A",
"M3A",
{}
],
"con_180": [
"M3A",
"BRA",
{}
],
"con_185": [
"BRA",
"QM",
{}
],
"con_190": [
"BDB",
"M1B",
{}
],
"con_195": [
"M1B",
"Q2B",
{}
],
"con_200": [
"Q2B",
"M2B",
{}
],
"con_205": [
"M2B",
"Q3B",
{}
],
"con_210": [
"Q3B",
"M3B",
{}
],
"con_215": [
"M3B",
"BRB",
{}
],
"con_220": [
"BRB",
"QM",
{}
],
"con_225": [
"QM",
"MM",
{}
],
"con_230": [
"MM",
"QPr",
{}
],
"con_235": [
"QPr",
"PrA",
{}
],
"con_240": [
"QPr",
"PrB",
{}
],
"con_245": [
"PrA",
"QPa",
{}
],
"con_250": [
"PrB",
"QPa",
{}
],
"con_255": [
"QPa",
"PaA",
{}
],
"con_260": [
"QPa",
"PaB",
{}
],
"con_265": [
"PaA",
"E1",
{}
],
"con_270": [
"PaB",
"E1",
{}
]
},
"general": {
"confidenceLevel": "0.95",
"maxSimTime": "2880",
"numberOfReplications": "1",
"processTimeout": "0.5",
"trace": "No"
},
"nodes": {
"BDA": {
"_class": "Dream.BatchDecompositionStartTime",
"element_id": "DreamNode_1",
"name": "Deco_A",
"numberOfSubBatches": 4,
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
"BDB": {
"_class": "Dream.BatchDecompositionStartTime",
"element_id": "DreamNode_2",
"name": "Deco_B",
"numberOfSubBatches": 4,
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
"BRA": {
"_class": "Dream.BatchReassembly",
"element_id": "DreamNode_3",
"name": "Assembly_A",
"numberOfSubBatches": 4,
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
"BRB": {
"_class": "Dream.BatchReassembly",
"element_id": "DreamNode_4",
"name": "Assembly_B",
"numberOfSubBatches": 4,
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
}
},
"E1": {
"_class": "Dream.Exit",
"element_id": "DreamNode_5",
"name": "Stock"
},
"M1A": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_6",
"failures": {},
"name": "RO_E_M_A_A",
"shift": {
"shiftPattern": [[360,780], [1800,2220]],
"endUnfinished": 0
},
"processingTime": {
}
},
"M1B": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_7",
"failures": {},
"name": "RO_E_M_A_B",
"shift": {
"shiftPattern": [[360,1260], [1800,2700]],
"endUnfinished": 0
},
"processingTime": {
}
},
"M2A": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_8",
"failures": {},
"name": "P_B_A_A",
"shift": {
"shiftPattern": [[360,780], [1800,2220]],
"endUnfinished": 0
},
"processingTime": {
}
},
"M2B": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_9",
"failures": {},
"name": "P_B_A_B",
"shift": {
"shiftPattern": [[360,1260], [1800,2700]],
"endUnfinished": 0
},
"processingTime": {
}
},
"M3A": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_10",
"failures": {},
"name": "D_B_A_A",
"shift": {
"shiftPattern": [[360,780], [1800,2220]],
"endUnfinished": 0
},
"processingTime": {
}
},
"M3B": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_11",
"failures": {},
"name": "D_B_A_B",
"shift": {
"shiftPattern": [[360,1260], [1800,2700]],
"endUnfinished": 0
},
"processingTime": {
}
},
"MM": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_12",
"failures": {},
"name": "Moulding",
"shift": {
"shiftPattern": [[360,1260], [1800,2700]],
"endUnfinished": 0
},
"processingTime": {
}
},
"PaA": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_13",
"failures": {},
"name": "Packaging_A",
"shift": {
"shiftPattern": [[360,780], [1800,2220]],
"endUnfinished": 0
},
"processingTime": {
}
},
"PaB": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_14",
"failures": {},
"name": "Packaging_B",
"shift": {
"shiftPattern": [[360,1260], [1800,2700]],
"endUnfinished": 0
},
"processingTime": {
}
},
"PrA": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_15",
"failures": {},
"name": "Pressure_A",
"shift": {
"shiftPattern": [[360,780], [1800,2220]],
"endUnfinished": 0
},
"processingTime": {
}
},
"PrB": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_16",
"failures": {},
"name": "Pressure_B",
"shift": {
"shiftPattern": [[360,1260], [1800,2700]],
"endUnfinished": 0
},
"processingTime": {
}
},
"Q2A": {
"_class": "Dream.LineClearance",
"capacity": "2",
"element_id": "DreamNode_17",
"isDummy": "0",
"name": "Q2A",
"schedulingRule": "FIFO"
},
"Q2B": {
"_class": "Dream.LineClearance",
"capacity": "2",
"element_id": "DreamNode_18",
"isDummy": "0",
"name": "Q2B",
"schedulingRule": "FIFO"
},
"Q3A": {
"_class": "Dream.LineClearance",
"capacity": "2",
"element_id": "DreamNode_19",
"isDummy": "0",
"name": "Q3A",
"schedulingRule": "FIFO"
},
"Q3B": {
"_class": "Dream.LineClearance",
"capacity": "2",
"element_id": "DreamNode_20",
"isDummy": "0",
"name": "Q3B",
"schedulingRule": "FIFO"
},
"QM": {
"_class": "Dream.Queue",
"capacity": "3",
"element_id": "DreamNode_21",
"isDummy": "0",
"name": "QM",
"schedulingRule": "FIFO"
},
"QPa": {
"_class": "Dream.Queue",
"capacity": "3",
"element_id": "DreamNode_22",
"isDummy": "0",
"name": "QPa",
"schedulingRule": "FIFO"
},
"QPr": {
"_class": "Dream.Queue",
"capacity": "3",
"element_id": "DreamNode_23",
"isDummy": "0",
"name": "QPr",
"schedulingRule": "FIFO"
},
"QStart": {
"_class": "Dream.Queue",
"capacity": "-1",
"element_id": "DreamNode_24",
"isDummy": "0",
"name": "StartQueue",
"schedulingRule": "FIFO"
},
"S1": {
"_class": "Dream.BatchSource",
"batchNumberOfUnits": 80,
"element_id": "DreamNode_25",
"entity": "Batch",
"interarrivalTime": {
"distributionType": "Fixed",
"mean": "0.5"
},
"name": "Source"
},
"EV": {
"_class": "Dream.EventGenerator",
"name": "attainment",
"start": "1440",
"interval": "1440",
"method": "Globals.countIntervalThroughput",
"argumentDict": {
}
}
},
"preference": {
"coordinates": {
"BDA": {
"left": 0.17522921311349376,
"top": 0.014751694583812569
},
"BDB": {
"left": 0.17064206093774784,
"top": 0.18992806776658683
},
"BRA": {
"left": 0.7623846916089703,
"top": 0.014751694583812569
},
"BRB": {
"left": 0.7486232350817325,
"top": 0.2175874951112354
},
"E1": {
"left": 0.781650730747103,
"top": 0.8537543240381524
},
"M1A": {
"left": 0.26697225662841195,
"top": 0.005531885468929714
},
"M1B": {
"left": 0.2550456609714726,
"top": 0.18992806776658683
},
"M2A": {
"left": 0.4596326480097402,
"top": 0.005531885468929714
},
"M2B": {
"left": 0.4568803567042926,
"top": 0.18992806776658683
},
"M3A": {
"left": 0.6614673437425602,
"top": 0.023971503698695426
},
"M3B": {
"left": 0.6495407480856209,
"top": 0.20836768599635255
},
"MM": {
"left": 0.882568078613513,
"top": 0.34666482271959537
},
"PaA": {
"left": 0.8926598134001541,
"top": 0.7707760420042068
},
"PaB": {
"left": 0.670641648094052,
"top": 0.7707760420042068
},
"PrA": {
"left": 0.8788983568729164,
"top": 0.6048194779363153
},
"PrB": {
"left": 0.6844031046212897,
"top": 0.5863798597065496
},
"Q2A": {
"left": 0.35871530014333014,
"top": 0.014751694583812569
},
"Q2B": {
"left": 0.3651373131893744,
"top": 0.18070825865170398
},
"Q3A": {
"left": 0.569724300227642,
"top": 0.014751694583812569
},
"Q3B": {
"left": 0.5577977045707027,
"top": 0.19914787688146968
},
"QM": {
"left": 0.8642194699105294,
"top": 0.1530488313070554
},
"QPa": {
"left": 0.781650730747103,
"top": 0.6509185235107297
},
"QPr": {
"left": 0.7908250350985949,
"top": 0.503401577672604
},
"QStart": {
"left": 0.0972476261258133,
"top": 0.09772997661775827
},
"S1": {
"left": 0.0037421998521831056,
"top": 0.09077525071036834
}
},
"zoom_level": 0.81
},
"spreadsheet": [
[
"Jobs",
"ID",
"Order Date",
"Due Date",
"Priority",
"Material",
"Sequence",
"Processing Times"
],
[
null,
null,
null,
null,
null,
null,
null,
null
]
]
}
<?xml version='1.0' encoding='utf8'?>
<CMSDDocument>
<DataSection>
<PartType>
<Identifier>Part1</Identifier>
</PartType>
<PartType>
<Identifier>UnfinishedPart1</Identifier>
</PartType>
<Resource>
<Identifier>S1</Identifier>
<Description>The source of the topology</Description>
<ResourceType>Source</ResourceType>
<Name>RawMaterial</Name>
</Resource>
<Resource>
<Identifier>M1</Identifier>
<Description>The lathe of the topology</Description>
<ResourceType>Machine</ResourceType>
<Name>Machine1</Name>
</Resource>
<Resource>
<Identifier>M2</Identifier>
<Description>The moulding machine of the topology</Description>
<ResourceType>Machine</ResourceType>
<Name>Machine2</Name>
</Resource>
<Resource>
<Identifier>Queue</Identifier>
<Description>The queue of the topology</Description>
<ResourceType>Queue</ResourceType>
<Name>Queue</Name>
</Resource>
<Resource>
<Identifier>Exit</Identifier>
<Description>The exit of the topology</Description>
<ResourceType>Exit</ResourceType>
<Name>Stock</Name>
</Resource>
<Resource>
<Identifier>A</Identifier>
<ResourceType>employee</ResourceType>
</Resource>
<Resource>
<Identifier>B</Identifier>
<ResourceType>employee</ResourceType>
</Resource>
<Resource>
<Identifier>Repairman</Identifier>
<Description>This element describes a class of employees</Description>
<ResourceType>employee</ResourceType>
<Name>W1</Name>
</Resource>
********************************Process Plan*****************************************************
<ProcessPlan>
<Identifier>ProcessPlan:Part1</Identifier>
<PartsProduced>
<Description>The part produced the process</Description>
<PartType>
<PartTypeIdentifier>Part1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>The part(s) consumed the process</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<FirstProcess>
<ProcessIdentifier>MainProcessSequence</ProcessIdentifier>
</FirstProcess>
<Process>
<Identifier>MainProcessSequence</Identifier>
<RepetitionCount>1</RepetitionCount>
<SubProcessGroup>
<Type>sequence</Type>
<Process>
<ProcessIdentifier>A010</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A020</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A030</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A040</ProcessIdentifier>
</Process>
<Process>
<ProcessIdentifier>A050</ProcessIdentifier>
</Process>
</SubProcessGroup>
</Process>
***********************************************Process************************************************
<Process>
<Identifier>A010</Identifier>
<Description>Process 1</Description>
<ResourcesRequired>
<Description>Source</Description>
<Resource>
<ResourceIdentifier>S1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<Property>
<Name>interarrivalTime</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>0.5</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>partType</Name>
<Value>Part</Value>
</Property>
</Process>
<Process>
<Identifier>A020</Identifier>
<Description>Process 2</Description>
<PartsProduced>
<Description>...</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>...</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<Resource>
<ResourceIdentifier>A</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<ResourcesRequired>
<Description>Machine1.</Description>
<Resource>
<ResourceIdentifier>M1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<OperationTime>
<Unit>minutes</Unit>
<Distribution>
<Name></Name>
<DistributionParameterA>
<Name></Name>
<Value></Value>
</DistributionParameterA>
<DistributionParameterB>
<Name></Name>
<Value></Value>
</DistributionParameterB>
</Distribution>
</OperationTime>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>60</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>5</Value>
</DistributionParameter>
</Distribution>
<Property>
<Name>RepairmanRequired</Name>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Process>
<Process>
<Identifier>A030</Identifier>
<Description>Process 3</Description>
<ResourcesRequired>
<Description>Queue1.</Description>
<Resource>
<ResourceIdentifier>Q1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<Property>
<Name>capacity</Name>
<Value>1</Value>
</Property>
</Process>
<Process>
<Identifier>A040</Identifier>
<Description>Process 4</Description>
<PartsProduced>
<Description>...</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsProduced>
<PartsConsumed>
<Description>...</Description>
<PartType>
<PartTypeIdentifier>UnfinishedPart1</PartTypeIdentifier>
</PartType>
<PartQuantity>1</PartQuantity>
</PartsConsumed>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<Resource>
<ResourceIdentifier>B</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<ResourcesRequired>
<Description>Machine2.</Description>
<Resource>
<ResourceIdentifier>M2</ResourceIdentifier>
</Resource>
</ResourcesRequired>
<OperationTime>
<Unit>minutes</Unit>
<Distribution>
<Name></Name>
<DistributionParameterA>
<Name></Name>
<Value></Value>
</DistributionParameterA>
<DistributionParameterB>
<Name></Name>
<Value></Value>
</DistributionParameterB>
</Distribution>
</OperationTime>
<Property>
<Name>MeanTimeToFailure</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>40</Value>
</DistributionParameter>
</Distribution>
</Property>
<Property>
<Name>MeanTimeToRepair</Name>
<Unit>minutes</Unit>
<Distribution>
<Name>Fixed</Name>
<DistributionParameter>
<Name>mean</Name>
<Value>10</Value>
</DistributionParameter>
</Distribution>
<Property>
<Name>RepairmanRequired</Name>
<ResourcesRequired>
<Description>The employee performing the operation.</Description>
<ResourceIdentifier>W1</ResourceIdentifier>
</ResourcesRequired>
</Property>
</Property>
</Process>
<Process>
<Identifier>A050</Identifier>
<Description>Process 5</Description>
<ResourcesRequired>
<Description>Exit.</Description>
<Resource>
<ResourceIdentifier>E1</ResourceIdentifier>
</Resource>
</ResourcesRequired>
</Process>
</ProcessPlan>
</DataSection>
</CMSDDocument>
\ No newline at end of file
'''
Created on 19 Feb 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/>.
# ===========================================================================
from ImportExceldata import Import_Excel
from DistributionFitting import DistFittest
from xml.etree import ElementTree as et
from ExcelOutput import Output
from ReplaceMissingValues import HandleMissingValues
import xlrd
import json
#================================================ This script is a simple example of the Knowledge extraction tool ===============================================================#
#The following is the Main script, that calls two Python objects in order to conduct the three main components of the Knowledge extraction tool
#In the following example the operation times of the topology's two machines are given in an Excel document.
#Import_Excel object imports data from the Excel document to the tool and DistFittest object fits the data to a statistical distribution using Kolmogorov-Smirnov test
workbook = xlrd.open_workbook('inputsKEtool.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)
B=DistFittest() #It calls the DistFittest object
B.ks_test(Machine2_OpearationTimes) #It conducts the Kolmogorov-Smirnov test in the list with the operation times data
B.ks_test(Machine1_OpearationTimes)
lista=[] #It creates a list, that contains the outcome of the Kolmogorov-Smirnov tests
lista.append(B.ks_test(Machine1_OpearationTimes))
lista.append(B.ks_test(Machine2_OpearationTimes))
names = [] #It defines the following five lists
aParameters=[]
bParameters=[]
aParameterValue=[]
bParameterValue=[]
for index in range(len(lista)):
names.append(lista[index].get('type')) #Insert the distribution names from the dictionary into the names list
aParameters.append(lista[index].get('aParameter')) #Insert the name of the first parameter of each distribution from the dictionary into the aParameters list
try:
bParameters.append(lista[index].get('bParameter')) #Insert the name of the second parameter of each distribution from the dictionary (if there are any->use of except) into the bParameters list
except:
bParameters.append('')
aParameterValue.append(lista[index].get('aParameterValue')) #Insert the value of the first parameter of each distribution from the dictionary into the aParameterValue list
try:
bParameterValue.append(lista[index].get('bParameterValue')) #Insert the value of the second parameter of each distribution from the dictionary (if there are any->use of except) into the bParameterValue list
except:
bParameterValue.append('')
#==================================== Output preparation: output the updated values in the CMSD information model of Topology10 ====================================================#
datafile=('CMSD_Topology10.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
root=tree.getroot()
process=tree.findall('./DataSection/ProcessPlan/Process') #It creates a new variable and using the 'findall' order in XML.ETREE library, this new variable holds all the processes defined in the XML file
for process in process:
process_identifier=process.find('Identifier').text #It creates a new variable that holds the text of the Identifier element in the XML file
if process_identifier=='A020': #It checks using if...elif syntax if the process identifier is 'A020', so the process that uses the first machine
OperationTime=process.get('OpeationTime') #It gets the element attribute OpearationTime inside the Process node
Distribution=process.get('./OperationTime/Distribution') #It gets the element attribute Distribution inside the OpearationTime node
Name=process.find('./OperationTime/Distribution/Name') #It finds the subelement Name inside the Distribution attribute
Name.text=str(names[0]) #It changes the text between the Name element tags, putting the name of the distribution (e.g. in Normal distribution that will be Normal)
DistributionParameterA=process.get('./OperationTime/Distribution/DistributionParameterA')
Name=process.find('./OperationTime/Distribution/DistributionParameterA/Name')
Name.text=str(aParameters[0]) #It changes the text between the Name element tags, putting the name of the distribution's first parameter (e.g. in Normal that will be the mean)
Value=process.find('./OperationTime/Distribution/DistributionParameterA/Value')
Value.text=str(aParameterValue[0]) #It changes the text between the Value element tags, putting the value of the distribution's first parameter (e.g. in Normal so for mean value that will be 5.0)
DistributionParameterB=process.get('./OperationTime/Distribution/DistributionParameterB')
Name=process.find('./OperationTime/Distribution/DistributionParameterB/Name')
Name.text=str(bParameters[0]) #It changes the text between the Name element tags, putting the name of the distribution's second parameter (e.g. in Normal that will be the standarddeviation)
Value=process.find('./OperationTime/Distribution/DistributionParameterB/Value')
Value.text=str(bParameterValue[0]) #It changes the text between the Value element tags, putting the value of the distribution's second parameter (e.g. in Normal so for standarddeviation value that will be 1.3)
elif process_identifier=='A040': #It checks using if...elif syntax if the process identifier is 'A040', so the process that uses the second machine
OperationTime=process.get('OpeationTime')
Distribution=process.get('./OperationTime/Distribution')
Name=process.find('./OperationTime/Distribution/Name')
Name.text=str(names[1])
DistributionParameterA=process.get('./OperationTime/Distribution/DistributionParameterA')
Name=process.find('./OperationTime/Distribution/DistributionParameterA/Name')
Name.text=str(aParameters[1])
Value=process.find('./OperationTime/Distribution/DistributionParameterA/Value')
Value.text=str(aParameterValue[1])
DistributionParameterB=process.get('./OperationTime/Distribution/DistributionParameterB')
Name=process.find('./OperationTime/Distribution/DistributionParameterB/Name')
Name.text=str(bParameters[1])
Value=process.find('./OperationTime/Distribution/DistributionParameterB/Value')
Value.text=str(bParameterValue[1])
else:
continue
tree.write('CMSD_Topology10_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 =========================================================#
jsonFile= open('JSON_Topology10.json','r') #It opens the Topology10 JSON file
data = json.load(jsonFile) #It loads the file
jsonFile.close()
nodes=data.get('coreObject',[]) #It creates a variable that holds the 'coreObject' list
for element in nodes:
name=element.get('name') #It creates a variable that gets the element attribute 'name'
processingTime=element.get('processingTime',{}) #It creates a variable that gets the element attribute 'processingTime'
if name =='Machine1': #It checks using if...elif syntax if the name is 'Machine1', so the first machine in the Topology10
processingTime['distributionType']=str(names[0]) #It changes the attribute's ('distributionType') name, putting the name of the distribution (e.g. in Normal distribution that will be Normal)
processingTime[str(aParameters[0])]=str(aParameterValue[0]) # It adds a new attribute in the JSON file with the name of the first argument in aParameter's list (e.g. in Normal that will be the mean), putting the value of the distribution's first parameter (e.g. in Normal so for mean value that will be 7.0)
processingTime[str(bParameters[0])]=str(bParameterValue[0]) # It adds a new attribute in the JSON file with the name of the second argument in aParameter's list (e.g. in Normal that will be the standarddeviation), putting the value of the distribution's second parameter (e.g. in Normal so for standarddeviation value that will be 7.0)
elif name=='Machine2':
processingTime['distributionType']=str(names[1])
processingTime[str(aParameters[1])]=str(aParameterValue[1])
processingTime[str(bParameters[1])]=str(bParameterValue[1])
else:
continue
jsonFile = open('JSON_Topology10_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 Excel files =============================================#
C=Output()
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')
\ No newline at end of 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