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
668a51d7
Commit
668a51d7
authored
Oct 31, 2013
by
Ioannis Papagiannopoulos
Committed by
Sebastien Robin
Nov 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test vs Topology22 added
parent
db943eaa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
15 deletions
+71
-15
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+23
-14
dream/test/dump/Topology22.result
dream/test/dump/Topology22.result
+47
-0
dream/test/testSimulationTopology.py
dream/test/testSimulationTopology.py
+1
-1
No files found.
dream/simulation/LineGenerationJSON.py
View file @
668a51d7
...
...
@@ -26,6 +26,9 @@ Created on 7 May 2013
main script. Reads data from JSON, generates and runs the simulation and prints the results to excel
'''
# ===========================================================================
# IMPORTS
# ===========================================================================
from
warnings
import
warn
import
logging
logger
=
logging
.
getLogger
(
"dream.platform"
)
...
...
@@ -81,15 +84,19 @@ from random import Random
import
sys
import
os.path
#reads general simulation inputs
# ===========================================================================
# reads general simulation inputs
# ===========================================================================
def
readGeneralInput
():
general
=
G
.
JSONData
[
'general'
]
G
.
numberOfReplications
=
int
(
general
.
get
(
'numberOfReplications'
,
'1'
))
G
.
maxSimTime
=
float
(
general
.
get
(
'maxSimTime'
,
'100'
))
general
=
G
.
JSONData
[
'general'
]
# read the dict with key 'general'
G
.
numberOfReplications
=
int
(
general
.
get
(
'numberOfReplications'
,
'1'
))
# read the number of replications
G
.
maxSimTime
=
float
(
general
.
get
(
'maxSimTime'
,
'100'
))
# get the maxSimTime
G
.
trace
=
general
.
get
(
'trace'
,
'No'
)
G
.
confidenceLevel
=
float
(
general
.
get
(
'confidenceLevel'
,
'0.95'
))
#creates the simulation objects
# ===========================================================================
# creates the simulation objects
# ===========================================================================
def
createObjects
():
json_data
=
G
.
JSONData
...
...
@@ -463,19 +470,19 @@ def main(argv=[], input_data=None):
if
input_data
is
None
:
# user passes the topology filename as first argument to the program
filename
=
argv
[
0
]
try
:
G
.
JSONFile
=
open
(
filename
,
"r"
)
try
:
# try to open the file with the inputs
G
.
JSONFile
=
open
(
filename
,
"r"
)
# global variable holding the file to be opened
except
IOError
:
print
"%s could not be open"
%
filename
return
"ERROR"
G
.
InputData
=
G
.
JSONFile
.
read
()
G
.
InputData
=
G
.
JSONFile
.
read
()
# pass the contents of the input file to the global var InputData
else
:
G
.
InputData
=
input_data
start
=
time
.
time
()
#
start counting execution time
start
=
time
.
time
()
#
start counting execution time
#read the input from the JSON file and create the line
G
.
JSONData
=
json
.
loads
(
G
.
InputData
)
G
.
JSONData
=
json
.
loads
(
G
.
InputData
)
# create the dictionary JSONData
readGeneralInput
()
createObjects
()
setTopology
()
...
...
@@ -492,10 +499,12 @@ def main(argv=[], input_data=None):
setWIP
()
activateObjects
()
#if the simulation is ran until no more events are scheduled, then we have to find the end time as the time the last entity ended.
# if the simulation is ran until no more events are scheduled,
# then we have to find the end time as the time the last entity ended.
if
G
.
maxSimTime
==-
1
:
simulate
(
until
=
infinity
)
#simulate until there are no more events. If someone does it for a model that has always events, then it will run forever!
#identify from the exits what is the time that the last entity has ended.
simulate
(
until
=
infinity
)
# simulate until there are no more events.
# If someone does it for a model that has always events, then it will run forever!
# identify from the exits what is the time that the last entity has ended.
endList
=
[]
for
exit
in
G
.
ExitList
:
endList
.
append
(
exit
.
timeLastEntityLeft
)
...
...
dream/test/dump/Topology22.result
0 → 100644
View file @
668a51d7
{
"elementList": [
{
"_class": "Dream.Exit",
"id": "E1",
"results": {
"throughput": 359,
"takt_time": 4.006963788300836,
"lifespan": 454.0
}
},
{
"_class": "Dream.Machine",
"id": "M1",
"results": {
"working_ratio": 50.06944444444444,
"blockage_ratio": 49.826388888888886,
"failure_ratio": 0.0,
"waiting_ratio": 0.10416666666666667
}
},
{
"_class": "Dream.Machine",
"id": "M2",
"results": {
"working_ratio": 99.89583333333333,
"blockage_ratio": 0.0,
"failure_ratio": 0.0,
"waiting_ratio": 0.10416666666666667
}
},
{
"_class": "Dream.Machine",
"id": "M3",
"results": {
"working_ratio": 24.930555555555557,
"blockage_ratio": 0.0,
"failure_ratio": 0.0,
"waiting_ratio": 75.06944444444444
}
}
],
"_class": "Dream.Simulation",
"general": {
"_class": "Dream.Configuration"
}
}
\ No newline at end of file
dream/test/testSimulationTopology.py
View file @
668a51d7
...
...
@@ -66,7 +66,7 @@ class SimulationTopology(TestCase):
self
.
assertEquals
(
stable_result
,
dump_result
,
"outputs are different"
)
# Automatically create a test method for every topology
for
x
in
range
(
1
,
2
2
):
for
x
in
range
(
1
,
2
3
):
def
getTestTopology
():
filename
=
"Topology%02i"
%
x
def
test_topology
(
self
):
...
...
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