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
95b020d7
Commit
95b020d7
authored
Aug 18, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Globals given a runSimulation method
parent
1a2fc131
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
dream/simulation/Globals.py
dream/simulation/Globals.py
+70
-0
No files found.
dream/simulation/Globals.py
View file @
95b020d7
...
@@ -368,3 +368,73 @@ def getPhrase():
...
@@ -368,3 +368,73 @@ def getPhrase():
'conveyerFull'
:{
'phrase'
:
'is now Full, No of units:'
,
'suffix'
:
'(*)'
}}
'conveyerFull'
:{
'phrase'
:
'is now Full, No of units:'
,
'suffix'
:
'(*)'
}}
return
printKwrds
return
printKwrds
def
runSimulation
(
objectList
=
[],
maxSimTime
=
100
,
numberOfReplications
=
1
,
trace
=
'No'
,
seed
=
1
):
G
.
numberOfReplications
=
numberOfReplications
G
.
trace
=
trace
G
.
maxSimTime
=
float
(
maxSimTime
)
G
.
seed
=
seed
G
.
ObjList
=
[]
G
.
ObjectInterruptionList
=
[]
G
.
ObjectResourceList
=
[]
from
CoreObject
import
CoreObject
from
ObjectInterruption
import
ObjectInterruption
from
ObjectResource
import
ObjectResource
from
Entity
import
Entity
for
object
in
objectList
:
if
issubclass
(
object
.
__class__
,
CoreObject
):
G
.
ObjList
.
append
(
object
)
elif
issubclass
(
object
.
__class__
,
ObjectInterruption
):
G
.
ObjectInterruptionList
.
append
(
object
)
elif
issubclass
(
object
.
__class__
,
ObjectResource
):
G
.
ObjectResourceList
.
append
(
object
)
#run the replications
for
i
in
range
(
G
.
numberOfReplications
):
G
.
seed
+=
1
#increment the seed so that we get different random numbers in each run.
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
G
.
EntityList
=
[]
for
object
in
objectList
:
if
issubclass
(
object
.
__class__
,
Entity
):
G
.
EntityList
.
append
(
object
)
#initialize all the objects
for
object
in
G
.
ObjList
+
G
.
ObjectInterruptionList
+
G
.
ObjectResourceList
+
G
.
EntityList
:
object
.
initialize
()
#activate all the objects
for
object
in
G
.
ObjList
+
G
.
ObjectInterruptionList
:
G
.
env
.
process
(
object
.
run
())
#set the WIP
setWIP
(
G
.
EntityList
)
G
.
env
.
run
(
until
=
G
.
maxSimTime
)
#run the simulation
# identify from the exits what is the time that the last entity has ended.
endList
=
[]
from
Exit
import
Exit
for
object
in
G
.
ObjList
:
if
issubclass
(
object
.
__class__
,
Exit
):
endList
.
append
(
object
.
timeLastEntityLeft
)
# identify the time of the last event
if
G
.
env
.
now
==
float
(
'inf'
):
G
.
maxSimTime
=
float
(
max
(
endList
))
# do not let G.maxSimTime=0 so that there will be no crash
if
G
.
maxSimTime
==
0
:
print
"simulation ran for 0 time, something may have gone wrong"
import
sys
sys
.
exit
()
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
+
G
.
ObjectResourceList
:
object
.
postProcessing
()
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