Commit c8111a5d authored by Georgios Dagkakis's avatar Georgios Dagkakis

earliest start logic incorporated in CapacityStations first implementation

parent 75678d6e
...@@ -34,10 +34,12 @@ from Entity import Entity ...@@ -34,10 +34,12 @@ from Entity import Entity
class CapacityProject(Entity): class CapacityProject(Entity):
type="CapacityProject" type="CapacityProject"
def __init__(self, id=None, name=None, capacityRequirementDict={}): def __init__(self, id=None, name=None, capacityRequirementDict={}, earliestStartDict={}):
Entity.__init__(self, id, name) Entity.__init__(self, id, name)
# 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
self.earliestStartDict=earliestStartDict
def initialize(self): def initialize(self):
self.projectSchedule=[] # a list of dicts to keep the schedule self.projectSchedule=[] # a list of dicts to keep the schedule
......
...@@ -193,32 +193,35 @@ class CapacityStationController(EventGenerator): ...@@ -193,32 +193,35 @@ class CapacityStationController(EventGenerator):
# 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 buffer.getActiveObjectQueue():
totalRequestedCapacity+=entity.requiredCapacity if self.checkIfProjectCanStartInStation(entity.capacityProject, station):
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 buffer.getActiveObjectQueue():
entity.shouldMove=True if self.checkIfProjectCanStartInStation(entity.capacityProject, station):
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()) entitiesInBuffer=list(buffer.getActiveObjectQueue())
# loop through the entities # loop through the entities
for entity in entitiesInBuffer: for entity in entitiesInBuffer:
# calculate what is the capacity that should proceed and what that should remain if self.checkIfProjectCanStartInStation(entity.capacityProject, station):
capacityToMove=totalAvailableCapacity*(entity.requiredCapacity)/float(totalRequestedCapacity) # calculate what is the capacity that should proceed and what that should remain
capacityToStay=entity.requiredCapacity-capacityToMove capacityToMove=totalAvailableCapacity*(entity.requiredCapacity)/float(totalRequestedCapacity)
# remove the capacity entity by the buffer so that the broken ones are created capacityToStay=entity.requiredCapacity-capacityToMove
buffer.getActiveObjectQueue().remove(entity) # remove the capacity entity by the buffer so that the broken ones are created
entityToMoveName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToMove) buffer.getActiveObjectQueue().remove(entity)
entityToMove=CapacityEntity(name=entityToMoveName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToMove) entityToMoveName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToMove)
entityToMove.initialize() entityToMove=CapacityEntity(name=entityToMoveName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToMove)
entityToMove.currentStation=buffer entityToMove.initialize()
entityToMove.shouldMove=True entityToMove.currentStation=buffer
entityToStayName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToStay) entityToMove.shouldMove=True
entityToStay=CapacityEntity(name=entityToStayName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToStay) entityToStayName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToStay)
entityToStay.initialize() entityToStay=CapacityEntity(name=entityToStayName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToStay)
entityToStay.currentStation=buffer entityToStay.initialize()
import Globals entityToStay.currentStation=buffer
Globals.setWIP([entityToMove,entityToStay]) #set the new components as wip import Globals
Globals.setWIP([entityToMove,entityToStay]) #set the new components as wip
# if the buffer is assembly there are different calculations # if the buffer is assembly there are different calculations
else: else:
# calculate the total capacity that is requested # calculate the total capacity that is requested
...@@ -324,5 +327,12 @@ class CapacityStationController(EventGenerator): ...@@ -324,5 +327,12 @@ class CapacityStationController(EventGenerator):
return False return False
# if nothing was found return true # if nothing was found return true
return True return True
# checks if the given project can start in the station or not because there is an earliest start defined
def checkIfProjectCanStartInStation(self, project, station):
earliestStartInStation=project.earliestStartDict.get(station.id, 0)
if self.env.now<earliestStartInStation:
return False
return True
\ No newline at end of file
...@@ -1262,7 +1262,8 @@ def createWIP(): ...@@ -1262,7 +1262,8 @@ def createWIP():
id=entity.get('id', 'not found') id=entity.get('id', 'not found')
name=entity.get('name', 'not found') name=entity.get('name', 'not found')
capacityRequirementDict=entity.get('capacityRequirementDict', {}) capacityRequirementDict=entity.get('capacityRequirementDict', {})
CP=CapacityProject(id=id, name=name, capacityRequirementDict=capacityRequirementDict) earliestStartDict=entity.get('earliestStartDict', {})
CP=CapacityProject(id=id, name=name, capacityRequirementDict=capacityRequirementDict, earliestStartDict=earliestStartDict)
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