Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
3fc5f7e3
Commit
3fc5f7e3
authored
Apr 17, 2015
by
Georgios Dagkakis
Committed by
panos
Apr 30, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
example that got damaged in rebase recovered
parent
01b66b72
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
34 deletions
+25
-34
dream/KnowledgeExtraction/KEtool_examples/TwoParallelStations/TwoParallelStations_example.py
...amples/TwoParallelStations/TwoParallelStations_example.py
+25
-34
No files found.
dream/KnowledgeExtraction/KEtool_examples/TwoParallelStations/TwoParallelStations_example.py
View file @
3fc5f7e3
...
...
@@ -31,15 +31,16 @@ from dream.KnowledgeExtraction.JSONOutput import JSONOutput
import
xlrd
import
json
import
dream.simulation.LineGenerationJSON
as
ManPyMain
#import ManPy main JSON script
import
os
def
main
(
test
=
0
,
ExcelFileName
=
'
KEtool_examples/TwoParallelStations/
inputData.xls'
,
JSONFileName
=
'
KEtool_examples/TwoParallelStations/JSON_Two
ParallelStations.json'
,
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
(
ExcelFileName
)
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
...
...
@@ -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 ================================#
jsonFile
=
open
(
'JSON_ParallelStations.json'
,
'r'
)
#It opens the JSON file
jsonFile
=
open
(
JSONFileName
,
'r'
)
#It opens the JSON file
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
)
nodes
=
data
[
'graph'
][
'node'
]
#It creates a variable that holds the 'nodes' dictionary
procTimeM1dict
=
{}
procTimeM2dict
=
{}
dist
=
M1ProcTime_dist
[
'distributionType'
]
d
el
M1ProcTime_dist
[
'distributionType'
]
procTimeM1dict
[
dist
]
=
M1ProcTime_dist
exportJSON
=
JSONOutput
()
stationId1
=
'St1'
stationId2
=
'St2'
d
ata1
=
exportJSON
.
ProcessingTimes
(
data
,
stationId1
,
M1ProcTime_dist
)
data2
=
exportJSON
.
ProcessingTimes
(
data1
,
stationId2
,
M2ProcTime_dist
)
dist
=
M2ProcTime_dist
[
'distributionType'
]
del
M2ProcTime_dist
[
'distributionType'
]
procTimeM2dict
[
dist
]
=
M2ProcTime_dist
#================================ Call ManPy and run the simulation model =============================================#
#calls ManPy main script with the input
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
()
stationId1
=
'St1'
stationId2
=
'St2'
data1
=
exportJSON
.
ProcessingTimes
(
data
,
stationId1
,
M1ProcTime_dist
)
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
#=================== 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 ==========================#
# save the KE output in xls
export
=
Output
()
# save KE results in Excel
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 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
jsonFile
=
open
(
'ManPyOutput.json'
,
"w"
)
#It opens the JSON file
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment