Commit b0be22a6 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

CapacityStation updated to output the utilization for every period and the total on

parent d28c8a1f
...@@ -34,6 +34,7 @@ import simpy ...@@ -34,6 +34,7 @@ import simpy
# the CapacityStation object # the CapacityStation object
# =========================================================================== # ===========================================================================
class CapacityStation(Queue): class CapacityStation(Queue):
class_name = 'Dream.CapacityStation'
#=========================================================================== #===========================================================================
# the __init__ method of the CapacityStation # the __init__ method of the CapacityStation
...@@ -51,10 +52,27 @@ class CapacityStation(Queue): ...@@ -51,10 +52,27 @@ class CapacityStation(Queue):
Queue.initialize(self) Queue.initialize(self)
self.remainingIntervalCapacity=list(self.intervalCapacity) self.remainingIntervalCapacity=list(self.intervalCapacity)
self.isLocked=True self.isLocked=True
self.utilisationDict=[] # a list of dicts for the results
def canAccept(self, callerObject=None): def canAccept(self, callerObject=None):
if self.isLocked: if self.isLocked:
return False return False
return Queue.canAccept(self) return Queue.canAccept(self)
# =======================================================================
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
from Globals import G
json = {'_class': self.class_name,
'id': self.id,
'results': {}}
if (G.numberOfReplications == 1):
# if we had just one replication output the results as numbers
json['results']['capacityUsed']=self.utilisationDict
meanUtilization=0
for entry in self.utilisationDict:
meanUtilization+=entry['utilization']/float(len(self.utilisationDict))
json['results']['meanUtilization']=meanUtilization
G.outputJSON['elementList'].append(json)
\ No newline at end of file
...@@ -97,8 +97,12 @@ class CapacityStationController(EventGenerator): ...@@ -97,8 +97,12 @@ class CapacityStationController(EventGenerator):
station.isLocked=False # unlock the station station.isLocked=False # unlock the station
buffer=station.previous[0] # take the buffer buffer=station.previous[0] # take the buffer
buffer.sortEntities() # sort the entities of the buffer so the ones to move go in front buffer.sortEntities() # sort the entities of the buffer so the ones to move go in front
periodDict={}
periodDict['period']=self.env.now
# loop though the entities # loop though the entities
entitiesToCheck=list(buffer.getActiveObjectQueue()) entitiesToCheck=list(buffer.getActiveObjectQueue())
capacityAvailable=station.remainingIntervalCapacity[0]
capacityAllocated=0
for entity in entitiesToCheck: for entity in entitiesToCheck:
if not entity.shouldMove: # when the first entity that should not move is reached break if not entity.shouldMove: # when the first entity that should not move is reached break
break break
...@@ -106,8 +110,12 @@ class CapacityStationController(EventGenerator): ...@@ -106,8 +110,12 @@ class CapacityStationController(EventGenerator):
# wait until the entity is removed # wait until the entity is removed
yield buffer.entityRemoved yield buffer.entityRemoved
buffer.entityRemoved=self.env.event() buffer.entityRemoved=self.env.event()
periodDict[entity.capacityProject.id]=entity.requiredCapacity
capacityAllocated+=entity.requiredCapacity
# lock the station # lock the station
station.isLocked=True station.isLocked=True
periodDict['utilization']=capacityAllocated/float(capacityAvailable)
station.utilisationDict.append(periodDict)
# for every station update the remaining interval capacity so that it is ready for next loop # for every station update the remaining interval capacity so that it is ready for next loop
for station in G.CapacityStationList: for station in G.CapacityStationList:
......
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