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
5245ca43
Commit
5245ca43
authored
Jun 16, 2014
by
panos
Committed by
Jérome Perrin
Jun 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New example added with extraction data from a database
parent
0193fcc7
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
477 additions
and
0 deletions
+477
-0
dream/KnowledgeExtraction/KEtool_examples/ParallelStations/JSON_example.json
...action/KEtool_examples/ParallelStations/JSON_example.json
+130
-0
dream/KnowledgeExtraction/KEtool_examples/ParallelStations/ParallelStations_example.py
...ool_examples/ParallelStations/ParallelStations_example.py
+165
-0
dream/KnowledgeExtraction/KEtool_examples/ParallelStations/test_database.sql
...action/KEtool_examples/ParallelStations/test_database.sql
+182
-0
No files found.
dream/KnowledgeExtraction/KEtool_examples/ParallelStations/JSON_example.json
0 → 100644
View file @
5245ca43
{
"_class"
:
"Dream.Simulation"
,
"edges"
:
{
"0"
:
[
"W1"
,
"M1"
,
{}
],
"1"
:
[
"W1"
,
"M2"
,
{}
],
"2"
:
[
"S1"
,
"DummyQ"
,
{}
],
"3"
:
[
"M1"
,
"E1"
,
{}
],
"4"
:
[
"M2"
,
"E1"
,
{}
],
"5"
:
[
"DummyQ"
,
"Q1"
,
{}
],
"6"
:
[
"Q1"
,
"M1"
,
{}
],
"7"
:
[
"Q1"
,
"M2"
,
{}
]
},
"general"
:
{
"_class"
:
"Dream.Configuration"
,
"confidenceLevel"
:
"0.95"
,
"maxSimTime"
:
"1440"
,
"numberOfReplications"
:
"1"
,
"trace"
:
"No"
},
"nodes"
:
{
"DummyQ"
:
{
"_class"
:
"Dream.Queue"
,
"capacity"
:
1
,
"isDummy"
:
"1"
,
"left"
:
0.639751552795031
,
"name"
:
"DummyQ"
,
"top"
:
0.7720588235294118
},
"E1"
:
{
"_class"
:
"Dream.Exit"
,
"left"
:
0.40993788819875776
,
"name"
:
"Stock"
,
"top"
:
0.04656862745098034
},
"M1"
:
{
"_class"
:
"Dream.Machine"
,
"left"
:
0.6335403726708074
,
"name"
:
"MILL1"
,
"failures"
:
{
"MTTF"
:
{
},
"MTTR"
:
{
}
,
"repairman"
:
"W1"
},
"processingTime"
:
{
},
"top"
:
0.40931372549019607
},
"M2"
:
{
"_class"
:
"Dream.Machine"
,
"failures"
:
{
"MTTF"
:
{
},
"MTTR"
:
{
}
,
"repairman"
:
"W1"
},
"left"
:
0.1863354037267081
,
"name"
:
"MILL2"
,
"processingTime"
:
{
},
"top"
:
0.40931372549019607
},
"Q1"
:
{
"_class"
:
"Dream.Queue"
,
"capacity"
:
1
,
"isDummy"
:
"0"
,
"left"
:
0.639751552795031
,
"name"
:
"Q1"
,
"top"
:
0.5906862745098039
},
"S1"
:
{
"_class"
:
"Dream.Source"
,
"entity"
:
"Dream.Part"
,
"interarrivalTime"
:
{
"distributionType"
:
"Fixed"
,
"mean"
:
0.5
},
"left"
:
0.639751552795031
,
"name"
:
"Raw Material"
,
"top"
:
0.9534313725490196
},
"W1"
:
{
"_class"
:
"Dream.Repairman"
,
"capacity"
:
1
,
"left"
:
0.18012422360248448
,
"name"
:
"W1"
,
"top"
:
0.5906862745098039
}
}
}
\ No newline at end of file
dream/KnowledgeExtraction/KEtool_examples/ParallelStations/ParallelStations_example.py
0 → 100644
View file @
5245ca43
'''
Created on 15 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
Transformations
import
BasicTransformations
from
DistributionFitting
import
DistFittest
from
DistributionFitting
import
Distributions
from
ExcelOutput
import
Output
import
pyodbc
import
json
#================================= Extract data from the database ==========================================#
cnxn
=
pyodbc
.
connect
(
"Driver={MySQL ODBC 3.51 Driver};SERVER=localhost; PORT=3306;DATABASE=test_database;UID=root; PASSWORD=Pitheos10; "
)
cursor1
=
cnxn
.
cursor
()
cursor2
=
cnxn
.
cursor
()
cursor3
=
cnxn
.
cursor
()
a
=
cursor1
.
execute
(
"""
select prod_code, stat_code,emp_no, TIMEIN, TIMEOUT
from production_status
"""
)
MILL1
=
[]
MILL2
=
[]
for
j
in
range
(
a
.
rowcount
):
#get the next line
ind1
=
a
.
fetchone
()
if
ind1
.
stat_code
==
'MILL1'
:
procTime
=
[]
procTime
.
insert
(
0
,
ind1
.
TIMEIN
)
procTime
.
insert
(
1
,
ind1
.
TIMEOUT
)
MILL1
.
append
(
procTime
)
elif
ind1
.
stat_code
==
'MILL2'
:
procTime
=
[]
procTime
.
insert
(
0
,
ind1
.
TIMEIN
)
procTime
.
insert
(
1
,
ind1
.
TIMEOUT
)
MILL2
.
append
(
procTime
)
else
:
continue
transform
=
BasicTransformations
()
procTime_MILL1
=
[]
for
elem
in
MILL1
:
t1
=
[]
t2
=
[]
t1
.
append
(((
elem
[
0
].
hour
)
*
60
)
*
60
+
(
elem
[
0
].
minute
)
*
60
+
elem
[
0
].
second
)
t2
.
append
(((
elem
[
1
].
hour
)
*
60
)
*
60
+
(
elem
[
1
].
minute
)
*
60
+
elem
[
1
].
second
)
dt
=
transform
.
subtraction
(
t2
,
t1
)
procTime_MILL1
.
append
(
dt
[
0
])
procTime_MILL2
=
[]
for
elem
in
MILL2
:
t1
=
[]
t2
=
[]
t1
.
append
(((
elem
[
0
].
hour
)
*
60
)
*
60
+
(
elem
[
0
].
minute
)
*
60
+
elem
[
0
].
second
)
t2
.
append
(((
elem
[
1
].
hour
)
*
60
)
*
60
+
(
elem
[
1
].
minute
)
*
60
+
elem
[
1
].
second
)
dt
=
transform
.
subtraction
(
t2
,
t1
)
procTime_MILL2
.
append
(
dt
[
0
])
b
=
cursor2
.
execute
(
"""
select stat_code, MTTF_hour
from failures
"""
)
c
=
cursor3
.
execute
(
"""
select stat_code, MTTR_hour
from repairs
"""
)
MTTF_MILL1
=
[]
MTTF_MILL2
=
[]
for
j
in
range
(
b
.
rowcount
):
#get the next line
ind2
=
b
.
fetchone
()
if
ind2
.
stat_code
==
'MILL1'
:
MTTF_MILL1
.
append
(
ind2
.
MTTF_hour
)
elif
ind2
.
stat_code
==
'MILL2'
:
MTTF_MILL2
.
append
(
ind2
.
MTTF_hour
)
else
:
continue
MTTR_MILL1
=
[]
MTTR_MILL2
=
[]
for
j
in
range
(
c
.
rowcount
):
#get the next line
ind3
=
c
.
fetchone
()
if
ind3
.
stat_code
==
'MILL1'
:
MTTR_MILL1
.
append
(
ind3
.
MTTR_hour
)
elif
ind3
.
stat_code
==
'MILL2'
:
MTTR_MILL2
.
append
(
ind3
.
MTTR_hour
)
else
:
continue
#======================= Fit data to statistical distributions ================================#
dist_proctime
=
DistFittest
()
distProcTime_MILL1
=
dist_proctime
.
ks_test
(
procTime_MILL1
)
distProcTime_MILL2
=
dist_proctime
.
ks_test
(
procTime_MILL2
)
dist_MTTF
=
Distributions
()
dist_MTTR
=
Distributions
()
distMTTF_MILL1
=
dist_MTTF
.
Weibull_distrfit
(
MTTF_MILL1
)
distMTTF_MILL2
=
dist_MTTF
.
Weibull_distrfit
(
MTTF_MILL2
)
distMTTR_MILL1
=
dist_MTTR
.
Poisson_distrfit
(
MTTR_MILL1
)
distMTTR_MILL2
=
dist_MTTR
.
Poisson_distrfit
(
MTTR_MILL2
)
#======================= Output preparation: output the updated values in the JSON file of this example ================================#
jsonFile
=
open
(
'JSON_example.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'
MTTF_Nodes
=
nodes
[
element
].
get
(
'MTTF'
,{})
#It creates a variable that gets the element attribute 'MTTF'
MTTR_Nodes
=
nodes
[
element
].
get
(
'MTTR'
,{})
#It creates a variable that gets the element attribute 'MTTR'
if
element
==
'M1'
:
nodes
[
'M1'
][
'processingTime'
]
=
distProcTime_MILL1
#It checks using if syntax if the element is 'M1'
nodes
[
'M1'
][
'failures'
][
'MTTF'
]
=
distMTTF_MILL1
nodes
[
'M1'
][
'failures'
][
'MTTR'
]
=
distMTTR_MILL1
elif
element
==
'M2'
:
nodes
[
'M2'
][
'processingTime'
]
=
distProcTime_MILL2
#It checks using if syntax if the element is 'M2'
nodes
[
'M2'
][
'failures'
][
'MTTF'
]
=
distMTTF_MILL2
nodes
[
'M2'
][
'failures'
][
'MTTR'
]
=
distMTTR_MILL2
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
(
procTime_MILL1
,
'procTimeMILL1_StatResults.xls'
)
export
.
PrintStatisticalMeasures
(
procTime_MILL2
,
'procTimeMILL2_StatResults.xls'
)
export
.
PrintStatisticalMeasures
(
MTTF_MILL1
,
'MTTFMILL1_StatResults.xls'
)
export
.
PrintStatisticalMeasures
(
MTTF_MILL2
,
'MTTFMILL2_StatResults.xls'
)
export
.
PrintStatisticalMeasures
(
MTTR_MILL1
,
'MTTRMILL1_StatResults.xls'
)
export
.
PrintStatisticalMeasures
(
MTTR_MILL2
,
'MTTRMILL2_StatResults.xls'
)
export
.
PrintDistributionFit
(
procTime_MILL1
,
'procTimeMILL1_DistFitResults.xls'
)
export
.
PrintDistributionFit
(
procTime_MILL2
,
'procTimeMILL2_DistFitResults.xls'
)
export
.
PrintDistributionFit
(
MTTF_MILL1
,
'MTTFMILL1_DistFitResults.xls'
)
export
.
PrintDistributionFit
(
MTTF_MILL2
,
'MTTFMILL2_DistFitResults.xls'
)
export
.
PrintDistributionFit
(
MTTR_MILL1
,
'MTTRMILL1_DistFitResults.xls'
)
export
.
PrintDistributionFit
(
MTTR_MILL2
,
'MTTRMILL2_DistFitResults.xls'
)
\ No newline at end of file
dream/KnowledgeExtraction/KEtool_examples/ParallelStations/test_database.sql
0 → 100644
View file @
5245ca43
This diff is collapsed.
Click to expand it.
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