Commit 72c1fba6 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Now we can check if a project can be finished at a station in the next period....

Now we can check if a project can be finished at a station in the next period. Need to see how to use it in optimization
parent 8a71ad03
......@@ -43,6 +43,9 @@ class CapacityProject(Entity):
def initialize(self):
self.projectSchedule=[] # a list of dicts to keep the schedule
self.alreadyWorkedDict={} # a dict that hold what has been processed at every station
for stationId in self.capacityRequirementDict:
self.alreadyWorkedDict[stationId]=0
# =======================================================================
# outputs results to JSON File
......
......@@ -369,5 +369,14 @@ class CapacityStationController(EventGenerator):
if self.env.now<earliestStartInStation:
return False
return True
# checks if the whole project can be finished in one station in the next time period
def checkIfAProjectCanBeFinishedInStation(self, entity, station):
required=entity.requiredCapacity
alreadyWorked=entity.capacityProject.alreadyWorkedDict[station.id]
total=entity.capacityProject.capacityRequirementDict[station.id]
if total-(alreadyWorked+required)<0.001: # a small value to avoid mistakes due to rounding
return True
return False
\ No newline at end of file
......@@ -72,4 +72,12 @@ class CapacityStationExit(Exit):
# output results only for the last exit
if not self.nextCapacityStationBuffer:
Exit.outputResultsJSON(self)
# extend so that it updates alreadyWorkedDict of the project
def getEntity(self):
activeEntity=Exit.getEntity(self)
alreadyWorkedDict=activeEntity.capacityProject.alreadyWorkedDict
stationId=self.giver.id
alreadyWorkedDict[stationId]+=activeEntity.requiredCapacity
\ No newline at end of file
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