Commit f78b0779 authored by panos's avatar panos

Insert new example wikth parallel stations

parent 84b3439e
{
"capacity_by_project_spreadsheet": [
[
"Project Name",
"Sequence",
"Capacity Requirements"
],
[
null,
null,
null
]
],
"capacity_by_station_spreadsheet": [
[
"Machine",
"Day 0",
"Day 1",
"Day 2",
"Day 3",
null
],
[
null,
null,
null,
null,
null,
null
]
],
"edges": {
"con_10": [
"Q1",
"St1",
{}
],
"con_15": [
"Q1",
"St2",
{}
],
"con_20": [
"St1",
"E1",
{}
],
"con_25": [
"St2",
"E1",
{}
],
"con_5": [
"S1",
"Q1",
{}
]
},
"general": {
"confidenceLevel": 0.95,
"currentDate": "2014/06/16",
"ke_url": "http://git.erp5.org/gitweb/dream.git/blob_plain/HEAD:/dream/KnowledgeExtraction/Mockup_Processingtimes.xls",
"maxSimTime": 100,
"numberOfReplications": 10,
"processTimeout": 10,
"seed": "",
"throughputTarget": 10,
"trace": "No"
},
"nodes": {
"E1": {
"_class": "Dream.Exit",
"element_id": "DreamNode_5",
"name": "Exit"
},
"Q1": {
"_class": "Dream.Queue",
"capacity": 1,
"element_id": "DreamNode_2",
"name": "Queue",
"schedulingRule": "FIFO"
},
"S1": {
"_class": "Dream.BatchSource",
"batchNumberOfUnits": 80,
"element_id": "DreamNode_1",
"entity": "Dream.Batch",
"interarrivalTime": {
"distributionType": "Fixed",
"mean": 1
},
"name": "Source"
},
"St1": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_3",
"failures": {
},
"name": "Milling1",
"processingTime": {
"distributionType": "Fixed",
"max": "",
"mean": 0.75,
"min": "",
"stdev": ""
}
},
"St2": {
"_class": "Dream.BatchScrapMachine",
"element_id": "DreamNode_4",
"failures": {
},
"name": "Milling2",
"processingTime": {
"distributionType": "Fixed",
"max": "",
"mean": 0.75,
"min": "",
"stdev": ""
}
}
},
"preference": {
"coordinates": {
"E1": {
"left": 0.838470725910555,
"top": 0.5011550303652008
},
"Q1": {
"left": 0.28592454969899506,
"top": 0.4898081240173095
},
"S1": {
"left": 0.053083038762682624,
"top": 0.48224351978538194
},
"St1": {
"left": 0.5199724933344594,
"top": 0.22882927801580868
},
"St2": {
"left": 0.5157499788874278,
"top": 0.7243108552070638
}
}
},
"shift_spreadsheet": [
[
"Day",
"Machines",
"Start",
"End"
],
[
null,
null,
null,
null
]
],
"wip_part_spreadsheet": [
[
"Order ID",
"Due Date",
"Priority",
"Project Manager",
"Part",
"Part Type",
"Sequence",
"Processing Times",
"Prerequisites Parts"
],
[
null,
null,
null,
null,
null,
null,
null,
null,
null
]
]
}
\ No newline at end of file
'''
Created on 20 Jun 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 DistributionFitting import DistFittest
from DistributionFitting import Distributions
from ImportExceldata import Import_Excel
from ExcelOutput import Output
from ReplaceMissingValues import HandleMissingValues
import xlrd
import json
import dream.simulation.LineGenerationJSON as ManPyMain #import ManPy main JSON script
#Read from the given directory the Excel document with the input data
workbook = xlrd.open_workbook('inputData.xls')
worksheets = workbook.sheet_names()
worksheet_ProcessingTimes = worksheets[0] #Define the worksheet with the Processing times data
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'
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
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