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
1d28372e
Commit
1d28372e
authored
Sep 04, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new example of a simple buffer allocation problem added
parent
c04cabd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
dream/simulation/Examples/BufferAllocation.py
dream/simulation/Examples/BufferAllocation.py
+53
-0
No files found.
dream/simulation/Examples/BufferAllocation.py
0 → 100644
View file @
1d28372e
from
dream.simulation.imports
import
Machine
,
Source
,
Exit
,
Part
,
Queue
,
NonStarvingEntry
from
dream.simulation.Globals
import
runSimulation
#define the objects of the model
NS
=
NonStarvingEntry
(
'NS1'
,
'Entry'
,
entityData
=
{
'_class'
:
'Dream.Part'
})
M1
=
Machine
(
'M1'
,
'Machine1'
,
processingTime
=
{
'Exp'
:{
'mean'
:
1
}})
Q2
=
Queue
(
'Q2'
,
'Queue2'
)
M2
=
Machine
(
'M2'
,
'Machine2'
,
processingTime
=
{
'Exp'
:{
'mean'
:
3
}})
Q3
=
Queue
(
'Q3'
,
'Queue3'
)
M3
=
Machine
(
'M3'
,
'Machine3'
,
processingTime
=
{
'Exp'
:{
'mean'
:
5
}})
E
=
Exit
(
'E1'
,
'Exit'
)
#define predecessors and successors for the objects
NS
.
defineRouting
(
successorList
=
[
M1
])
M1
.
defineRouting
(
predecessorList
=
[
NS
],
successorList
=
[
Q2
])
Q2
.
defineRouting
(
predecessorList
=
[
M1
],
successorList
=
[
M2
])
M2
.
defineRouting
(
predecessorList
=
[
Q2
],
successorList
=
[
Q3
])
Q3
.
defineRouting
(
predecessorList
=
[
M2
],
successorList
=
[
M3
])
M3
.
defineRouting
(
predecessorList
=
[
Q3
],
successorList
=
[
E
])
E
.
defineRouting
(
predecessorList
=
[
M3
])
def
main
(
test
=
0
):
# add all the objects in a list
objectList
=
[
NS
,
M1
,
M2
,
M3
,
Q2
,
Q3
,
E
]
# set the length of the experiment
maxSimTime
=
480
solutionList
=
[]
for
i
in
range
(
1
,
10
):
Q2
.
capacity
=
i
Q3
.
capacity
=
10
-
i
# call the runSimulation giving the objects and the length of the experiment
runSimulation
(
objectList
,
maxSimTime
,
numberOfReplications
=
10
)
# return results for the test
if
test
:
return
{
"parts"
:
E
.
numOfExits
}
solutionList
.
append
({
"Q2"
:
Q2
.
capacity
,
"Q3"
:
Q3
.
capacity
,
"throughput"
:
sum
(
E
.
Exits
)
/
float
(
len
(
E
.
Exits
))
}
)
E
.
Exits
=
[]
solutionList
.
sort
(
key
=
lambda
x
:
x
.
get
(
"throughput"
,
0
),
reverse
=
True
)
print
"the best allocation is for Q2"
,
solutionList
[
0
][
'Q2'
],
"units and Q3"
,
solutionList
[
0
][
'Q2'
],
\
"units, with a predicted throughput of"
,
solutionList
[
0
][
'throughput'
]
if
__name__
==
'__main__'
:
main
()
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