Commit 1fcc8ffa authored by Georgios Dagkakis's avatar Georgios Dagkakis

changes in the algorithm copied

parent 83f69770
...@@ -34,8 +34,13 @@ class DemandPlanningLine(plugin.OutputPreparationPlugin, TimeSupportMixin): ...@@ -34,8 +34,13 @@ class DemandPlanningLine(plugin.OutputPreparationPlugin, TimeSupportMixin):
options = { options = {
"xaxis": { "xaxis": {
"mode": "time", "mode": "time",
"minTickSize": [1, self.getTimeUnitText()], #"minTickSize": [1, self.getTimeUnitText()],
} "minTickSize": [1, "day"],
},
"legend": {
"backgroundOpacity": 0.1,
"position":"se",
},
} }
bottleNeckUtilizationDict[bottleneck] = { bottleNeckUtilizationDict[bottleneck] = {
...@@ -84,13 +89,18 @@ class BottleNeckByWeek(plugin.OutputPreparationPlugin, TimeSupportMixin): ...@@ -84,13 +89,18 @@ class BottleNeckByWeek(plugin.OutputPreparationPlugin, TimeSupportMixin):
for week, bottleneckData in by_week.items(): for week, bottleneckData in by_week.items():
series = [] series = []
ticks = list(enumerate(bottleneckData.keys())) #ticks = list(enumerate(bottleneckData.keys()))
ticks = list(enumerate(G.Bottlenecks))
options = { options = {
"xaxis": { "xaxis": {
"minTickSize": 1, "minTickSize": 1,
"ticks": ticks "ticks": ticks
}, },
"legend": {
"backgroundOpacity": 0.1,
"position":"se",
},
"series": { "series": {
"bars": { "bars": {
"show": True, "show": True,
...@@ -115,7 +125,7 @@ class BottleNeckByWeek(plugin.OutputPreparationPlugin, TimeSupportMixin): ...@@ -115,7 +125,7 @@ class BottleNeckByWeek(plugin.OutputPreparationPlugin, TimeSupportMixin):
( 'maxUtilization', 'Target Utilization' ) ]: ( 'maxUtilization', 'Target Utilization' ) ]:
series.append({ series.append({
"label": utilizationLabel, "label": utilizationLabel,
"data": list(enumerate([x[utilizationType] for x in bottleneckData.values()])), "data": list(enumerate([bottleneckData[x][utilizationType] for x in G.Bottlenecks])),
}) })
return data return data
\ No newline at end of file
...@@ -150,9 +150,9 @@ def AllocationRoutine_Final(initialWeek, itemList, itemType, ant): ...@@ -150,9 +150,9 @@ def AllocationRoutine_Final(initialWeek, itemList, itemType, ant):
# for orders add allocation information # for orders add allocation information
if itemType == 'order': if itemType == 'order':
if chosenMA == None: if chosenMA == None:
G.OrderResults.append((item['orderID'], item['sp'], item['MAlist'], item['Week'], item['Customer'], item['Qty'], item['priority'], chosenMA, oMAlist2, 'NaN', 'NaN', 'None')) G.OrderResults.append((item['orderID'], item['sp'], item['MAlist'], item['Week'], item['Qty'], item['priority'], chosenMA, oMAlist2, 'NaN', 'NaN', 'None'))
else: else:
G.OrderResults.append((item['orderID'], item['sp'], item['MAlist'], item['Week'], item['Customer'], item['Qty'], item['priority'], chosenMA, oMAlist2, Results[chosenMA]['lateness'], Results[chosenMA]['earliness'], Results[chosenMA]['Allocation'])) G.OrderResults.append((item['orderID'], item['sp'], item['MAlist'], item['Week'], item['Qty'], item['priority'], chosenMA, oMAlist2, Results[chosenMA]['lateness'], Results[chosenMA]['earliness'], Results[chosenMA]['Allocation']))
if itemType == 'forecast': if itemType == 'forecast':
if chosenMA == None: if chosenMA == None:
...@@ -180,8 +180,15 @@ def choseMA(allResults, possibleSolutions, MAlist, weeklist): ...@@ -180,8 +180,15 @@ def choseMA(allResults, possibleSolutions, MAlist, weeklist):
for week in weeklist: for week in weeklist:
for bn in allResults[ma]['utilisation']: for bn in allResults[ma]['utilisation']:
if week in allResults[ma]['utilisation'][bn]: if week in allResults[ma]['utilisation'][bn]:
minUtil.append(max(0, (G.Capacity[bn][week]['minUtilisation']-allResults[ma]['utilisation'][bn][week])/G.Capacity[bn][week]['minUtilisation'])) if G.Capacity[bn][week]['minUtilisation']:
targetUtil.append((G.Capacity[bn][week]['targetUtilisation']-allResults[ma]['utilisation'][bn][week])/G.Capacity[bn][week]['targetUtilisation']) minUtil.append(max(0, (G.Capacity[bn][week]['minUtilisation']-allResults[ma]['utilisation'][bn][week])/G.Capacity[bn][week]['minUtilisation']))
else:
minUtil.append(max(0, (G.Capacity[bn][week]['minUtilisation']-allResults[ma]['utilisation'][bn][week])))
if G.Capacity[bn][week]['targetUtilisation']:
targetUtil.append((G.Capacity[bn][week]['targetUtilisation']-allResults[ma]['utilisation'][bn][week])/G.Capacity[bn][week]['targetUtilisation'])
else:
targetUtil.append(G.Capacity[bn][week]['targetUtilisation']-allResults[ma]['utilisation'][bn][week])
res.append([ma, allResults[ma]['remainingUnits'], allResults[ma]['lateness'], std(array(targetUtil)), std(array(minUtil)), allResults[ma]['earliness']]) res.append([ma, allResults[ma]['remainingUnits'], allResults[ma]['lateness'], std(array(targetUtil)), std(array(minUtil)), allResults[ma]['earliness']])
...@@ -218,13 +225,20 @@ def choseMA2(allResults, possibleSolutions, MAlist, weeklist): # more simil ...@@ -218,13 +225,20 @@ def choseMA2(allResults, possibleSolutions, MAlist, weeklist): # more simil
targetU = [] targetU = []
for week in weeklist: for week in weeklist:
utilisation = float(G.Capacity[bottleneck][week]['OriginalCapacity'] - allResults[ma]['remainingCap'][bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity'] utilisation = float(G.Capacity[bottleneck][week]['OriginalCapacity'] - allResults[ma]['remainingCap'][bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity']
minU.append(max(0, (G.Capacity[bottleneck][week]['minUtilisation']-utilisation)/G.Capacity[bottleneck][week]['minUtilisation'])) if G.Capacity[bottleneck][week]['minUtilisation']:
targetU.append((utilisation - G.Capacity[bottleneck][week]['targetUtilisation'])/G.Capacity[bottleneck][week]['targetUtilisation']) minU.append(max(0, (G.Capacity[bottleneck][week]['minUtilisation']-utilisation)/G.Capacity[bottleneck][week]['minUtilisation']))
else:
minU.append(max(0, (G.Capacity[bottleneck][week]['minUtilisation']-utilisation)))
if G.Capacity[bottleneck][week]['targetUtilisation']:
targetU.append((utilisation - G.Capacity[bottleneck][week]['targetUtilisation'])/G.Capacity[bottleneck][week]['targetUtilisation'])
else:
targetU.append((utilisation - G.Capacity[bottleneck][week]['targetUtilisation']))
minUtil.append(mean(array(minU))) minUtil.append(mean(array(minU)))
targetUtil.append(mean(absolute(targetU))) targetUtil.append(mean(absolute(targetU)))
res.append([ma, allResults[ma]['remainingUnits'], allResults[ma]['lateness'], std(array(targetUtil)), std(array(minUtil)), allResults[ma]['earliness']]) res.append([ma, allResults[ma]['remainingUnits'], allResults[ma]['lateness'], mean(array(targetUtil)), mean(array(minUtil)), allResults[ma]['earliness']])
# order results...1st criterion: target utilisation (stdDev), 2nd criterion: min utilisation(stdDev) # order results...1st criterion: target utilisation (stdDev), 2nd criterion: min utilisation(stdDev)
sortedMA = sorted(res, key=itemgetter(1, 2, 3, 4, 5)) sortedMA = sorted(res, key=itemgetter(1, 2, 3, 4, 5))
...@@ -242,4 +256,4 @@ def choseMA2(allResults, possibleSolutions, MAlist, weeklist): # more simil ...@@ -242,4 +256,4 @@ def choseMA2(allResults, possibleSolutions, MAlist, weeklist): # more simil
assert(chosenMA in possibleSolutions) assert(chosenMA in possibleSolutions)
return chosenMA, sortedMA return chosenMA, sortedMA
\ No newline at end of file
...@@ -80,7 +80,7 @@ class G: ...@@ -80,7 +80,7 @@ class G:
# output variables # output variables
reportResults = tablib.Databook() reportResults = tablib.Databook()
OrderResults = tablib.Dataset(title='OrderSummary') OrderResults = tablib.Dataset(title='OrderSummary')
OrderResults.headers = ('OrderID', 'SP_NUMBER', 'MA_LIST', 'REQUEST_DATE', 'DFSELLER', 'ORDERQTY', 'PRIORITY', 'CHOSEN_MA','ORDERED_MA_LIST', 'LATENESS', 'EARLINESS', 'ALLOCATION') OrderResults.headers = ('OrderID', 'SP_NUMBER', 'MA_LIST', 'REQUEST_DATE', 'ORDERQTY', 'PRIORITY', 'CHOSEN_MA','ORDERED_MA_LIST', 'LATENESS', 'EARLINESS', 'ALLOCATION')
forecastResults = tablib.Dataset(title='ForecastSummary') forecastResults = tablib.Dataset(title='ForecastSummary')
forecastResults.headers = ('PPOS', 'SP_NUMBER', 'MA_LIST', 'REQUEST_DATE', 'ORDERQTY', 'PRIORITY', 'CHOSEN_MA', 'LATENESS', 'EARLINESS', 'ALLOCATION') forecastResults.headers = ('PPOS', 'SP_NUMBER', 'MA_LIST', 'REQUEST_DATE', 'ORDERQTY', 'PRIORITY', 'CHOSEN_MA', 'LATENESS', 'EARLINESS', 'ALLOCATION')
globalMAAllocation = {} globalMAAllocation = {}
...@@ -150,7 +150,7 @@ def initialiseVar(): ...@@ -150,7 +150,7 @@ def initialiseVar():
# output variables # output variables
G.reportResults = tablib.Databook() G.reportResults = tablib.Databook()
G.OrderResults = tablib.Dataset(title='OrderSummary') G.OrderResults = tablib.Dataset(title='OrderSummary')
G.OrderResults.headers = ('OrderID', 'SP_NUMBER', 'MA_LIST', 'REQUEST_DATE', 'DFSELLER', 'ORDERQTY', 'PRIORITY', 'CHOSEN_MA','ORDERED_MA_LIST', 'LATENESS', 'EARLINESS', 'ALLOCATION') G.OrderResults.headers = ('OrderID', 'SP_NUMBER', 'MA_LIST', 'REQUEST_DATE', 'ORDERQTY', 'PRIORITY', 'CHOSEN_MA','ORDERED_MA_LIST', 'LATENESS', 'EARLINESS', 'ALLOCATION')
G.forecastResults = tablib.Dataset(title='ForecastSummary') G.forecastResults = tablib.Dataset(title='ForecastSummary')
G.forecastResults.headers = ('PPOS', 'SP_NUMBER', 'MA_LIST', 'REQUEST_DATE', 'ORDERQTY', 'PRIORITY', 'CHOSEN_MA', 'LATENESS', 'EARLINESS', 'ALLOCATION') G.forecastResults.headers = ('PPOS', 'SP_NUMBER', 'MA_LIST', 'REQUEST_DATE', 'ORDERQTY', 'PRIORITY', 'CHOSEN_MA', 'LATENESS', 'EARLINESS', 'ALLOCATION')
G.CapacityResults = None G.CapacityResults = None
......
...@@ -50,6 +50,7 @@ def ImportInput(input, algorithmAttributes): ...@@ -50,6 +50,7 @@ def ImportInput(input, algorithmAttributes):
wbin = xlrd.open_workbook(file_contents=attachement_data) wbin = xlrd.open_workbook(file_contents=attachement_data)
G.maxEarliness = algorithmAttributes.get('maxEarliness',None) G.maxEarliness = algorithmAttributes.get('maxEarliness',None)
G.maxLateness = algorithmAttributes.get('maxLateness',None) G.maxLateness = algorithmAttributes.get('maxLateness',None)
startWeek = algorithmAttributes.get('CurrentWeek',None)
# utilisation calculation # utilisation calculation
G.minDeltaUt = algorithmAttributes.get('minDelta',None) G.minDeltaUt = algorithmAttributes.get('minDelta',None)
...@@ -81,12 +82,24 @@ def ImportInput(input, algorithmAttributes): ...@@ -81,12 +82,24 @@ def ImportInput(input, algorithmAttributes):
sh = wbin.sheet_by_name('BN_Capa') sh = wbin.sheet_by_name('BN_Capa')
rows = sh.nrows rows = sh.nrows
G.planningHorizon = sh.ncols - 2
Weeks = {} Weeks = {}
for week in range(2,sh.ncols): w = 2
while w<sh.ncols and withoutFormat(1,w,sh,1) != startWeek:
w += 1
if w == sh.ncols:
print "please enter a valid week value"
return "stop"
refCap = {}
noTarget = []
for week in range(w,sh.ncols):
Weeks[week] = withoutFormat(1,week,sh,1) Weeks[week] = withoutFormat(1,week,sh,1)
G.WeekList.append(withoutFormat(1,week,sh,1)) G.WeekList.append(withoutFormat(1,week,sh,1))
refCap[Weeks[week]] = 1
G.planningHorizon = len(G.WeekList)
for row in range(2,rows,4): for row in range(2,rows,4):
bn = withoutFormat(row,0,sh,0) bn = withoutFormat(row,0,sh,0)
...@@ -95,18 +108,42 @@ def ImportInput(input, algorithmAttributes): ...@@ -95,18 +108,42 @@ def ImportInput(input, algorithmAttributes):
G.Capacity[bn] = {}#{'OriginalCapacity':{}, 'RemainingCapacity':{}, 'minUtilisation':{}, 'targetUtilisation':{}} G.Capacity[bn] = {}#{'OriginalCapacity':{}, 'RemainingCapacity':{}, 'minUtilisation':{}, 'targetUtilisation':{}}
G.CurrentCapacityDictOrig[bn] = {} G.CurrentCapacityDictOrig[bn] = {}
for week in range(2,sh.ncols): for week in range(w,sh.ncols):
G.Capacity[bn][Weeks[week]]={'OriginalCapacity':withoutFormat(row,week,sh,1), 'RemainingCapacity':withoutFormat(row+1,week,sh,1), 'minUtilisation':withoutFormat(row+2,week,sh,0), 'targetUtilisation':withoutFormat(row+3,week,sh,0)} G.Capacity[bn][Weeks[week]]={'OriginalCapacity':withoutFormat(row,week,sh,1), 'RemainingCapacity':withoutFormat(row+1,week,sh,1), 'minUtOrig':withoutFormat(row+2,week,sh,0), 'targetUtOrig':withoutFormat(row+3,week,sh,0)}
if G.Capacity[bn][Weeks[week]]['minUtOrig'] == '':
G.Capacity[bn][Weeks[week]]['minUtilisation'] = 0
else:
G.Capacity[bn][Weeks[week]]['minUtilisation'] = G.Capacity[bn][Weeks[week]]['minUtOrig']
if G.Capacity[bn][Weeks[week]]['targetUtOrig'] == '':
G.Capacity[bn][Weeks[week]]['targetUtilisation'] = 1
noTarget.append([bn, Weeks[week]])
else:
G.Capacity[bn][Weeks[week]]['targetUtilisation'] = G.Capacity[bn][Weeks[week]]['targetUtOrig']
if G.Capacity[bn][Weeks[week]]['targetUtOrig'] < refCap[Weeks[week]]:
refCap[Weeks[week]] = G.Capacity[bn][Weeks[week]]['targetUtOrig']
G.CurrentCapacityDictOrig[bn][Weeks[week]] = withoutFormat(row,week,sh,1) G.CurrentCapacityDictOrig[bn][Weeks[week]] = withoutFormat(row,week,sh,1)
for coppie in noTarget:
if refCap[coppie[1]] == 1:
refCap[coppie[1]] = 0
G.Capacity[coppie[0]][coppie[1]]['targetUtilisation'] = refCap[coppie[1]]
# Import loading factors # Import loading factors
sh = wbin.sheet_by_name('BN_Load Factor') sh = wbin.sheet_by_name('BN_Load Factor')
rows = sh.nrows rows = sh.nrows
w = 3
while withoutFormat(1,w,sh,1) != startWeek:
w += 1
Weeks = {} Weeks = {}
for week in range(3,sh.ncols): for week in range(w,sh.ncols):
Weeks[week] = withoutFormat(1,week,sh,1) Weeks[week] = withoutFormat(1,week,sh,1)
for row in range(2,rows): for row in range(2,rows):
...@@ -125,15 +162,19 @@ def ImportInput(input, algorithmAttributes): ...@@ -125,15 +162,19 @@ def ImportInput(input, algorithmAttributes):
bn = withoutFormat(row,2,sh,0) bn = withoutFormat(row,2,sh,0)
G.RouteDict[ma][bn] = {} G.RouteDict[ma][bn] = {}
for week in range(3,sh.ncols): for week in range(w,sh.ncols):
G.RouteDict[ma][bn][Weeks[week]] = withoutFormat(row,week,sh,0) G.RouteDict[ma][bn][Weeks[week]] = withoutFormat(row,week,sh,0)
# Import batch size # Import batch size
sh = wbin.sheet_by_name('BatchSize') sh = wbin.sheet_by_name('BatchSize')
rows = sh.nrows rows = sh.nrows
w = 2
while withoutFormat(2,w,sh,1) != startWeek:
w += 1
Weeks = {} Weeks = {}
for week in range(2,sh.ncols): for week in range(w,sh.ncols):
Weeks[week] = withoutFormat(2,week,sh,1) Weeks[week] = withoutFormat(2,week,sh,1)
for row in range(3,rows): for row in range(3,rows):
...@@ -144,7 +185,7 @@ def ImportInput(input, algorithmAttributes): ...@@ -144,7 +185,7 @@ def ImportInput(input, algorithmAttributes):
G.BatchSize[ma]= {} G.BatchSize[ma]= {}
G.incompleteBatches[ma] = 0 G.incompleteBatches[ma] = 0
for week in range(2,sh.ncols): for week in range(w,sh.ncols):
G.BatchSize[ma][Weeks[week]] = withoutFormat(row,week,sh,0) G.BatchSize[ma][Weeks[week]] = withoutFormat(row,week,sh,0)
# G.incompleteBatches[ma][Weeks[week]] = 0 # G.incompleteBatches[ma][Weeks[week]] = 0
...@@ -153,24 +194,28 @@ def ImportInput(input, algorithmAttributes): ...@@ -153,24 +194,28 @@ def ImportInput(input, algorithmAttributes):
sh = wbin.sheet_by_name('OrderSummary') sh = wbin.sheet_by_name('OrderSummary')
rows = sh.nrows rows = sh.nrows
orderID = 1
G.priorityList['order'] = [] G.priorityList['order'] = []
G.sortedOrders['order'] = {} G.sortedOrders['order'] = {}
for row in range(1,rows): for row in range(1,rows):
week = withoutFormat(row,3,sh,1)
if week < startWeek:
continue
orderID = withoutFormat(row,2,sh,0)
G.orders[orderID] = {} G.orders[orderID] = {}
G.orders[orderID]['orderID'] = orderID G.orders[orderID]['orderID'] = orderID
G.orders[orderID]['ppos'] = 0 G.orders[orderID]['sp'] = withoutFormat(row,0,sh,0)
G.orders[orderID]['sp'] = withoutFormat(row,1,sh,0) maList = withoutFormat(row,1,sh,0)
maList = withoutFormat(row,2,sh,0)
maList = my_split(maList, ['; ', ';']) maList = my_split(maList, ['; ', ';'])
print 'malist', maList
maList.remove('') maList.remove('')
G.orders[orderID]['MAlist'] = maList G.orders[orderID]['MAlist'] = maList
week = withoutFormat(row,3,sh,1)
G.orders[orderID]['Week'] = week G.orders[orderID]['Week'] = week
G.orders[orderID]['Customer'] = withoutFormat(row, 4, sh, 0) G.orders[orderID]['Qty'] = withoutFormat(row, 4, sh, 0)
G.orders[orderID]['Qty'] = withoutFormat(row, 5, sh, 0) priority = withoutFormat(row, 5, sh, 1)
priority = withoutFormat(row, 6, sh, 1)
G.orders[orderID]['priority'] = priority G.orders[orderID]['priority'] = priority
if priority not in G.priorityList['order']: if priority not in G.priorityList['order']:
G.priorityList['order'].append(priority) G.priorityList['order'].append(priority)
...@@ -179,19 +224,22 @@ def ImportInput(input, algorithmAttributes): ...@@ -179,19 +224,22 @@ def ImportInput(input, algorithmAttributes):
if week not in G.sortedOrders['order'][priority]: if week not in G.sortedOrders['order'][priority]:
G.sortedOrders['order'][priority][week] = [] G.sortedOrders['order'][priority][week] = []
G.sortedOrders['order'][priority][week].append(G.orders[orderID]) G.sortedOrders['order'][priority][week].append(G.orders[orderID])
orderID += 1
print 'sorted orders keys', G.sortedOrders['order'].keys()
# Import forecast # Import forecast
sh = wbin.sheet_by_name('FC_Summary') sh = wbin.sheet_by_name('FC_Summary')
rows = sh.nrows rows = sh.nrows
G.priorityList['forecast'] = [] G.priorityList['forecast'] = []
G.sortedOrders['forecast'] = {} G.sortedOrders['forecast'] = {}
Weeks = {} Weeks = {}
w = 3
while withoutFormat(1,w,sh,1) != startWeek:
w += 1
for week in range(3,sh.ncols): for week in range(3,sh.ncols):
Weeks[week] = withoutFormat(1,week,sh,1) Weeks[week] = withoutFormat(1,week,sh,1)
row = 2 row = w
while row < rows: while row < rows:
newSp = withoutFormat(row,1,sh,0) newSp = withoutFormat(row,1,sh,0)
...@@ -210,6 +258,8 @@ def ImportInput(input, algorithmAttributes): ...@@ -210,6 +258,8 @@ def ImportInput(input, algorithmAttributes):
subRow += 1 subRow += 1
print 'ma sug', maSuggested, subRow print 'ma sug', maSuggested, subRow
oID = 1
orderID = 'Forecast_'+str(oID)
for week in range(4,sh.ncols): for week in range(4,sh.ncols):
qty = withoutFormat(row+subRow,week,sh,1) qty = withoutFormat(row+subRow,week,sh,1)
if qty: if qty:
...@@ -233,7 +283,8 @@ def ImportInput(input, algorithmAttributes): ...@@ -233,7 +283,8 @@ def ImportInput(input, algorithmAttributes):
if Weeks[week] not in G.sortedOrders['forecast'][priority]: if Weeks[week] not in G.sortedOrders['forecast'][priority]:
G.sortedOrders['forecast'][priority][Weeks[week]] = [] G.sortedOrders['forecast'][priority][Weeks[week]] = []
G.sortedOrders['forecast'][priority][Weeks[week]].append(G.orders[orderID]) G.sortedOrders['forecast'][priority][Weeks[week]].append(G.orders[orderID])
orderID += 1 oID += 1
orderID = 'Forecast_'+str(oID)
row += subRow+1 row += subRow+1
...@@ -260,7 +311,7 @@ def ImportInput(input, algorithmAttributes): ...@@ -260,7 +311,7 @@ def ImportInput(input, algorithmAttributes):
for priority in G.priorityList['forecast']: for priority in G.priorityList['forecast']:
G.globalMAAllocation[ma][week]['forecast'][priority] = 0 G.globalMAAllocation[ma][week]['forecast'][priority] = 0
G.globalMAAllocationIW[ma][week]['forecast'][priority] = 0 G.globalMAAllocationIW[ma][week]['forecast'][priority] = 0
# set lateness and earliness results # set lateness and earliness results
for week in G.WeekList: for week in G.WeekList:
G.Lateness[week] = {} G.Lateness[week] = {}
...@@ -275,10 +326,11 @@ def ImportInput(input, algorithmAttributes): ...@@ -275,10 +326,11 @@ def ImportInput(input, algorithmAttributes):
G.Excess[sp] = {} G.Excess[sp] = {}
for week in G.WeekList: for week in G.WeekList:
G.Excess[sp][week] = 0 G.Excess[sp][week] = 0
G.ordersOrig = deepcopy(G.orders) G.ordersOrig = deepcopy(G.orders)
G.sortedOrdersOrig = deepcopy(G.sortedOrders) G.sortedOrdersOrig = deepcopy(G.sortedOrders)
if __name__ == '__main__': if __name__ == '__main__':
ImportInput() ImportInput()
\ No newline at end of file
\ No newline at end of file
...@@ -51,12 +51,15 @@ def utilisationCalc1(ACOcapacityDict, initialWeek, ind): ...@@ -51,12 +51,15 @@ def utilisationCalc1(ACOcapacityDict, initialWeek, ind):
for week in weekList: for week in weekList:
utilisation = float(G.Capacity[bottleneck][week]['OriginalCapacity']-ACOcapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity'] utilisation = float(G.Capacity[bottleneck][week]['OriginalCapacity']-ACOcapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity']
minU.append(utilisation > G.Capacity[bottleneck][week]['minUtilisation']) minU.append(utilisation > G.Capacity[bottleneck][week]['minUtilisation'])
targetU.append(float(utilisation - G.Capacity[bottleneck][week]['targetUtilisation'])/G.Capacity[bottleneck][week]['targetUtilisation']) if G.Capacity[bottleneck][week]['targetUtilisation']:
targetU.append(float(utilisation - G.Capacity[bottleneck][week]['targetUtilisation'])/G.Capacity[bottleneck][week]['targetUtilisation'])
else:
targetU.append(float(utilisation - G.Capacity[bottleneck][week]['targetUtilisation']))
minUtil.append(mean(array(minU))) minUtil.append(mean(array(minU)))
targetUtil.append(mean(absolute(targetU))) targetUtil.append(mean(absolute(targetU)))
ACOtargetUtil = std(array(targetUtil)) #mean(array(targetUtil)) #FIXME: potrebbe essere std(array(targetUtil)) ACOtargetUtil = mean(array(targetUtil)) #mean(array(targetUtil)) #FIXME: potrebbe essere std(array(targetUtil))
ACOminUtil = mean(array(minUtil))*-1 ACOminUtil = mean(array(minUtil))*-1
return ACOtargetUtil, ACOminUtil return ACOtargetUtil, ACOminUtil
...@@ -72,11 +75,14 @@ def utilisationCalc2(ACOcapacityDict, initialWeek, ind): ...@@ -72,11 +75,14 @@ def utilisationCalc2(ACOcapacityDict, initialWeek, ind):
minUtil = [] minUtil = []
targetUtil = [] targetUtil = []
for bottleneck in G.Bottlenecks: for bottleneck in G.Bottlenecks:
weekList = [initialWeek] + [G.WeekList[i] for i in range(ind-1, max(-1,ind-G.maxEarliness-1), -1)] weekList = [initialWeek] #+ [G.WeekList[i] for i in range(ind-1, max(-1,ind-G.maxEarliness-1), -1)]
for week in weekList: for week in weekList:
utilisation = float(G.Capacity[bottleneck][week]['OriginalCapacity']-ACOcapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity'] utilisation = float(G.Capacity[bottleneck][week]['OriginalCapacity']-ACOcapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity']
minUtil.append(utilisation > G.Capacity[bottleneck][week]['minUtilisation']) minUtil.append(utilisation > G.Capacity[bottleneck][week]['minUtilisation'])
targetUtil.append(float(utilisation - G.Capacity[bottleneck][week]['targetUtilisation'])/G.Capacity[bottleneck][week]['targetUtilisation']) if G.Capacity[bottleneck][week]['targetUtilisation']:
targetUtil.append(float(utilisation - G.Capacity[bottleneck][week]['targetUtilisation'])/G.Capacity[bottleneck][week]['targetUtilisation'])
else:
targetUtil.append(float(utilisation - G.Capacity[bottleneck][week]['targetUtilisation']))
ACOtargetUtil = std(array(targetUtil)) ACOtargetUtil = std(array(targetUtil))
ACOminUtil = mean(array(minUtil))*-1 ACOminUtil = mean(array(minUtil))*-1
...@@ -100,7 +106,10 @@ def utilisationCalc3(ACOcapacityDict, initialWeek, ind): ...@@ -100,7 +106,10 @@ def utilisationCalc3(ACOcapacityDict, initialWeek, ind):
for week in weekList: for week in weekList:
utilisation = float(G.Capacity[bottleneck][week]['OriginalCapacity']-ACOcapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity'] utilisation = float(G.Capacity[bottleneck][week]['OriginalCapacity']-ACOcapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity']
minU.append(utilisation) minU.append(utilisation)
targetU.append(float(utilisation - G.Capacity[bottleneck][week]['targetUtilisation'])/G.Capacity[bottleneck][week]['targetUtilisation']) if G.Capacity[bottleneck][week]['targetUtilisation']:
targetU.append(float(utilisation - G.Capacity[bottleneck][week]['targetUtilisation'])/G.Capacity[bottleneck][week]['targetUtilisation'])
else:
targetU.append(float(utilisation - G.Capacity[bottleneck][week]['targetUtilisation']))
minUtil.append(mean(array(minU))) minUtil.append(mean(array(minU)))
targetUtil.append(mean(array(max(minU)))) targetUtil.append(mean(array(max(minU))))
...@@ -108,4 +117,4 @@ def utilisationCalc3(ACOcapacityDict, initialWeek, ind): ...@@ -108,4 +117,4 @@ def utilisationCalc3(ACOcapacityDict, initialWeek, ind):
ACOtargetUtil = max(targetUtil) ACOtargetUtil = max(targetUtil)
ACOminUtil = mean(array(minUtil)) #FIXME: considerare piu settimane in weeklist e std(targetUtil) ACOminUtil = mean(array(minUtil)) #FIXME: considerare piu settimane in weeklist e std(targetUtil)
return ACOtargetUtil, ACOminUtil return ACOtargetUtil, ACOminUtil
\ No newline at end of file
...@@ -29,22 +29,27 @@ from ImportInput import ImportInput ...@@ -29,22 +29,27 @@ from ImportInput import ImportInput
from outputResults import outputResults from outputResults import outputResults
from Globals import G, initialiseVar from Globals import G, initialiseVar
import time import time
from numpy import mean, std, array from numpy import mean, std, array, absolute
from operator import itemgetter from operator import itemgetter
def main(input, algorithmAttributes): def main(input, algorithmAttributes):
startTime = time.time() startTime = time.time()
ImportInput(input, algorithmAttributes) ver = ImportInput(input, algorithmAttributes)
if str(G.ACO).lower() == "all": if ver == "stop":
return
if G.ACO == "all":
G.acoRange = [0,1] G.acoRange = [0,1]
G.minRange = {0:[0,1],1:[0,1]} G.minRange = {0:[0,1],1:[0,1]}
elif str(G.ACO) == "1": elif G.ACO == "1":
G.acoRange = [0,1] G.acoRange = [1]
G.minRange = {0:[0,1],1:[G.minDeltaUt]} G.minRange = {0:[0,1], 1:[G.minDeltaUt]}
else: else:
G.acoRange = [0] G.acoRange = [0]
G.minRange = {0:[G.minDeltaUt]} G.minRange = {0:[G.minDeltaUt]}
for j in G.acoRange: for j in G.acoRange:
for i in G.minRange[j]: for i in G.minRange[j]:
initialiseVar() initialiseVar()
...@@ -68,9 +73,12 @@ def main(input, algorithmAttributes): ...@@ -68,9 +73,12 @@ def main(input, algorithmAttributes):
for bottleneck in G.Bottlenecks: for bottleneck in G.Bottlenecks:
for week in G.WeekList: for week in G.WeekList:
utilisation.append(float(G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity']) utilisation.append(float(G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity'])
targetUt.append((G.Capacity[bottleneck][week]['targetUtilisation']-float(G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity'])/G.Capacity[bottleneck][week]['targetUtilisation']) if G.Capacity[bottleneck][week]['targetUtilisation']:
targetUt.append((G.Capacity[bottleneck][week]['targetUtilisation']-float(G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity'])/G.Capacity[bottleneck][week]['targetUtilisation'])
else:
targetUt.append((G.Capacity[bottleneck][week]['targetUtilisation']-float(G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity']))
G.Summary[(G.ACO,G.minDeltaUt)]['utilisation'] = mean(array(utilisation)) G.Summary[(G.ACO,G.minDeltaUt)]['utilisation'] = mean(array(utilisation))
G.Summary[(G.ACO,G.minDeltaUt)]['targetM'] = mean(array(targetUt)) G.Summary[(G.ACO,G.minDeltaUt)]['targetM'] = mean(absolute(array(targetUt)))
G.Summary[(G.ACO,G.minDeltaUt)]['targetStd'] = std(array(targetUt)) G.Summary[(G.ACO,G.minDeltaUt)]['targetStd'] = std(array(targetUt))
if G.ACO: if G.ACO:
G.Summary[(G.ACO,G.minDeltaUt)]['ant'] = bestAnt G.Summary[(G.ACO,G.minDeltaUt)]['ant'] = bestAnt
...@@ -81,7 +89,7 @@ def main(input, algorithmAttributes): ...@@ -81,7 +89,7 @@ def main(input, algorithmAttributes):
# selection # selection
listSummary = [G.Summary[item] for item in G.Summary.keys()] listSummary = [G.Summary[item] for item in G.Summary.keys()]
print 'list summary', listSummary print 'list summary', listSummary
listSummary = sorted(listSummary, key=itemgetter('exUnits', 'lateness', 'targetStd', 'utilisation','targetM', 'earliness')) listSummary = sorted(listSummary, key=itemgetter('exUnits', 'lateness', 'targetM', 'targetStd', 'utilisation', 'earliness'))
bestScenario = listSummary[0]['scenario'] bestScenario = listSummary[0]['scenario']
aco = bestScenario[0] aco = bestScenario[0]
......
...@@ -71,7 +71,7 @@ def outputResults(): ...@@ -71,7 +71,7 @@ def outputResults():
G.CapacityResults.append([bottleneck, 'Capa Pegging Resource Capacity (UoM)',]+initialCap) G.CapacityResults.append([bottleneck, 'Capa Pegging Resource Capacity (UoM)',]+initialCap)
G.CapacityResults.append(['', 'Capa Pegging Resource Total Load (UoM)',]+[G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week] for week in G.WeekList]) G.CapacityResults.append(['', 'Capa Pegging Resource Total Load (UoM)',]+[G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week] for week in G.WeekList])
G.CapacityResults.append(['', 'Capa Pegging Resource Total Util (Percent)',]+[float(G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity']*100 for week in G.WeekList]) G.CapacityResults.append(['', 'Capa Pegging Resource Total Util (Percent)',]+[float(G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity']*100 for week in G.WeekList])
G.CapacityResults.append(['', 'Capa Pegging Resource Min Util (Percent)',]+[G.Capacity[bottleneck][week]['minUtilisation']*100 for week in G.WeekList]) G.CapacityResults.append(['', 'Capa Pegging Resource Min Util (Percent)',]+[G.Capacity[bottleneck][week]['minUtOrig']*100 for week in G.WeekList])
G.CapacityResults.append(['', 'Capa Pegging Resource Target Util (Percent)',]+[G.Capacity[bottleneck][week]['targetUtilisation']*100 for week in G.WeekList]) G.CapacityResults.append(['', 'Capa Pegging Resource Target Util (Percent)',]+[G.Capacity[bottleneck][week]['targetUtilisation']*100 for week in G.WeekList])
# utilisation results # utilisation results
...@@ -371,4 +371,4 @@ def outputResults(): ...@@ -371,4 +371,4 @@ def outputResults():
else: else:
weightedLateSP[week][sp]['result'] = 0 weightedLateSP[week][sp]['result'] = 0
''' '''
\ 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