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
Hide 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):
...
@@ -40,9 +40,9 @@ class CapacityStationController(EventGenerator):
# attribute used by optimization in calculateWhatIsToBeProcessed
# attribute used by optimization in calculateWhatIsToBeProcessed
# only the projects that are within this threshold from the one with EDD in the same bufffer
# only the projects that are within this threshold from the one with EDD in the same bufffer
# will be considered to move at first
# 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
# 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
# the total assemblySpace in the system
self
.
assemblySpace
=
float
(
G
.
extraPropertyDict
.
get
(
'assemblySpace'
,
float
(
'inf'
)))
self
.
assemblySpace
=
float
(
G
.
extraPropertyDict
.
get
(
'assemblySpace'
,
float
(
'inf'
)))
...
@@ -215,18 +215,38 @@ class CapacityStationController(EventGenerator):
...
@@ -215,18 +215,38 @@ class CapacityStationController(EventGenerator):
exit
.
currentlyObtainedEntities
=
[]
exit
.
currentlyObtainedEntities
=
[]
def
calculateWhatIsToBeProcessed
(
self
):
def
calculateWhatIsToBeProcessed
(
self
):
import
Globals
availableSpace
=
self
.
assemblySpace
-
self
.
calculateConsumedSpace
()
availableSpace
=
self
.
assemblySpace
-
self
.
calculateConsumedSpace
()
assert
availableSpace
>=
0
,
'negative available space'
alreadyConsideredBuffers
=
[]
# loop through the capacity station buffers
# loop through the capacity station buffers
for
buffer
in
G
.
CapacityStationBufferList
:
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
()
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
# 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
totalAvailableCapacity
=
station
.
remainingIntervalCapacity
[
0
]
# get the available capacity of the station
# for this interval
# for this interval
# list to keep entities that have not been already allocated
# list to keep entities that have not been already allocated
entitiesNotAllocated
=
list
(
activeObjectQueue
)
entitiesNotAllocated
=
list
(
entitiesConsidered
)
allCapacityConsumed
=
False
allCapacityConsumed
=
False
if
totalAvailableCapacity
==
0
:
if
totalAvailableCapacity
==
0
:
...
@@ -241,7 +261,7 @@ class CapacityStationController(EventGenerator):
...
@@ -241,7 +261,7 @@ class CapacityStationController(EventGenerator):
for
entity
in
entitiesNotAllocated
:
for
entity
in
entitiesNotAllocated
:
if
EDD
>
entity
.
capacityProject
.
dueDate
:
if
EDD
>
entity
.
capacityProject
.
dueDate
:
EDD
=
entity
.
capacityProject
.
dueDate
EDD
=
entity
.
capacityProject
.
dueDate
# put the entities in the corresponding list according to their due date
# put the entities in the corresponding list according to their due date
for
entity
in
entitiesNotAllocated
:
for
entity
in
entitiesNotAllocated
:
if
entity
.
capacityProject
.
dueDate
-
EDD
<=
self
.
dueDateThreshold
:
if
entity
.
capacityProject
.
dueDate
-
EDD
<=
self
.
dueDateThreshold
:
...
@@ -250,23 +270,26 @@ class CapacityStationController(EventGenerator):
...
@@ -250,23 +270,26 @@ class CapacityStationController(EventGenerator):
entitiesOutsideThreshold
.
append
(
entity
)
entitiesOutsideThreshold
.
append
(
entity
)
# calculate the total capacity that is requested
# calculate the total capacity that is requested
totalRequestedCapacity
=
0
totalRequestedCapacity
=
0
for
entity
in
entitiesWithinThreshold
:
for
entity
in
entitiesWithinThreshold
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
entity
.
currentStation
.
next
[
0
]
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
))
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
entity
.
currentStation
))
\
self
.
checkIfThereIsEnoughSpace
(
entity
,
buffer
,
availableSpace
):
and
self
.
checkIfThereIsEnoughSpace
(
entity
,
entity
.
currentStation
,
availableSpace
):
totalRequestedCapacity
+=
entity
.
requiredCapacity
totalRequestedCapacity
+=
entity
.
requiredCapacity
# if there is enough capacity for all the entities set them that they all should move
# if there is enough capacity for all the entities set them that they all should move
if
totalRequestedCapacity
<=
totalAvailableCapacity
:
if
totalRequestedCapacity
<=
totalAvailableCapacity
:
for
entity
in
entitiesWithinThreshold
:
for
entity
in
entitiesWithinThreshold
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
entity
.
currentStation
.
next
[
0
]
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
))
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
entity
.
currentStation
))
\
self
.
checkIfThereIsEnoughSpace
(
entity
,
buffer
,
availableSpace
):
and
self
.
checkIfThereIsEnoughSpace
(
entity
,
entity
.
currentStation
,
availableSpace
):
entity
.
shouldMove
=
True
entity
.
shouldMove
=
True
# reduce the available space if there is need to
# reduce the available space if there is need to
if
buffer
.
requireFullProject
:
if
entity
.
currentStation
.
requireFullProject
and
\
availableSpace
-=
entity
.
capacityProject
.
assemblySpaceRequirement
(
not
self
.
checkIfProjectConsumesAssemblySpace
(
entity
,
entity
.
currentStation
)):
availableSpace
-=
entity
.
capacityProject
.
assemblySpaceRequirement
assert
availableSpace
>=
0
,
'negative available space'
# remove the entity from the none allocated ones
# remove the entity from the none allocated ones
entitiesNotAllocated
.
remove
(
entity
)
entitiesNotAllocated
.
remove
(
entity
)
# check if all the capacity is consumed to update the flag and break the loop
# check if all the capacity is consumed to update the flag and break the loop
...
@@ -279,9 +302,9 @@ class CapacityStationController(EventGenerator):
...
@@ -279,9 +302,9 @@ class CapacityStationController(EventGenerator):
# check in the entities outside the threshold if there is one or more that can be moved
# check in the entities outside the threshold if there is one or more that can be moved
haveMoreEntitiesToAllocate
=
False
haveMoreEntitiesToAllocate
=
False
for
entity
in
entitiesOutsideThreshold
:
for
entity
in
entitiesOutsideThreshold
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
entity
.
currentStation
.
next
[
0
]
)
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
))
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
entity
.
currentStation
))
\
self
.
checkIfThereIsEnoughSpace
(
entity
,
buffer
,
availableSpace
):
and
self
.
checkIfThereIsEnoughSpace
(
entity
,
entity
.
currentStation
,
availableSpace
):
haveMoreEntitiesToAllocate
=
True
haveMoreEntitiesToAllocate
=
True
break
break
...
@@ -297,46 +320,38 @@ class CapacityStationController(EventGenerator):
...
@@ -297,46 +320,38 @@ class CapacityStationController(EventGenerator):
else
:
else
:
allCapacityConsumed
=
True
allCapacityConsumed
=
True
entitiesToBeBroken
=
list
(
entitiesWithinThreshold
)
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
# loop through the entities
for
entity
in
entitiesToBeBroken
:
for
entity
in
entitiesToBeBroken
:
# consider only entities that can move - not tose waiting for assembly or earliest start
# consider only entities that can move - not those waiting for assembly or earliest start
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
)
and
\
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
entity
.
currentStation
.
next
[
0
])
and
\
(
not
self
.
checkIfProjectNeedsToBeAssembled
(
entity
.
capacityProject
,
buffer
)):
(
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 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
:
and
self
.
prioritizeIfCanFinish
:
# set that the entity can move
# set that the entity can move
entity
.
shouldMove
=
True
entity
.
shouldMove
=
True
# reduce the available space if there is need to
# 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
availableSpace
-=
entity
.
capacityProject
.
assemblySpaceRequirement
assert
availableSpace
>=
0
,
'negative available space'
# update the values
# update the values
totalAvailableCapacity
-=
entity
.
requiredCapacity
totalAvailableCapacity
-=
entity
.
requiredCapacity
totalRequestedCapacity
-=
entity
.
requiredCapacity
totalRequestedCapacity
-=
entity
.
requiredCapacity
# else break the entity according to rule
# else break the entity according to rule
else
:
else
:
self
.
breakEntity
(
entity
,
buffer
,
station
,
totalAvailableCapacity
,
self
.
breakEntity
(
entity
,
entity
.
currentStation
,
entity
.
currentStation
.
next
[
0
]
,
totalRequestedCapacity
)
total
AvailableCapacity
,
total
RequestedCapacity
)
# reduce the available space if there is need to
# 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
availableSpace
-=
entity
.
capacityProject
.
assemblySpaceRequirement
# the capacity will be 0 since we consumed it all
assert
availableSpace
>=
0
,
'negative available space'
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
# breaks an entity in the part that should move and the one that should stay
# breaks an entity in the part that should move and the one that should stay
def
breakEntity
(
self
,
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
):
def
breakEntity
(
self
,
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
):
# calculate what is the capacity that should proceed and what that should remain
# calculate what is the capacity that should proceed and what that should remain
...
@@ -354,7 +369,7 @@ class CapacityStationController(EventGenerator):
...
@@ -354,7 +369,7 @@ class CapacityStationController(EventGenerator):
entityToStay
.
initialize
()
entityToStay
.
initialize
()
entityToStay
.
currentStation
=
buffer
entityToStay
.
currentStation
=
buffer
import
Globals
import
Globals
Globals
.
setWIP
([
entityToMove
,
entityToStay
])
#set the new components as wip
Globals
.
setWIP
([
entityToMove
,
entityToStay
])
#set the new components as wip
# merges the capacity entities if they belong to the same project
# merges the capacity entities if they belong to the same project
def
mergeEntities
(
self
):
def
mergeEntities
(
self
):
...
@@ -480,7 +495,7 @@ class CapacityStationController(EventGenerator):
...
@@ -480,7 +495,7 @@ class CapacityStationController(EventGenerator):
station
=
buffer
.
next
[
0
]
station
=
buffer
.
next
[
0
]
for
entity
in
buffer
.
getActiveObjectQueue
():
for
entity
in
buffer
.
getActiveObjectQueue
():
if
self
.
checkIfProjectConsumesAssemblySpace
(
entity
,
buffer
):
if
self
.
checkIfProjectConsumesAssemblySpace
(
entity
,
buffer
):
consumedSpace
+=
entity
.
capacityProject
.
capacityRequirementDict
[
station
.
id
]
consumedSpace
+=
entity
.
capacityProject
.
assemblySpaceRequirement
return
consumedSpace
return
consumedSpace
# checks if a project already consumes assembly space because assembly work started in a previous period
# 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