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
7c246a10
Commit
7c246a10
authored
Aug 08, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CapacityStationController to consider if projects share workpower
parent
e9dd5605
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
10 deletions
+42
-10
dream/simulation/CapacityStationController.py
dream/simulation/CapacityStationController.py
+42
-10
No files found.
dream/simulation/CapacityStationController.py
View file @
7c246a10
...
...
@@ -48,6 +48,8 @@ class CapacityStationController(EventGenerator):
self
.
stepsAreComplete
=
self
.
env
.
event
()
def
run
(
self
):
# sort the buffers so if they have shared resources the ones with highest priority will go in front
self
.
sortBuffers
()
yield
self
.
env
.
timeout
(
self
.
start
)
#wait until the start time
#loop until the end of the simulation
while
1
:
...
...
@@ -87,13 +89,15 @@ class CapacityStationController(EventGenerator):
# lock the exit again
exit
.
isLocked
=
True
# create the entities in the following stations
self
.
createInCapacityStationBuffers
()
# if the last exits led to an empty system then the simulation must be stopped
# step returns and the generator never yields the stepsAreComplete signal
if
self
.
checkIfSystemEmpty
():
return
# create the entities in the following stations
self
.
createInCapacityStationBuffers
()
# if there is need to merge entities in a buffer
self
.
mergeEntities
()
...
...
@@ -141,7 +145,11 @@ class CapacityStationController(EventGenerator):
# lock the station
station
.
isLocked
=
True
# calculate the utilization
periodDict
[
'utilization'
]
=
capacityAllocated
/
float
(
capacityAvailable
)
if
capacityAvailable
:
periodDict
[
'utilization'
]
=
capacityAllocated
/
float
(
capacityAvailable
)
else
:
# TODO check how the utilization and mean utilization should be calculated if it is 0
periodDict
[
'utilization'
]
=
0
# update the utilisationDict of the station
station
.
utilisationDict
.
append
(
periodDict
)
...
...
@@ -198,8 +206,9 @@ class CapacityStationController(EventGenerator):
# list to keep entities that have not been already allocated
entitiesNotAllocated
=
list
(
activeObjectQueue
)
allCapacityConsumed
=
False
if
totalAvailableCapacity
==
0
:
allCapacityConsumed
=
True
while
not
allCapacityConsumed
:
# list to keep entities that are within a threshold from the EDD
entitiesWithinThreshold
=
[]
...
...
@@ -230,11 +239,13 @@ class CapacityStationController(EventGenerator):
for
entity
in
entitiesWithinThreshold
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
entity
.
shouldMove
=
True
entity
.
shouldMove
=
True
# remove the entity from the none allocated ones
entitiesNotAllocated
.
remove
(
entity
)
# check if all the capacity is consumed to update the flag and break the loop
if
totalRequestedCapacity
==
totalAvailableCapacity
:
# the capacity will be 0 since we consumed it all
totalAvailableCapacity
=
0
allCapacityConsumed
=
True
# if we still have available capacity
else
:
...
...
@@ -245,13 +256,15 @@ class CapacityStationController(EventGenerator):
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
haveMoreEntitiesToAllocate
=
True
break
# otherwise we have to calculate the capacity for next loop
# the remaining capacity will be decreased by the one that was originally requested
totalAvailableCapacity
-=
totalRequestedCapacity
# if we have more entities break
if
not
haveMoreEntitiesToAllocate
:
break
# otherwise we have to calculate the capacity for next loop
# the remaining capacity will be decreased by the one that was originally requested
totalAvailableCapacity
-=
totalRequestedCapacity
# else calculate the capacity for every entity and create the entities
else
:
allCapacityConsumed
=
True
...
...
@@ -272,7 +285,20 @@ class CapacityStationController(EventGenerator):
# else break the entity according to rule
else
:
self
.
breakEntity
(
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
)
# the capacity will be 0 since we consumed it all
totalAvailableCapacity
=
0
if
station
.
sharedResources
:
self
.
setSharedCapacity
(
station
,
totalAvailableCapacity
)
def
setSharedCapacity
(
self
,
station
,
capacity
):
sharedStationsIds
=
station
.
sharedResources
.
get
(
'stationIds'
,
[])
for
capacityStation
in
G
.
CapacityStationList
:
if
capacityStation
is
station
:
continue
if
capacityStation
.
id
in
sharedStationsIds
:
capacityStation
.
remainingIntervalCapacity
[
0
]
=
capacity
# breaks an entity in the part that should move and the one that should stay
def
breakEntity
(
self
,
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
):
# calculate what is the capacity that should proceed and what that should remain
...
...
@@ -388,5 +414,11 @@ class CapacityStationController(EventGenerator):
if
total
-
(
alreadyWorked
+
required
)
<
0.001
and
availableCapacity
>=
required
:
# a small value to avoid mistakes due to rounding
return
True
return
False
# sorts the buffers so if they have shared resources the ones with highest priority will go in front
def
sortBuffers
(
self
):
for
buffer
in
G
.
CapacityStationBufferList
:
station
=
buffer
.
next
[
0
]
buffer
.
sharedPriority
=
station
.
sharedResources
.
get
(
'priority'
,
-
float
(
'inf'
))
G
.
CapacityStationBufferList
.
sort
(
key
=
lambda
x
:
x
.
sharedPriority
,
reverse
=
True
)
\ 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