Commit bc720c02 authored by Georgios Dagkakis's avatar Georgios Dagkakis

EDD to be updated in every allocation step for the same buffer

parent 2b92dced
...@@ -190,28 +190,30 @@ class CapacityStationController(EventGenerator): ...@@ -190,28 +190,30 @@ class CapacityStationController(EventGenerator):
station=buffer.next[0] # get the station 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
# if there is no capacity continue with the next buffer # list to keep entities that were already allocated
if totalAvailableCapacity<=0: entitiesAlreadyConsidered=[]
continue # list to keep entities that have not been already allocated
entitiesNotAllocated=list(activeObjectQueue)
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 # get the EDD
EDD=float('inf') EDD=float('inf')
for entity in activeObjectQueue: for entity in entitiesNotAllocated:
if EDD>entity.capacityProject.dueDate: if EDD>entity.capacityProject.dueDate:
EDD=entity.capacityProject.dueDate EDD=entity.capacityProject.dueDate
# list to keep entities that are within a threshold from the EDD # put the entities in the corresponding list according to their due date
entitiesWithinThreshold=[] for entity in entitiesNotAllocated:
# 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: if entity.capacityProject.dueDate-EDD<=self.dueDateThreshold:
entitiesWithinThreshold.append(entity) entitiesWithinThreshold.append(entity)
else: else:
entitiesOutsideThreshold.append(entity) entitiesOutsideThreshold.append(entity)
# if the buffer is not assembly
# 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:
...@@ -219,48 +221,37 @@ class CapacityStationController(EventGenerator): ...@@ -219,48 +221,37 @@ class CapacityStationController(EventGenerator):
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)): (not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)):
totalRequestedCapacity+=entity.requiredCapacity totalRequestedCapacity+=entity.requiredCapacity
allCapacityConsumed=False
# 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, station) and\
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)): (not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)):
entity.shouldMove=True entity.shouldMove=True
# check if all the capacity is consumed to update the flag # 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: if totalRequestedCapacity==totalAvailableCapacity:
allCapacityConsumed=True allCapacityConsumed=True
# if we still have available capacity
# else calculate the capacity for every entity and create the entities
else: else:
allCapacityConsumed=True # check in the entities outside the threshold if there is one or more that can be moved
entitiesToBeBroken=list(entitiesWithinThreshold) haveMoreEntitiesToAllocate=False
# loop through the entities for entity in entitiesOutsideThreshold:
for entity in entitiesToBeBroken:
if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\ if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)): (not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)):
self.breakEntity(entity, buffer, station, totalAvailableCapacity, totalRequestedCapacity) haveMoreEntitiesToAllocate=True
break
# if we have more entities break
if not haveMoreEntitiesToAllocate:
break
# from now on entities outside the threshold are considered # otherwise we have to calculate the capacity for next loop
if not allCapacityConsumed:
# the remaining capacity will be decreased by the one that was originally requested # the remaining capacity will be decreased by the one that was originally requested
totalAvailableCapacity-=totalRequestedCapacity totalAvailableCapacity-=totalRequestedCapacity
totalRequestedCapacity=0
for entity in entitiesOutsideThreshold:
if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)):
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 entitiesOutsideThreshold:
if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)):
entity.shouldMove=True
# else calculate the capacity for every entity and create the entities # else calculate the capacity for every entity and create the entities
else: else:
allCapacityConsumed=True allCapacityConsumed=True
entitiesToBeBroken=list(entitiesOutsideThreshold) entitiesToBeBroken=list(entitiesWithinThreshold)
# loop through the entities # loop through the entities
for entity in entitiesToBeBroken: for entity in entitiesToBeBroken:
if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\ if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\
......
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