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
bc720c02
Commit
bc720c02
authored
Aug 07, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EDD to be updated in every allocation step for the same buffer
parent
2b92dced
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
62 deletions
+53
-62
dream/simulation/CapacityStationController.py
dream/simulation/CapacityStationController.py
+53
-62
No files found.
dream/simulation/CapacityStationController.py
View file @
bc720c02
...
...
@@ -189,84 +189,75 @@ class CapacityStationController(EventGenerator):
activeObjectQueue
=
buffer
.
getActiveObjectQueue
()
station
=
buffer
.
next
[
0
]
# get the station
totalAvailableCapacity
=
station
.
remainingIntervalCapacity
[
0
]
# get the available capacity of the station
# for this interval
# if there is no capacity continue with the next buffer
if
totalAvailableCapacity
<=
0
:
continue
# get the EDD
EDD
=
float
(
'inf'
)
for
entity
in
activeObjectQueue
:
if
EDD
>
entity
.
capacityProject
.
dueDate
:
EDD
=
entity
.
capacityProject
.
dueDate
# list to keep entities that are within a threshold from the EDD
entitiesWithinThreshold
=
[]
# list to keep entities that are outside a threshold from the EDD
entitiesOutsideThreshold
=
[]
# put the entities in the list
for
entity
in
activeObjectQueue
:
if
entity
.
capacityProject
.
dueDate
-
EDD
<=
self
.
dueDateThreshold
:
entitiesWithinThreshold
.
append
(
entity
)
else
:
entitiesOutsideThreshold
.
append
(
entity
)
# if the buffer is not assembly
# calculate the total capacity that is requested
totalRequestedCapacity
=
0
for
entity
in
entitiesWithinThreshold
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
totalRequestedCapacity
+=
entity
.
requiredCapacity
# for this interval
# list to keep entities that were already allocated
entitiesAlreadyConsidered
=
[]
# list to keep entities that have not been already allocated
entitiesNotAllocated
=
list
(
activeObjectQueue
)
allCapacityConsumed
=
False
# if there is enough capacity for all the entities set them that they all should move
if
totalRequestedCapacity
<=
totalAvailableCapacity
:
for
entity
in
entitiesWithinThreshold
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
entity
.
shouldMove
=
True
# check if all the capacity is consumed to update the flag
if
totalRequestedCapacity
==
totalAvailableCapacity
:
allCapacityConsumed
=
True
# else calculate the capacity for every entity and create the entities
else
:
allCapacityConsumed
=
True
entitiesToBeBroken
=
list
(
entitiesWithinThreshold
)
# loop through the entities
for
entity
in
entitiesToBeBroken
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
self
.
breakEntity
(
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
)
allCapacityConsumed
=
False
while
not
allCapacityConsumed
:
# list to keep entities that are within a threshold from the EDD
entitiesWithinThreshold
=
[]
# list to keep entities that are outside a threshold from the EDD
entitiesOutsideThreshold
=
[]
# get the EDD
EDD
=
float
(
'inf'
)
for
entity
in
entitiesNotAllocated
:
if
EDD
>
entity
.
capacityProject
.
dueDate
:
EDD
=
entity
.
capacityProject
.
dueDate
# from now on entities outside the threshold are considered
if
not
allCapacityConsumed
:
# the remaining capacity will be decreased by the one that was originally requested
totalAvailableCapacity
-=
totalRequestedCapacity
totalRequestedCapacity
=
0
for
entity
in
entitiesOutsideThreshold
:
# put the entities in the corresponding list according to their due date
for
entity
in
entitiesNotAllocated
:
if
entity
.
capacityProject
.
dueDate
-
EDD
<=
self
.
dueDateThreshold
:
entitiesWithinThreshold
.
append
(
entity
)
else
:
entitiesOutsideThreshold
.
append
(
entity
)
# calculate the total capacity that is requested
totalRequestedCapacity
=
0
for
entity
in
entitiesWithinThreshold
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
totalRequestedCapacity
+=
entity
.
requiredCapacity
totalRequestedCapacity
+=
entity
.
requiredCapacity
# if there is enough capacity for all the entities set them that they all should move
if
totalRequestedCapacity
<=
totalAvailableCapacity
:
for
entity
in
entities
Outside
Threshold
:
for
entity
in
entities
Within
Threshold
:
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
:
allCapacityConsumed
=
True
# if we still have available capacity
else
:
# check in the entities outside the threshold if there is one or more that can be moved
haveMoreEntitiesToAllocate
=
False
for
entity
in
entitiesOutsideThreshold
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
haveMoreEntitiesToAllocate
=
True
break
# 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
entitiesToBeBroken
=
list
(
entities
Outside
Threshold
)
entitiesToBeBroken
=
list
(
entities
Within
Threshold
)
# loop through the entities
for
entity
in
entitiesToBeBroken
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
self
.
breakEntity
(
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
)
# 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
...
...
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