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
85077d5c
Commit
85077d5c
authored
Aug 26, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes so that stations that require the same resources can follow the EDD constraint first
parent
51fb992a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
47 deletions
+62
-47
dream/simulation/CapacityStationController.py
dream/simulation/CapacityStationController.py
+62
-47
No files found.
dream/simulation/CapacityStationController.py
View file @
85077d5c
...
...
@@ -40,9 +40,9 @@ class CapacityStationController(EventGenerator):
# attribute used by optimization in calculateWhatIsToBeProcessed
# only the projects that are within this threshold from the one with EDD in the same bufffer
# will be considered to move at first
self
.
dueDateThreshold
=
dueDateThreshold
self
.
dueDateThreshold
=
float
(
dueDateThreshold
)
# attribute that shows if we prioritize entities that can finish work in this station in the next interval
self
.
prioritizeIfCanFinish
=
prioritizeIfCanFinish
self
.
prioritizeIfCanFinish
=
bool
(
int
(
prioritizeIfCanFinish
))
# the total assemblySpace in the system
self
.
assemblySpace
=
float
(
G
.
extraPropertyDict
.
get
(
'assemblySpace'
,
float
(
'inf'
)))
...
...
@@ -215,18 +215,38 @@ class CapacityStationController(EventGenerator):
exit
.
currentlyObtainedEntities
=
[]
def
calculateWhatIsToBeProcessed
(
self
):
import
Globals
availableSpace
=
self
.
assemblySpace
-
self
.
calculateConsumedSpace
()
assert
availableSpace
>=
0
,
'negative available space'
alreadyConsideredBuffers
=
[]
# loop through the capacity station buffers
for
buffer
in
G
.
CapacityStationBufferList
:
if
buffer
in
alreadyConsideredBuffers
:
continue
alreadyConsideredBuffers
.
append
(
buffer
)
sharedBuffers
=
[]
station
=
buffer
.
next
[
0
]
# get the station
if
station
.
sharedResources
:
sharedStations
=
station
.
sharedResources
.
get
(
'stationIds'
,[])
for
element
in
sharedStations
:
s
=
Globals
.
findObjectById
(
element
)
b
=
s
.
previous
[
0
]
sharedBuffers
.
append
(
b
)
activeObjectQueue
=
buffer
.
getActiveObjectQueue
()
entitiesConsidered
=
list
(
activeObjectQueue
)
for
b
in
sharedBuffers
:
entitiesConsidered
+=
b
.
getActiveObjectQueue
()
alreadyConsideredBuffers
.
append
(
b
)
# sort entities according to due date of the project that each belongs to
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
.
capacityProject
.
dueDate
)
entitiesConsidered
.
sort
(
key
=
lambda
x
:
x
.
capacityProject
.
dueDate
)
station
=
buffer
.
next
[
0
]
# get the station
totalAvailableCapacity
=
station
.
remainingIntervalCapacity
[
0
]
# get the available capacity of the station
# for this interval
# list to keep entities that have not been already allocated
entitiesNotAllocated
=
list
(
activeObjectQueue
)
entitiesNotAllocated
=
list
(
entitiesConsidered
)
allCapacityConsumed
=
False
if
totalAvailableCapacity
==
0
:
...
...
@@ -252,21 +272,24 @@ class CapacityStationController(EventGenerator):
# 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
))
and
\
self
.
checkIfThereIsEnoughSpace
(
entity
,
buffer
,
availableSpace
):
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
entity
.
currentStation
.
next
[
0
]
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
entity
.
currentStation
))
\
and
self
.
checkIfThereIsEnoughSpace
(
entity
,
entity
.
currentStation
,
availableSpace
):
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
entitiesWithinThreshold
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
))
and
\
self
.
checkIfThereIsEnoughSpace
(
entity
,
buffer
,
availableSpace
):
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
entity
.
currentStation
.
next
[
0
]
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
entity
.
currentStation
))
\
and
self
.
checkIfThereIsEnoughSpace
(
entity
,
entity
.
currentStation
,
availableSpace
):
entity
.
shouldMove
=
True
# reduce the available space if there is need to
if
buffer
.
requireFullProject
:
if
entity
.
currentStation
.
requireFullProject
and
\
(
not
self
.
checkIfProjectConsumesAssemblySpace
(
entity
,
entity
.
currentStation
)):
availableSpace
-=
entity
.
capacityProject
.
assemblySpaceRequirement
assert
availableSpace
>=
0
,
'negative available space'
# 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
...
...
@@ -279,9 +302,9 @@ class CapacityStationController(EventGenerator):
# 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
))
and
\
self
.
checkIfThereIsEnoughSpace
(
entity
,
buffer
,
availableSpace
):
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
entity
.
currentStation
.
next
[
0
]
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
entity
.
currentStation
))
\
and
self
.
checkIfThereIsEnoughSpace
(
entity
,
entity
.
currentStation
,
availableSpace
):
haveMoreEntitiesToAllocate
=
True
break
...
...
@@ -297,45 +320,37 @@ class CapacityStationController(EventGenerator):
else
:
allCapacityConsumed
=
True
entitiesToBeBroken
=
list
(
entitiesWithinThreshold
)
entitiesToBeBroken
.
sort
(
key
=
lambda
x
:
self
.
checkIfAProjectCanBeFinishedInStation
(
x
,
x
.
currentStation
.
next
[
0
],
totalAvailableCapacity
)
and
self
.
prioritizeIfCanFinish
,
reverse
=
True
)
# loop through the entities
for
entity
in
entitiesToBeBroken
:
# consider only entities that can move - not tose waiting for assembly or earliest start
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
# consider only entities that can move - not those waiting for assembly or earliest start
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
entity
.
currentStation
.
next
[
0
])
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
entity
.
currentStation
))
and
\
self
.
checkIfThereIsEnoughSpace
(
entity
,
entity
.
currentStation
,
availableSpace
):
# if we prioritize an entity that can completely finish then check for this
if
self
.
checkIfAProjectCanBeFinishedInStation
(
entity
,
station
,
totalAvailableCapacity
)
\
if
self
.
checkIfAProjectCanBeFinishedInStation
(
entity
,
entity
.
currentStation
.
next
[
0
]
,
totalAvailableCapacity
)
\
and
self
.
prioritizeIfCanFinish
:
# set that the entity can move
entity
.
shouldMove
=
True
# reduce the available space if there is need to
if
buffer
.
requireFullProject
:
if
entity
.
currentStation
.
requireFullProject
and
\
(
not
self
.
checkIfProjectConsumesAssemblySpace
(
entity
,
entity
.
currentStation
)):
availableSpace
-=
entity
.
capacityProject
.
assemblySpaceRequirement
assert
availableSpace
>=
0
,
'negative available space'
# update the values
totalAvailableCapacity
-=
entity
.
requiredCapacity
totalRequestedCapacity
-=
entity
.
requiredCapacity
# else break the entity according to rule
else
:
self
.
breakEntity
(
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
)
self
.
breakEntity
(
entity
,
entity
.
currentStation
,
entity
.
currentStation
.
next
[
0
]
,
total
AvailableCapacity
,
total
RequestedCapacity
)
# reduce the available space if there is need to
if
buffer
.
requireFullProject
:
if
entity
.
currentStation
.
requireFullProject
and
\
(
not
self
.
checkIfProjectConsumesAssemblySpace
(
entity
,
entity
.
currentStation
)):
availableSpace
-=
entity
.
capacityProject
.
assemblySpaceRequirement
# the capacity will be 0 since we consumed it all
totalAvailableCapacity
=
0
# if the station shares capacity with other stations then we have to
# reduce in them the amount of capacity that was consumed
if
station
.
sharedResources
:
self
.
setSharedCapacity
(
station
,
totalAvailableCapacity
)
# if capacity is shared and one station consumes part of it
# then this method reduces the capacity from the other stations
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
assert
availableSpace
>=
0
,
'negative available space'
# breaks an entity in the part that should move and the one that should stay
def
breakEntity
(
self
,
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
):
...
...
@@ -480,7 +495,7 @@ class CapacityStationController(EventGenerator):
station
=
buffer
.
next
[
0
]
for
entity
in
buffer
.
getActiveObjectQueue
():
if
self
.
checkIfProjectConsumesAssemblySpace
(
entity
,
buffer
):
consumedSpace
+=
entity
.
capacityProject
.
capacityRequirementDict
[
station
.
id
]
consumedSpace
+=
entity
.
capacityProject
.
assemblySpaceRequirement
return
consumedSpace
# checks if a project already consumes assembly space because assembly work started in a previous period
...
...
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