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
85b7051e
Commit
85b7051e
authored
Mar 10, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AssemblyLine example also updated and added in test
parent
7a0a1f88
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
58 deletions
+69
-58
dream/simulation/Examples/AssemblyLine.py
dream/simulation/Examples/AssemblyLine.py
+35
-29
dream/simulation/Examples/TwoServers.py
dream/simulation/Examples/TwoServers.py
+27
-27
dream/tests/testSimulationExamples.py
dream/tests/testSimulationExamples.py
+7
-2
No files found.
dream/simulation/Examples/AssemblyLine.py
View file @
85b7051e
...
...
@@ -3,13 +3,13 @@ from dream.simulation.imports import simulate, activate, initialize
#define the objects of the model
Frame
.
capacity
=
4
Sp
=
Source
(
'SP'
,
'Parts'
,
mean
=
0.5
,
entity
=
'Dream.Part'
)
Sf
=
Source
(
'SF'
,
'Frames'
,
mean
=
2
,
entity
=
'Dream.Frame'
)
M
=
Machine
(
'M'
,
'Machine'
,
mean
=
0.25
)
A
=
Assembly
(
'A'
,
'Assembly'
,
mean
=
2
)
Sp
=
Source
(
'SP'
,
'Parts'
,
interarrivalTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
0.5
}
,
entity
=
'Dream.Part'
)
Sf
=
Source
(
'SF'
,
'Frames'
,
interarrivalTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
2
}
,
entity
=
'Dream.Frame'
)
M
=
Machine
(
'M'
,
'Machine'
,
processingTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
0.25
}
)
A
=
Assembly
(
'A'
,
'Assembly'
,
processingTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
2
}
)
E
=
Exit
(
'E1'
,
'Exit'
)
F
=
Failure
(
victim
=
M
,
distribution
Type
=
'Fixed'
,
MTTF
=
60
,
MTTR
=
5
)
F
=
Failure
(
victim
=
M
,
distribution
=
{
'distributionType'
:
'Fixed'
,
'MTTF'
:
60
,
'MTTR'
:
5
}
)
G
.
ObjList
=
[
Sp
,
Sf
,
M
,
A
,
E
]
#add all the objects in G.ObjList so that they can be easier accessed later
...
...
@@ -22,31 +22,37 @@ A.defineRouting([Sp,Sf],[M])
M
.
defineRouting
([
A
],[
E
])
E
.
defineRouting
([
M
])
initialize
()
#initialize the simulation (SimPy method)
def
main
():
initialize
()
#initialize the simulation (SimPy method)
for
object
in
G
.
ObjList
:
object
.
initialize
()
for
objectInterruption
in
G
.
ObjectInterruptionList
:
objectInterruption
.
initialize
()
for
object
in
G
.
ObjList
:
object
.
initialize
()
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
for
objectInterruption
in
G
.
ObjectInterruptionList
:
objectInterruption
.
initialize
()
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
for
objectInterruption
in
G
.
ObjectInterruptionList
:
activate
(
objectInterruption
,
objectInterruption
.
run
())
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
for
objectInterruption
in
G
.
ObjectInterruptionList
:
activate
(
objectInterruption
,
objectInterruption
.
run
())
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
()
#print the results
print
"the system produced"
,
E
.
numOfExits
,
"frames"
print
"the working ratio of"
,
A
.
objName
,
"is"
,
(
A
.
totalWorkingTime
/
G
.
maxSimTime
)
*
100
,
"%"
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
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
()
#print the results
print
"the system produced"
,
E
.
numOfExits
,
"frames"
working_ratio
=
(
A
.
totalWorkingTime
/
G
.
maxSimTime
)
*
100
print
"the working ratio of"
,
A
.
objName
,
"is"
,
working_ratio
,
"%"
return
{
"frames"
:
E
.
numOfExits
,
"working_ratio"
:
working_ratio
}
if
__name__
==
'__main__'
:
main
()
dream/simulation/Examples/TwoServers.py
View file @
85b7051e
...
...
@@ -25,42 +25,42 @@ Q.defineRouting([M1],[M2])
M2
.
defineRouting
([
Q
],[
E
])
E
.
defineRouting
([
M2
])
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
R
.
initialize
()
def
main
():
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
R
.
initialize
()
for
object
in
G
.
ObjList
:
object
.
initialize
()
for
object
in
G
.
ObjList
:
object
.
initialize
()
for
objectInterruption
in
G
.
ObjectInterruptionList
:
objectInterruption
.
initialize
()
for
objectInterruption
in
G
.
ObjectInterruptionList
:
objectInterruption
.
initialize
()
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
for
objectInterruption
in
G
.
ObjectInterruptionList
:
activate
(
objectInterruption
,
objectInterruption
.
run
())
for
objectInterruption
in
G
.
ObjectInterruptionList
:
activate
(
objectInterruption
,
objectInterruption
.
run
())
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
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
()
R
.
postProcessing
()
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
R
.
postProcessing
()
#print the results
print
"the system produced"
,
E
.
numOfExits
,
"parts"
blockage_ratio
=
(
M1
.
totalBlockageTime
/
G
.
maxSimTime
)
*
100
working_ratio
=
(
R
.
totalWorkingTime
/
G
.
maxSimTime
)
*
100
print
"the blockage ratio of"
,
M1
.
objName
,
"is"
,
blockage_ratio
,
"%"
print
"the working ratio of"
,
R
.
objName
,
"is"
,
working_ratio
,
"%"
return
{
"parts"
:
E
.
numOfExits
,
#print the results
print
"the system produced"
,
E
.
numOfExits
,
"parts"
blockage_ratio
=
(
M1
.
totalBlockageTime
/
G
.
maxSimTime
)
*
100
working_ratio
=
(
R
.
totalWorkingTime
/
G
.
maxSimTime
)
*
100
print
"the blockage ratio of"
,
M1
.
objName
,
"is"
,
blockage_ratio
,
"%"
print
"the working ratio of"
,
R
.
objName
,
"is"
,
working_ratio
,
"%"
return
{
"parts"
:
E
.
numOfExits
,
"blockage_ratio"
:
blockage_ratio
,
"working_ratio"
:
working_ratio
}
...
...
dream/tests/testSimulationExamples.py
View file @
85b7051e
...
...
@@ -38,5 +38,10 @@ class SimulationExamples(TestCase):
from
dream.simulation.Examples.TwoServers
import
main
result
=
main
()
self
.
assertEquals
(
result
[
'parts'
],
732
)
self
.
assertTrue
(
78
<
result
[
"blockage_ratio"
]
<
79
)
self
.
assertTrue
(
26
<
result
[
"working_ratio"
]
<
27
)
self
.
assertTrue
(
78.17
<
result
[
"blockage_ratio"
]
<
78.18
)
self
.
assertTrue
(
26.73
<
result
[
"working_ratio"
]
<
27.74
)
from
dream.simulation.Examples.AssemblyLine
import
main
result
=
main
()
self
.
assertEquals
(
result
[
'frames'
],
664
)
self
.
assertTrue
(
92.36
<
result
[
"working_ratio"
]
<
93.37
)
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