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
006ea15d
Commit
006ea15d
authored
Aug 29, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new example using EventGenerator added
parent
0e2febe1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
dream/simulation/Examples/BalancingABuffer.py
dream/simulation/Examples/BalancingABuffer.py
+54
-0
No files found.
dream/simulation/Examples/BalancingABuffer.py
0 → 100644
View file @
006ea15d
from
dream.simulation.imports
import
Machine
,
Queue
,
Exit
,
Part
,
EventGenerator
from
dream.simulation.Globals
import
runSimulation
,
G
# method to check if the buffer is starving and refill it
def
balanceQueue
(
buffer
,
refillLevel
=
1
):
objectQueue
=
buffer
.
getActiveObjectQueue
()
numInQueue
=
len
(
objectQueue
)
print
'-'
*
50
print
'at time='
,
G
.
env
.
now
if
numInQueue
==
0
:
print
'buffer is starving, I will bring 5 parts'
for
i
in
range
(
refillLevel
):
partId
=
'P'
+
str
(
G
.
numOfParts
)
partName
=
'Part'
+
str
(
G
.
numOfParts
)
P
=
Part
(
partId
,
partName
,
currentStation
=
buffer
)
objectQueue
.
append
(
P
)
G
.
numOfParts
+=
1
# send a signal to the buffer that it can dispose an Entity
buffer
.
canDispose
.
succeed
(
G
.
env
.
now
)
else
:
print
'buffer has'
,
numInQueue
,
'parts. No need to bring more'
#define the objects of the model
Q
=
Queue
(
'Q1'
,
'Queue'
,
capacity
=
float
(
'inf'
))
M
=
Machine
(
'M1'
,
'Machine'
,
processingTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
6
})
E
=
Exit
(
'E1'
,
'Exit'
)
EV
=
EventGenerator
(
'EV'
,
'EntityCreator'
,
start
=
0
,
stop
=
float
(
'inf'
),
interval
=
20
,
method
=
balanceQueue
,
argumentDict
=
{
'buffer'
:
Q
,
'refillLevel'
:
5
})
G
.
numOfParts
=
0
#define predecessors and successors for the objects
Q
.
defineRouting
(
successorList
=
[
M
])
M
.
defineRouting
(
predecessorList
=
[
Q
],
successorList
=
[
E
])
E
.
defineRouting
(
predecessorList
=
[
M
])
def
main
():
# add all the objects in a list
objectList
=
[
Q
,
M
,
E
,
EV
]
# set the length of the experiment
maxSimTime
=
100.0
# call the runSimulation giving the objects and the length of the experiment
runSimulation
(
objectList
,
maxSimTime
)
#print the results
print
'='
*
50
print
"the system produced"
,
E
.
numOfExits
,
"parts"
working_ratio
=
(
M
.
totalWorkingTime
/
maxSimTime
)
*
100
print
"the total working ratio of the Machine is"
,
working_ratio
,
"%"
return
{
"parts"
:
E
.
numOfExits
,
"working_ratio"
:
working_ratio
}
if
__name__
==
'__main__'
:
main
()
\ No newline at end of file
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