Commit 3d7e4ee8 authored by Georgios Dagkakis's avatar Georgios Dagkakis

capacity instance updated so that the user can define pool of capacity

parent 2db61a50
......@@ -12,24 +12,55 @@ class AvailableCapacitySpreadsheet(plugin.InputPreparationPlugin):
read capacity data and update the capacity property of the stations.
"""
def preprocess(self, data):
def preprocess(self, data):
strptime = datetime.datetime.strptime
capacityData=data['input'].get('available_capacity_spreadsheet', None)
node=data['graph']['node']
nodes=data['graph']['node']
now = strptime(data['general']['currentDate'], '%Y/%m/%d')
if capacityData:
# get the number of stations
numberOfStations=len([st for st in capacityData[0] if (st and not st=='DAY')])
if capacityData:
poolDict={}
for node_id, node in nodes.iteritems():
pool=node.get('pool',None)
if pool and not pool in nodes.keys():
if not poolDict.get(pool,None):
poolDict[pool]=[]
poolDict[pool].append(node_id)
# loop through columns and get those that contain a pool
columnsToErase=[]
for col in range(len(copy(capacityData[0]))):
# if the column contains a pool create new columns with the actual station id
if capacityData[0][col] in poolDict.keys():
pool=capacityData[0][col]
if pool in ['DAY',None,'']:
continue
poolCapacity=[c[col] for c in capacityData]
columnsToErase.append(col)
for stationId in poolDict[pool]:
capacityData[0].append(stationId)
i=1
for row in capacityData[1:]:
row.append(poolCapacity[i])
i+=1
# erase the columns that contain pools
for col in columnsToErase:
for row in capacityData:
row.pop(col)
# loop through stations
for col in range(numberOfStations):
stationId=capacityData[0][col+1]
for col in range(len(capacityData[0])):
stationId=capacityData[0][col]
if stationId in ['DAY',None,'']:
continue
assert stationId in data['graph']['node'].keys(), ('available capacity spreadsheet has station id:',stationId,
'that does not exist in production line')
# for every station read the interval capacity (Monday to Sunday)
intervalCapacity=[]
for row in range(7):
intervalCapacity.append(float(capacityData[row+1][col+1]))
node[stationId]['intervalCapacity']=intervalCapacity
intervalCapacity.append(float(capacityData[row+1][col]))
nodes[stationId]['intervalCapacity']=intervalCapacity
# for every station read the interval capacity exceptions
for row in range(8,len(capacityData)):
# at the first empty line break
......@@ -38,12 +69,13 @@ class AvailableCapacitySpreadsheet(plugin.InputPreparationPlugin):
exeptionDate=strptime(capacityData[row][0], '%Y/%m/%d')
dayDifference=(exeptionDate-now).days
assert dayDifference>=0, 'exception date for past day given'
intervalCapacityExceptions=node[stationId].get('intervalCapacityExceptions',{})
intervalCapacityExceptions=nodes[stationId].get('intervalCapacityExceptions',{})
if not intervalCapacityExceptions:
node[stationId]['intervalCapacityExceptions']={}
node[stationId]['intervalCapacityExceptions'][str(float(dayDifference))]=float(capacityData[row][col+1])
nodes[stationId]['intervalCapacityExceptions']={}
nodes[stationId]['intervalCapacityExceptions'][str(float(dayDifference))]=float(capacityData[row][col])
# set the interval capacity start
node[stationId]['intervalCapacityStart']=now.weekday()
nodes[stationId]['intervalCapacityStart']=now.weekday()
return data
\ No newline at end of file
......@@ -410,6 +410,12 @@
"description": "Is this station an assembly? Yes: 1, No: 0",
"type": "number",
"required": true
},
"pool": {
"_default": "",
"description": "The pool of workers that is used for this station. If this station does not share resources leave empty",
"type": "string",
"required": false
}
}
}
......
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