Commit d9083295 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Merge branch 'demandPlanningLine'

parents abdb3aa1 c91b9f67
from dream.plugins import plugin
from dream.plugins.TimeSupport import TimeSupportMixin
from datetime import datetime
class DemandPlanningLine(plugin.OutputPreparationPlugin, TimeSupportMixin):
""" Output the queue statistics in a format compatible with Output_viewGraph
"""
def postprocess(self, data):
from dream.simulation.applications.DemandPlanning.Globals import G
utilisation=G.Utilisation
# XXX current implementation for one bottleneck
bottleNeckUtilization=G.Utilisation['BE_T_BE1S_TEST_EQ_FLEX_T417_3']
dateList=[]
# get the current date from the data
for record_id,record in bottleNeckUtilization.iteritems():
year=str(record_id)[0:4]
week=str(record_id)[4:]
fullDate=datetime.strptime(year+'-'+week+'-0', '%Y-%W-%w')
dateList.append(fullDate)
currentDate=str(min(dateList))
currentDate=currentDate.replace('-', '/')
data['general']['currentDate']=currentDate
data['general']['timeUnit']='week'
self.initializeTimeSupport(data)
result = data['result']['result_list'][-1]
series = []
options = {
"xaxis": {
"mode": "time",
"minTickSize": [1, self.getTimeUnitText()],
}
}
result[self.configuration_dict['output_id']] = {
"series": series,
"options": options
}
# create the 3 lines
for utilizationType in ['averageUtilization','minUtilization','maxUtilization']:
utilizationList=[]
for record_id,record in bottleNeckUtilization.iteritems():
year=str(record_id)[0:4]
week=str(record_id)[4:]
fullDate=datetime.strptime(year+'-'+week+'-0', '%Y-%W-%w')
utilizationList.append([fullDate,record[utilizationType]])
utilizationList.sort(key=lambda x: x[0], reverse=True)
series.append({
"label": utilizationType,
"data": [((time-datetime(1970, 1, 1)).total_seconds()*1000, value) for (time, value) in utilizationList]
})
return data
...@@ -14,4 +14,8 @@ class PostProcessDemandPlanning(plugin.OutputPreparationPlugin): ...@@ -14,4 +14,8 @@ class PostProcessDemandPlanning(plugin.OutputPreparationPlugin):
'mime_type': 'application/vnd.ms-excel', 'mime_type': 'application/vnd.ms-excel',
'data': G.reportResults.xlsx.encode('base64') 'data': G.reportResults.xlsx.encode('base64')
} }
import json
utilisationString=json.dumps(G.Utilisation, indent=5)
outputJSONFile=open('Utilisation.json', mode='w')
outputJSONFile.write(utilisationString)
return data return data
...@@ -141,6 +141,14 @@ ...@@ -141,6 +141,14 @@
"gadget": "Output_viewDownloadFile", "gadget": "Output_viewDownloadFile",
"title": "Download Result Spreadsheet", "title": "Download Result Spreadsheet",
"type": "object_view" "type": "object_view"
},
"view_utilization_stats": {
"configuration": {
"output_id": "bottleneck_utilization"
},
"gadget": "Output_viewGraph",
"title": "Bottleneck Utilization",
"type": "object_view"
} }
}, },
"post_processing": { "post_processing": {
...@@ -148,6 +156,10 @@ ...@@ -148,6 +156,10 @@
{ {
"_class": "dream.plugins.PostProcessDemandPlanning.PostProcessDemandPlanning", "_class": "dream.plugins.PostProcessDemandPlanning.PostProcessDemandPlanning",
"output_id": "demand_planning_spreadsheet" "output_id": "demand_planning_spreadsheet"
},
{
"_class": "dream.plugins.DemandPlanningLine.DemandPlanningLine",
"output_id": "bottleneck_utilization"
} }
] ]
}, },
......
...@@ -47,6 +47,7 @@ class G: ...@@ -47,6 +47,7 @@ class G:
Lateness = {} Lateness = {}
Excess = {} Excess = {}
weightFactor = [10.0,1.0,0,2] weightFactor = [10.0,1.0,0,2]
Utilisation={}
# ACO parameters # ACO parameters
ACO = 1 ACO = 1
......
...@@ -41,6 +41,16 @@ def outputResults(): ...@@ -41,6 +41,16 @@ def outputResults():
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])
# utilisation results
for bottleneck in G.Bottlenecks:
G.Utilisation[bottleneck] = {}
for week in G.WeekList:
G.Utilisation[bottleneck][week] = {}
G.Utilisation[bottleneck][week]['averageUtilization'] = float(G.Capacity[bottleneck][week]['OriginalCapacity']-G.CurrentCapacityDict[bottleneck][week])/G.Capacity[bottleneck][week]['OriginalCapacity']
G.Utilisation[bottleneck][week]['minUtilization'] = G.Capacity[bottleneck][week]['minUtilisation']
G.Utilisation[bottleneck][week]['maxUtilization'] = G.Capacity[bottleneck][week]['targetUtilisation']
# report allocation results # report allocation results
head = ['PPOS', 'Demand_Items_Product_DCBNO - SP', 'Demand_Items_Product_DCBNO - MA', 'Demand_Type - Group', 'Priority','Values'] + G.WeekList head = ['PPOS', 'Demand_Items_Product_DCBNO - SP', 'Demand_Items_Product_DCBNO - MA', 'Demand_Type - Group', 'Priority','Values'] + G.WeekList
G.allocationResults.headers = head G.allocationResults.headers = head
......
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