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
066c5fca
Commit
066c5fca
authored
Dec 04, 2013
by
Georgios Dagkakis
Committed by
Sebastien Robin
Dec 11, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test script to pass a more realistic method to the generator. Still work to be done in this
parent
878ceeb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
4 deletions
+53
-4
dream/simulation/TestGeneratorMainScript.py
dream/simulation/TestGeneratorMainScript.py
+53
-4
No files found.
dream/simulation/TestGeneratorMainScript.py
View file @
066c5fca
...
...
@@ -25,19 +25,68 @@ Created on 4 Dec 2013
test script to test the generator
'''
from
SimPy.Simulation
import
now
,
activate
,
simulate
from
SimPy.Simulation
import
now
,
activate
,
simulate
,
infinity
,
initialize
from
EventGenerator
import
EventGenerator
from
Machine
import
Machine
from
Source
import
Source
from
Exit
import
Exit
from
Part
import
Part
from
Queue
import
Queue
from
Globals
import
G
import
ExcelHandler
def
myMethod
():
print
"I was invoked at"
,
now
()
def
move
():
if
len
(
Q2
.
getActiveObjectQueue
())
>
70
:
Q2
.
next
=
[
E
]
E
.
previous
=
[
Q2
]
for
i
in
range
(
20
):
E
.
getEntity
()
Q2
.
next
=
[]
E
.
previous
=
[]
G
.
trace
=
"Yes"
S
=
Source
(
'S1'
,
'Source'
,
mean
=
1
,
item
=
Part
)
M1
=
Machine
(
'M1'
,
'Machine1'
,
mean
=
0.75
)
Q1
=
Queue
(
'Q1'
,
'Queue1'
,
capacity
=
infinity
)
M2
=
Machine
(
'M2'
,
'Machine2'
,
mean
=
1.5
)
Q2
=
Queue
(
'Q2'
,
'Queue2'
,
capacity
=
infinity
)
E
=
Exit
(
'E1'
,
'Exit'
)
#define predecessors and successors for the objects
S
.
defineRouting
([
M1
])
M1
.
defineRouting
([
S
],[
Q1
])
Q1
.
defineRouting
([
M1
],[
M2
])
M2
.
defineRouting
([
Q1
],[
Q2
])
Q2
.
defineRouting
([
M2
])
EG
=
EventGenerator
(
start
=
60
,
interval
=
60
,
method
=
move
)
G
.
ObjList
=
[
S
,
M1
,
M2
,
E
,
Q1
,
Q2
,
EG
]
EG
=
EventGenerator
(
start
=
60
,
interval
=
60
,
method
=
myMethod
)
activate
(
EG
,
EG
.
run
())
simulate
(
until
=
480
)
#run the simulation
initialize
()
#initialize the simulation (SimPy method)
for
object
in
G
.
ObjList
:
object
.
initialize
()
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
maxSimTime
=
480
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
ExcelHandler
.
outputTrace
(
'TRACE'
)
print
"the system produced"
,
E
.
numOfExits
,
"parts"
print
"the waiting ratio of"
,
M1
.
objName
,
"is"
,
(
M1
.
totalWaitingTime
/
G
.
maxSimTime
)
*
100
,
"%"
print
"the waiting ratio of"
,
M2
.
objName
,
"is"
,
(
M2
.
totalWaitingTime
/
G
.
maxSimTime
)
*
100
,
"%"
...
...
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