Commit 313880c9 authored by Georgios Dagkakis's avatar Georgios Dagkakis

bug in CapacityStationController fixed

parent 0f674ff0
...@@ -222,6 +222,7 @@ class CapacityStationController(EventGenerator): ...@@ -222,6 +222,7 @@ class CapacityStationController(EventGenerator):
def calculateWhatIsToBeProcessed(self): def calculateWhatIsToBeProcessed(self):
import dream.simulation.Globals as Globals import dream.simulation.Globals as Globals
# calculate what space is available # calculate what space is available
availableSpace=self.assemblySpace-self.calculateConsumedSpace() availableSpace=self.assemblySpace-self.calculateConsumedSpace()
assert availableSpace>=0, 'negative available space' assert availableSpace>=0, 'negative available space'
...@@ -230,7 +231,6 @@ class CapacityStationController(EventGenerator): ...@@ -230,7 +231,6 @@ class CapacityStationController(EventGenerator):
# loop through the capacity station buffers # loop through the capacity station buffers
for buffer in G.CapacityStationBufferList: for buffer in G.CapacityStationBufferList:
pr = False
# if the buffer was considered before (due to shared resources) continue # if the buffer was considered before (due to shared resources) continue
if buffer in alreadyConsideredBuffers: if buffer in alreadyConsideredBuffers:
continue continue
...@@ -258,7 +258,6 @@ class CapacityStationController(EventGenerator): ...@@ -258,7 +258,6 @@ class CapacityStationController(EventGenerator):
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(entitiesConsidered) entitiesNotAllocated=list(entitiesConsidered)
allCapacityConsumed=False allCapacityConsumed=False
...@@ -360,12 +359,24 @@ class CapacityStationController(EventGenerator): ...@@ -360,12 +359,24 @@ class CapacityStationController(EventGenerator):
else: else:
allCapacityConsumed=True allCapacityConsumed=True
entitiesToBeBroken=list(entitiesWithinThreshold) entitiesToBeBroken=list(entitiesWithinThreshold)
# we sort the entities so the ones that can finish in current period (if any) go in front leftCapacity=totalAvailableCapacity
leftSpace=availableSpace
# with the below we calculate the projects that can finish in the current period
# and sort the entities so the ones that can finish in current period (if any) go in front
for e in entitiesToBeBroken:
e.willFinishNow=False
if self.checkIfAProjectCanBeFinishedInStation(e,e.currentStation.next[0],leftCapacity) and\
(not self.checkIfProjectNeedsToBeAssembled(e.capacityProject, e.currentStation)) and\
self.checkIfProjectCanStartInStation(e.capacityProject, e.currentStation.next[0]) and\
self.checkIfThereIsEnoughSpace(entity, entityBuffer, leftSpace):
leftCapacity-=e.requiredCapacity
if e.currentStation.requireFullProject and \
(not self.checkIfProjectConsumesAssemblySpace(e, e.currentStation)):
leftSpace-=e.capacityProject.assemblySpaceRequirement
e.willFinishNow=True
entitiesToBeBroken.sort(key=lambda \ entitiesToBeBroken.sort(key=lambda \
x: self.checkIfAProjectCanBeFinishedInStation(x,x.currentStation.next[0], x: x.willFinishNow and self.prioritizeIfCanFinish, reverse=True)
totalAvailableCapacity) \
and self.prioritizeIfCanFinish,
reverse=True)
# loop through the entities # loop through the entities
for entity in entitiesToBeBroken: for entity in entitiesToBeBroken:
# get buffer where the entity is and the station it requests to get in # get buffer where the entity is and the station it requests to get in
...@@ -388,6 +399,7 @@ class CapacityStationController(EventGenerator): ...@@ -388,6 +399,7 @@ class CapacityStationController(EventGenerator):
# 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:
if self.breakEntity(entity, entityBuffer, entityStation, if self.breakEntity(entity, entityBuffer, entityStation,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment