Commit 5daca64b authored by Georgios Dagkakis's avatar Georgios Dagkakis

corrections in CapacityStationController. Cleanup needed

parent e62c5715
...@@ -100,6 +100,9 @@ class CapacityStation(Queue): ...@@ -100,6 +100,9 @@ class CapacityStation(Queue):
meanUtilization=0 meanUtilization=0
for entry in self.utilisationDict: for entry in self.utilisationDict:
meanUtilization+=entry['utilization']/float(len(self.utilisationDict)) meanUtilization+=entry['utilization']/float(len(self.utilisationDict))
if entry['utilization']>1.0:
print '*************'
print self.id, entry['period'],entry['utilization']
json['results']['meanUtilization']=meanUtilization json['results']['meanUtilization']=meanUtilization
json['results']['detailedWorkPlan']=self.detailedWorkPlan json['results']['detailedWorkPlan']=self.detailedWorkPlan
G.outputJSON['elementList'].append(json) G.outputJSON['elementList'].append(json)
...@@ -227,15 +227,22 @@ class CapacityStationController(EventGenerator): ...@@ -227,15 +227,22 @@ class CapacityStationController(EventGenerator):
assert availableSpace>=0, 'negative available space' assert availableSpace>=0, 'negative available space'
# list to hold the buffers that are already considered (due to shared resources) # list to hold the buffers that are already considered (due to shared resources)
alreadyConsideredBuffers = [] alreadyConsideredBuffers = []
# loop through the capacity station buffers # loop through the capacity station buffers
for buffer in G.CapacityStationBufferList: for buffer in G.CapacityStationBufferList:
pr = False
if self.env.now==21.0:
if buffer.id=='ASBTST_B':
pass
print 'FOUND'
pr=True
# if the buffer was considered before (due to shared resources) continue # if the buffer was considered before (due to shared resources) continue
if buffer in alreadyConsideredBuffers: if buffer in alreadyConsideredBuffers:
continue continue
alreadyConsideredBuffers.append(buffer) alreadyConsideredBuffers.append(buffer)
sharedBuffers = [] sharedBuffers = []
station=buffer.next[0] # get the station station=buffer.next[0] # get the station
# find the stations that share resources with the one considered now # find the stations that share resources with the one considered now
if station.sharedResources: if station.sharedResources:
sharedStations = station.sharedResources.get('stationIds',[]) sharedStations = station.sharedResources.get('stationIds',[])
...@@ -294,23 +301,33 @@ class CapacityStationController(EventGenerator): ...@@ -294,23 +301,33 @@ class CapacityStationController(EventGenerator):
for entity in entitiesWithinThreshold: for entity in entitiesWithinThreshold:
# get buffer where the entity is and the station it requests to get in # get buffer where the entity is and the station it requests to get in
entityBuffer=entity.currentStation entityBuffer=entity.currentStation
entityStation=entity.currentStation.next[0] entityStation=entity.currentStation.next[0]
if pr:
print '----->checking', entity.capacityProject.id
print self.checkIfThereIsEnoughSpace(entity, entityBuffer, consideredSpace)
if self.checkIfProjectCanStartInStation(entity.capacityProject, entityStation) and\ if self.checkIfProjectCanStartInStation(entity.capacityProject, entityStation) and\
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, entityBuffer))\ (not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, entityBuffer))\
and self.checkIfThereIsEnoughSpace(entity, entityBuffer, consideredSpace): and self.checkIfThereIsEnoughSpace(entity, entityBuffer, consideredSpace):
consideredSpace-=entity.capacityProject.assemblySpaceRequirement if not self.checkIfProjectConsumesAssemblySpace(entity, entityBuffer):
consideredSpace-=entity.capacityProject.assemblySpaceRequirement
totalRequestedCapacity+=entity.requiredCapacity totalRequestedCapacity+=entity.requiredCapacity
if pr:
print totalRequestedCapacity
# 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:
availableCapacity=float(totalAvailableCapacity)
for entity in entitiesWithinThreshold: for entity in entitiesWithinThreshold:
# get buffer where the entity is and the station it requests to get in # get buffer where the entity is and the station it requests to get in
entityBuffer=entity.currentStation entityBuffer=entity.currentStation
entityStation=entity.currentStation.next[0] entityStation=entity.currentStation.next[0]
if self.checkIfProjectCanStartInStation(entity.capacityProject, entityStation) and\ if self.checkIfProjectCanStartInStation(entity.capacityProject, entityStation) and\
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, entityBuffer))\ (not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, entityBuffer))\
and self.checkIfThereIsEnoughSpace(entity, entityBuffer, availableSpace): and self.checkIfThereIsEnoughSpace(entity, entityBuffer, availableSpace) and\
entity.requiredCapacity<=availableCapacity:
entity.shouldMove=True entity.shouldMove=True
availableCapacity-=entity.requiredCapacity
assert availableCapacity>=0, 'negative available capacity'
# reduce the available space if there is need to # reduce the available space if there is need to
if entityBuffer.requireFullProject and \ if entityBuffer.requireFullProject and \
(not self.checkIfProjectConsumesAssemblySpace(entity, entityBuffer)): (not self.checkIfProjectConsumesAssemblySpace(entity, entityBuffer)):
...@@ -380,9 +397,14 @@ class CapacityStationController(EventGenerator): ...@@ -380,9 +397,14 @@ class CapacityStationController(EventGenerator):
# update the values # update the values
totalAvailableCapacity-=entity.requiredCapacity totalAvailableCapacity-=entity.requiredCapacity
totalRequestedCapacity-=entity.requiredCapacity totalRequestedCapacity-=entity.requiredCapacity
# else break the entity according to rule # else break the entity according to rule
else: else:
if pr:
print 'breaking entity',entity.capacityProject.id
print totalAvailableCapacity
print totalRequestedCapacity
print entity.requiredCapacity
print totalAvailableCapacity*(entity.requiredCapacity)/float(totalRequestedCapacity)
if self.breakEntity(entity, entityBuffer, entityStation, if self.breakEntity(entity, entityBuffer, entityStation,
totalAvailableCapacity, totalRequestedCapacity): totalAvailableCapacity, totalRequestedCapacity):
# reduce the available space if there is need to # reduce the available space if there is need to
......
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