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
b0be22a6
Commit
b0be22a6
authored
Jun 10, 2014
by
Georgios Dagkakis
Committed by
Jérome Perrin
Jun 13, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CapacityStation updated to output the utilization for every period and the total on
parent
d28c8a1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
dream/simulation/CapacityStation.py
dream/simulation/CapacityStation.py
+19
-1
dream/simulation/CapacityStationController.py
dream/simulation/CapacityStationController.py
+9
-1
No files found.
dream/simulation/CapacityStation.py
View file @
b0be22a6
...
@@ -34,6 +34,7 @@ import simpy
...
@@ -34,6 +34,7 @@ import simpy
# the CapacityStation object
# the CapacityStation object
# ===========================================================================
# ===========================================================================
class
CapacityStation
(
Queue
):
class
CapacityStation
(
Queue
):
class_name
=
'Dream.CapacityStation'
#===========================================================================
#===========================================================================
# the __init__ method of the CapacityStation
# the __init__ method of the CapacityStation
...
@@ -51,10 +52,27 @@ class CapacityStation(Queue):
...
@@ -51,10 +52,27 @@ class CapacityStation(Queue):
Queue
.
initialize
(
self
)
Queue
.
initialize
(
self
)
self
.
remainingIntervalCapacity
=
list
(
self
.
intervalCapacity
)
self
.
remainingIntervalCapacity
=
list
(
self
.
intervalCapacity
)
self
.
isLocked
=
True
self
.
isLocked
=
True
self
.
utilisationDict
=
[]
# a list of dicts for the results
def
canAccept
(
self
,
callerObject
=
None
):
def
canAccept
(
self
,
callerObject
=
None
):
if
self
.
isLocked
:
if
self
.
isLocked
:
return
False
return
False
return
Queue
.
canAccept
(
self
)
return
Queue
.
canAccept
(
self
)
# =======================================================================
# outputs results to JSON File
# =======================================================================
def
outputResultsJSON
(
self
):
from
Globals
import
G
json
=
{
'_class'
:
self
.
class_name
,
'id'
:
self
.
id
,
'results'
:
{}}
if
(
G
.
numberOfReplications
==
1
):
# if we had just one replication output the results as numbers
json
[
'results'
][
'capacityUsed'
]
=
self
.
utilisationDict
meanUtilization
=
0
for
entry
in
self
.
utilisationDict
:
meanUtilization
+=
entry
[
'utilization'
]
/
float
(
len
(
self
.
utilisationDict
))
json
[
'results'
][
'meanUtilization'
]
=
meanUtilization
G
.
outputJSON
[
'elementList'
].
append
(
json
)
\ No newline at end of file
dream/simulation/CapacityStationController.py
View file @
b0be22a6
...
@@ -97,8 +97,12 @@ class CapacityStationController(EventGenerator):
...
@@ -97,8 +97,12 @@ class CapacityStationController(EventGenerator):
station
.
isLocked
=
False
# unlock the station
station
.
isLocked
=
False
# unlock the station
buffer
=
station
.
previous
[
0
]
# take the buffer
buffer
=
station
.
previous
[
0
]
# take the buffer
buffer
.
sortEntities
()
# sort the entities of the buffer so the ones to move go in front
buffer
.
sortEntities
()
# sort the entities of the buffer so the ones to move go in front
periodDict
=
{}
periodDict
[
'period'
]
=
self
.
env
.
now
# loop though the entities
# loop though the entities
entitiesToCheck
=
list
(
buffer
.
getActiveObjectQueue
())
entitiesToCheck
=
list
(
buffer
.
getActiveObjectQueue
())
capacityAvailable
=
station
.
remainingIntervalCapacity
[
0
]
capacityAllocated
=
0
for
entity
in
entitiesToCheck
:
for
entity
in
entitiesToCheck
:
if
not
entity
.
shouldMove
:
# when the first entity that should not move is reached break
if
not
entity
.
shouldMove
:
# when the first entity that should not move is reached break
break
break
...
@@ -106,8 +110,12 @@ class CapacityStationController(EventGenerator):
...
@@ -106,8 +110,12 @@ class CapacityStationController(EventGenerator):
# wait until the entity is removed
# wait until the entity is removed
yield
buffer
.
entityRemoved
yield
buffer
.
entityRemoved
buffer
.
entityRemoved
=
self
.
env
.
event
()
buffer
.
entityRemoved
=
self
.
env
.
event
()
periodDict
[
entity
.
capacityProject
.
id
]
=
entity
.
requiredCapacity
capacityAllocated
+=
entity
.
requiredCapacity
# lock the station
# lock the station
station
.
isLocked
=
True
station
.
isLocked
=
True
periodDict
[
'utilization'
]
=
capacityAllocated
/
float
(
capacityAvailable
)
station
.
utilisationDict
.
append
(
periodDict
)
# for every station update the remaining interval capacity so that it is ready for next loop
# for every station update the remaining interval capacity so that it is ready for next loop
for
station
in
G
.
CapacityStationList
:
for
station
in
G
.
CapacityStationList
:
...
...
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