Commit e48e9b6e authored by Georgios Dagkakis's avatar Georgios Dagkakis

changes so that CapacityStationController considers the due date in order to...

changes so that CapacityStationController considers the due date in order to allocate what is to be moved
parent 33ed93d2
...@@ -34,8 +34,8 @@ from Entity import Entity ...@@ -34,8 +34,8 @@ from Entity import Entity
class CapacityProject(Entity): class CapacityProject(Entity):
type="CapacityProject" type="CapacityProject"
def __init__(self, id=None, name=None, capacityRequirementDict={}, earliestStartDict={}): def __init__(self, id=None, name=None, capacityRequirementDict={}, earliestStartDict={}, dueDate=0):
Entity.__init__(self, id, name) Entity.__init__(self, id, name, dueDate=dueDate)
# a dict that shows the required capacity from every station # a dict that shows the required capacity from every station
self.capacityRequirementDict=capacityRequirementDict self.capacityRequirementDict=capacityRequirementDict
# a dict that shows the earliest start in every station # a dict that shows the earliest start in every station
......
...@@ -33,9 +33,13 @@ from Globals import G ...@@ -33,9 +33,13 @@ from Globals import G
class CapacityStationController(EventGenerator): class CapacityStationController(EventGenerator):
def __init__(self, id=id, name=None, start=None, stop=None, interval=None, def __init__(self, id=id, name=None, start=None, stop=None, interval=None,
duration=None, method=None, argumentDict=None): duration=None, method=None, argumentDict=None, dueDateThreshold=float('inf')):
EventGenerator.__init__(self, id, name, start, stop, interval, EventGenerator.__init__(self, id, name, start, stop, interval,
duration, method, argumentDict) duration, method, argumentDict)
# 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
def initialize(self): def initialize(self):
EventGenerator.initialize(self) EventGenerator.initialize(self)
...@@ -182,30 +186,80 @@ class CapacityStationController(EventGenerator): ...@@ -182,30 +186,80 @@ class CapacityStationController(EventGenerator):
def calculateWhatIsToBeProcessed(self): def calculateWhatIsToBeProcessed(self):
# loop through the capacity station buffers # loop through the capacity station buffers
for buffer in G.CapacityStationBufferList: for buffer in G.CapacityStationBufferList:
activeObjectQueue=buffer.getActiveObjectQueue()
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 # if there is no capacity continue with the next buffer
if totalAvailableCapacity<=0: if totalAvailableCapacity<=0:
continue 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 # 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 buffer.getActiveObjectQueue(): 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)):
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 totalRequestedCapacity<totalAvailableCapacity:
for entity in entitiesWithinThreshold:
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:
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)
# 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:
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 there is enough capacity for all the entities set them that they all should move
if totalRequestedCapacity<=totalAvailableCapacity: if totalRequestedCapacity<=totalAvailableCapacity:
for entity in buffer.getActiveObjectQueue(): for entity in entitiesOutsideThreshold:
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
# else calculate the capacity for every entity and create the entities # else calculate the capacity for every entity and create the entities
else: else:
entitiesInBuffer=list(buffer.getActiveObjectQueue()) allCapacityConsumed=True
entitiesToBeBroken=list(entitiesOutsideThreshold)
# loop through the entities # loop through the entities
for entity in entitiesInBuffer: 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) self.breakEntity(entity, buffer, station, totalAvailableCapacity, totalRequestedCapacity)
......
...@@ -869,10 +869,12 @@ def createObjects(): ...@@ -869,10 +869,12 @@ def createObjects():
stop=float('inf') stop=float('inf')
interval = float(element.get('interval') or 1) interval = float(element.get('interval') or 1)
duration = float(element.get('duration') or 0) duration = float(element.get('duration') or 0)
dueDateThreshold = float(element.get('dueDateThreshold') or float('inf'))
argumentDict=(element.get('argumentDict', {})) # get the arguments of the method as a dict / default {} argumentDict=(element.get('argumentDict', {})) # get the arguments of the method as a dict / default {}
# create the CapacityStationController object
CSC = CapacityStationController(id, name, start=start, stop=stop, interval=interval, CSC = CapacityStationController(id, name, start=start, stop=stop, interval=interval,
duration=duration, argumentDict=argumentDict) # create the EventGenerator object duration=duration, argumentDict=argumentDict, dueDateThreshold=dueDateThreshold)
# calling the getSuccessorList() method on the repairman # calling the getSuccessorList() method on the repairman
G.EventGeneratorList.append(CSC) # add the Event Generator to the RepairmanList G.EventGeneratorList.append(CSC) # add the Event Generator to the RepairmanList
G.CapacityStationControllerList.append(CSC) G.CapacityStationControllerList.append(CSC)
...@@ -1263,7 +1265,9 @@ def createWIP(): ...@@ -1263,7 +1265,9 @@ def createWIP():
name=entity.get('name', 'not found') name=entity.get('name', 'not found')
capacityRequirementDict=entity.get('capacityRequirementDict', {}) capacityRequirementDict=entity.get('capacityRequirementDict', {})
earliestStartDict=entity.get('earliestStartDict', {}) earliestStartDict=entity.get('earliestStartDict', {})
CP=CapacityProject(id=id, name=name, capacityRequirementDict=capacityRequirementDict, earliestStartDict=earliestStartDict) dueDate=float(entity.get('dueDate', 0))
CP=CapacityProject(id=id, name=name, capacityRequirementDict=capacityRequirementDict,
earliestStartDict=earliestStartDict, dueDate=dueDate)
G.EntityList.append(CP) G.EntityList.append(CP)
G.CapacityProjectList.append(CP) G.CapacityProjectList.append(CP)
......
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