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
edac5069
Commit
edac5069
authored
Sep 02, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one more example with EventGenerator
parent
3ced8e74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
dream/simulation/Examples/ChangingPredecessors.py
dream/simulation/Examples/ChangingPredecessors.py
+68
-0
No files found.
dream/simulation/Examples/ChangingPredecessors.py
0 → 100644
View file @
edac5069
from
dream.simulation.imports
import
Machine
,
Queue
,
Exit
,
Part
,
EventGenerator
,
ExcelHandler
from
dream.simulation.Globals
import
runSimulation
,
G
# method that is to be invoked by the generator.
# it changes the predecessor of the Machine
def
changeMachinePredecessor
(
machine
,
possiblePredecessors
):
# if the machine has no predecessors (at the start of the simulation)
# pick the first of the list
if
not
len
(
machine
.
previous
):
machine
.
previous
.
append
(
possiblePredecessors
[
0
])
# else loop through the possible predecessors and if one is not the current
# set this as predecessor and break
else
:
for
buffer
in
possiblePredecessors
:
if
not
buffer
==
machine
.
previous
[
0
]:
machine
.
previous
[
0
]
=
buffer
break
# if canDispose is not triggered in the predecessor send it
if
not
machine
.
previous
[
0
].
canDispose
.
triggered
:
machine
.
previous
[
0
].
canDispose
.
succeed
()
print
G
.
env
.
now
,
'from now on the machine will take from'
,
machine
.
previous
[
0
].
id
#define the objects of the model
Q1
=
Queue
(
'Q1'
,
'Queue1'
,
capacity
=
float
(
'inf'
))
Q2
=
Queue
(
'Q2'
,
'Queue2'
,
capacity
=
float
(
'inf'
))
M
=
Machine
(
'M1'
,
'Machine'
,
processingTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
3
})
E
=
Exit
(
'E1'
,
'Exit'
)
P1
=
Part
(
'P1'
,
'Part1'
,
currentStation
=
Q1
)
entityList
=
[]
for
i
in
range
(
5
):
# create the WIP in a loop
Q1PartId
=
'Q1_P'
+
str
(
i
)
Q1PartName
=
'Q1_Part'
+
str
(
i
)
PQ1
=
Part
(
Q1PartId
,
Q1PartName
,
currentStation
=
Q1
)
entityList
.
append
(
PQ1
)
Q2PartId
=
'Q2_P'
+
str
(
i
)
Q2PartName
=
'Q2_Part'
+
str
(
i
)
PQ2
=
Part
(
Q2PartId
,
Q2PartName
,
currentStation
=
Q2
)
entityList
.
append
(
PQ2
)
#define predecessors and successors for the objects
Q1
.
defineRouting
(
successorList
=
[
M
])
Q2
.
defineRouting
(
successorList
=
[
M
])
M
.
defineRouting
(
successorList
=
[
E
])
E
.
defineRouting
(
predecessorList
=
[
M
])
EV
=
EventGenerator
(
'EV'
,
'PredecessorChanger'
,
start
=
0
,
stop
=
50
,
interval
=
10
,
method
=
changeMachinePredecessor
,
argumentDict
=
{
'machine'
:
M
,
'possiblePredecessors'
:[
Q1
,
Q2
]})
def
main
():
# add all the objects in a list
objectList
=
[
Q1
,
Q2
,
M
,
E
,
EV
]
+
entityList
# set the length of the experiment
maxSimTime
=
float
(
'inf'
)
# call the runSimulation giving the objects and the length of the experiment
runSimulation
(
objectList
,
maxSimTime
,
trace
=
'Yes'
)
#print the results
print
'='
*
50
print
"the system produced"
,
E
.
numOfExits
,
"parts in"
,
E
.
timeLastEntityLeft
,
"minutes"
working_ratio
=
(
M
.
totalWorkingTime
/
E
.
timeLastEntityLeft
)
*
100
print
"the total working ratio of the Machine is"
,
working_ratio
,
"%"
ExcelHandler
.
outputTrace
(
'ChangingPredecessors'
)
return
{
"parts"
:
E
.
numOfExits
,
"simulationTime"
:
E
.
timeLastEntityLeft
,
"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