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
2bcb75b2
Commit
2bcb75b2
authored
Jun 17, 2013
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
results outputted also in a JSON file
parent
b6451406
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
129 additions
and
6 deletions
+129
-6
DREAM/dream/simulation/Assembly.py
DREAM/dream/simulation/Assembly.py
+12
-1
DREAM/dream/simulation/Conveyer.py
DREAM/dream/simulation/Conveyer.py
+12
-0
DREAM/dream/simulation/Dismantle.py
DREAM/dream/simulation/Dismantle.py
+13
-1
DREAM/dream/simulation/Exit.py
DREAM/dream/simulation/Exit.py
+13
-0
DREAM/dream/simulation/Globals.py
DREAM/dream/simulation/Globals.py
+5
-1
DREAM/dream/simulation/LineGenerationJSON.py
DREAM/dream/simulation/LineGenerationJSON.py
+38
-2
DREAM/dream/simulation/Machine.py
DREAM/dream/simulation/Machine.py
+15
-0
DREAM/dream/simulation/Queue.py
DREAM/dream/simulation/Queue.py
+5
-0
DREAM/dream/simulation/Repairman.py
DREAM/dream/simulation/Repairman.py
+12
-1
DREAM/dream/simulation/Source.py
DREAM/dream/simulation/Source.py
+4
-0
No files found.
DREAM/dream/simulation/Assembly.py
View file @
2bcb75b2
...
...
@@ -239,7 +239,18 @@ class Assembly(Process):
G
.
outputIndex
+=
1
G
.
outputIndex
+=
1
#outputs results to JSON File
def
outputResultsJSON
(
self
):
from
Globals
import
G
if
(
G
.
numberOfReplications
==
1
):
#if we had just one replication output the results to excel
json
=
{}
json
[
'_class'
]
=
'Dream.Assembly'
;
json
[
'id'
]
=
str
(
self
.
id
)
json
[
'results'
]
=
{}
json
[
'results'
][
'working_ratio'
]
=
100
*
self
.
totalWorkingTime
/
G
.
maxSimTime
json
[
'results'
][
'blockage_ratio'
]
=
100
*
self
.
totalBlockageTime
/
G
.
maxSimTime
json
[
'results'
][
'waiting_ratio'
]
=
100
*
self
.
totalWaitingTime
/
G
.
maxSimTime
G
.
outputJSON
[
'coreObject'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
...
...
DREAM/dream/simulation/Conveyer.py
View file @
2bcb75b2
...
...
@@ -317,6 +317,18 @@ class Conveyer(Process):
G
.
outputIndex
+=
1
G
.
outputIndex
+=
1
#outputs results to JSON File
def
outputResultsJSON
(
self
):
from
Globals
import
G
if
(
G
.
numberOfReplications
==
1
):
#if we had just one replication output the results to excel
json
=
{}
json
[
'_class'
]
=
'Dream.Conveyer'
;
json
[
'id'
]
=
str
(
self
.
id
)
json
[
'results'
]
=
{}
json
[
'results'
][
'working_ratio'
]
=
100
*
self
.
totalWorkingTime
/
G
.
maxSimTime
json
[
'results'
][
'blockage_ratio'
]
=
100
*
self
.
totalBlockageTime
/
G
.
maxSimTime
json
[
'results'
][
'waiting_ratio'
]
=
100
*
self
.
totalWaitingTime
/
G
.
maxSimTime
G
.
outputJSON
[
'coreObject'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
...
...
DREAM/dream/simulation/Dismantle.py
View file @
2bcb75b2
...
...
@@ -273,7 +273,19 @@ class Dismantle(Process):
G
.
outputIndex
+=
1
G
.
outputIndex
+=
1
#outputs results to JSON File
def
outputResultsJSON
(
self
):
from
Globals
import
G
if
(
G
.
numberOfReplications
==
1
):
#if we had just one replication output the results to excel
json
=
{}
json
[
'_class'
]
=
'Dream.Dismantle'
;
json
[
'id'
]
=
str
(
self
.
id
)
json
[
'results'
]
=
{}
json
[
'results'
][
'working_ratio'
]
=
100
*
self
.
totalWorkingTime
/
G
.
maxSimTime
json
[
'results'
][
'blockage_ratio'
]
=
100
*
self
.
totalBlockageTime
/
G
.
maxSimTime
json
[
'results'
][
'waiting_ratio'
]
=
100
*
self
.
totalWaitingTime
/
G
.
maxSimTime
G
.
outputJSON
[
'coreObject'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def
checkIfArrayHasDifValues
(
self
,
array
):
...
...
DREAM/dream/simulation/Exit.py
View file @
2bcb75b2
...
...
@@ -183,6 +183,19 @@ class Exit(Process):
G
.
outputSheet
.
write
(
G
.
outputIndex
,
3
,
self
.
TaktTime
[
0
])
G
.
outputIndex
+=
1
G
.
outputIndex
+=
1
#outputs results to JSON File
def
outputResultsJSON
(
self
):
from
Globals
import
G
if
(
G
.
numberOfReplications
==
1
):
#if we had just one replication output the results to excel
json
=
{}
json
[
'_class'
]
=
'Dream.Exit'
;
json
[
'id'
]
=
str
(
self
.
id
)
json
[
'results'
]
=
{}
json
[
'results'
][
'throughput'
]
=
self
.
numOfExits
json
[
'results'
][
'lifespan'
]
=
((
self
.
totalLifespan
)
/
self
.
numOfExits
)
/
G
.
Base
json
[
'results'
][
'takt_time'
]
=
((
self
.
totalTaktTime
)
/
self
.
numOfExits
)
/
G
.
Base
G
.
outputJSON
[
'coreObject'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
...
...
DREAM/dream/simulation/Globals.py
View file @
2bcb75b2
...
...
@@ -36,9 +36,13 @@ class G:
traceSheet
=
traceFile
.
add_sheet
(
'sheet '
+
str
(
sheetIndex
),
cell_overwrite_ok
=
True
)
#create excel sheet
#
the output excel
#
variables for excel output
outputIndex
=
0
#index that shows in what row we are
sheetIndex
=
1
#index that shows in what sheet we are
outputFile
=
xlwt
.
Workbook
()
#create excel file
outputSheet
=
outputFile
.
add_sheet
(
'sheet '
+
str
(
sheetIndex
),
cell_overwrite_ok
=
True
)
#create excel sheet
#variables for json output
outputJSON
=
{}
outputJSONFile
=
None
DREAM/dream/simulation/LineGenerationJSON.py
View file @
2bcb75b2
...
...
@@ -297,6 +297,10 @@ def main(argv=[]):
for
core_object
in
G
.
ObjList
:
core_object
.
postProcessing
(
G
.
maxSimTime
)
#carry on the post processing operations for every model resource in the topology
for
model_resource
in
G
.
RepairmanList
:
model_resource
.
postProcessing
(
G
.
maxSimTime
)
#output trace to excel
if
(
G
.
trace
==
"Yes"
):
G
.
traceFile
.
save
(
'trace'
+
str
(
i
+
1
)
+
'.xls'
)
...
...
@@ -308,13 +312,45 @@ def main(argv=[]):
G
.
outputSheet
.
write
(
G
.
outputIndex
,
0
,
"Execution Time"
)
G
.
outputSheet
.
write
(
G
.
outputIndex
,
1
,
str
(
time
.
time
()
-
start
)
+
" seconds"
)
G
.
outputIndex
+=
2
G
.
outputJSONFile
=
open
(
'outputJSON.json'
,
mode
=
'w'
)
G
.
outputJSON
[
'_class'
]
=
'Dream.Simulation'
;
G
.
outputJSON
[
'general'
]
=
{};
G
.
outputJSON
[
'general'
][
'_class'
]
=
'Dream.Configuration'
;
G
.
outputJSON
[
'general'
][
'totalExecutionTime'
]
=
(
time
.
time
()
-
start
);
G
.
outputJSON
[
'modelResource'
]
=
[];
G
.
outputJSON
[
'coreObject'
]
=
[];
#output data to JSON for every object in the topology
for
core_object
in
G
.
ObjList
:
try
:
core_object
.
outputResultsJSON
()
except
AttributeError
:
pass
#output data to JSON for every resource in the topology
for
model_resource
in
G
.
RepairmanList
:
try
:
model_resource
.
outputResultsJSON
()
except
AttributeError
:
pass
outputJSONString
=
str
(
str
(
G
.
outputJSON
))
outputJSONString
=
outputJSONString
.
replace
(
"'"
,
'"'
)
G
.
outputJSONFile
.
write
(
str
(
outputJSONString
))
#output data to excel for every object in the topology
for
core_object
in
G
.
ObjList
:
core_object
.
outputResultsXL
(
G
.
maxSimTime
)
#output data to excel for every resource in the topology
for
model_resource
in
G
.
RepairmanList
:
model_resource
.
outputResultsXL
(
G
.
maxSimTime
)
G
.
outputFile
.
save
(
"output.xls"
)
print
"execution time="
+
str
(
time
.
time
()
-
start
)
if
__name__
==
'__main__'
:
main
()
main
()
DREAM/dream/simulation/Machine.py
View file @
2bcb75b2
...
...
@@ -13,6 +13,7 @@ from SimPy.Simulation import activate, passivate, waituntil, now, hold
from
Failure
import
Failure
from
RandomNumberGenerator
import
RandomNumberGenerator
import
scipy.stats
as
stat
import
sys
#the Machine object
class
Machine
(
Process
):
...
...
@@ -419,6 +420,20 @@ class Machine(Process):
G
.
outputIndex
+=
1
G
.
outputIndex
+=
1
#outputs results to JSON File
def
outputResultsJSON
(
self
):
from
Globals
import
G
if
(
G
.
numberOfReplications
==
1
):
#if we had just one replication output the results to excel
json
=
{}
json
[
'_class'
]
=
'Dream.Machine'
;
json
[
'id'
]
=
str
(
self
.
id
)
json
[
'results'
]
=
{}
json
[
'results'
][
'failure_ratio'
]
=
100
*
self
.
totalFailureTime
/
G
.
maxSimTime
json
[
'results'
][
'working_ratio'
]
=
100
*
self
.
totalWorkingTime
/
G
.
maxSimTime
json
[
'results'
][
'blockage_ratio'
]
=
100
*
self
.
totalBlockageTime
/
G
.
maxSimTime
json
[
'results'
][
'waiting_ratio'
]
=
100
*
self
.
totalWaitingTime
/
G
.
maxSimTime
G
.
outputJSON
[
'coreObject'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def
checkIfArrayHasDifValues
(
self
,
array
):
...
...
DREAM/dream/simulation/Queue.py
View file @
2bcb75b2
...
...
@@ -9,6 +9,7 @@ Models a FIFO queue where entities can wait in order to get into a server
from
SimPy.Simulation
import
*
#import sys
#the Queue object
class
Queue
(
Process
):
...
...
@@ -196,4 +197,8 @@ class Queue(Process):
#outputs data to "output.xls"
def
outputResultsXL
(
self
,
MaxSimtime
):
pass
#outputs results to JSON File
def
outputResultsJSON
(
self
):
pass
\ No newline at end of file
DREAM/dream/simulation/Repairman.py
View file @
2bcb75b2
...
...
@@ -83,7 +83,18 @@ class Repairman(object):
G
.
outputSheet
.
write
(
G
.
outputIndex
,
3
,
self
.
Waiting
[
0
])
G
.
outputIndex
+=
1
G
.
outputIndex
+=
1
#outputs results to JSON File
def
outputResultsJSON
(
self
):
from
Globals
import
G
if
(
G
.
numberOfReplications
==
1
):
#if we had just one replication output the results to excel
json
=
{}
json
[
'_class'
]
=
'Dream.Repairman'
;
json
[
'id'
]
=
str
(
self
.
id
)
json
[
'results'
]
=
{}
json
[
'results'
][
'working_ratio'
]
=
100
*
self
.
totalWorkingTime
/
G
.
maxSimTime
json
[
'results'
][
'waiting_ratio'
]
=
100
*
self
.
totalWaitingTime
/
G
.
maxSimTime
G
.
outputJSON
[
'modelResource'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
...
...
DREAM/dream/simulation/Source.py
View file @
2bcb75b2
...
...
@@ -139,3 +139,7 @@ class Source(Process):
#outputs data to "output.xls"
def
outputResultsXL
(
self
,
MaxSimtime
):
pass
#outputs results to JSON File
def
outputResultsJSON
(
self
):
pass
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