Commit e4638f49 authored by Georgios Dagkakis's avatar Georgios Dagkakis

plugins removed from root plugin folder

parent 77660a60
from copy import copy
import json
import time
import random
import operator
import datetime
from dream.plugins import plugin
class AddDemandPlannerGenerator(plugin.InputPreparationPlugin):
""" Input preparation
adds an EventGenerator that will call the Demand Planning algorithm once
"""
def preprocess(self, data):
nodes=data['graph']['node']
data_uri_encoded_input_data = data['input'].get(self.configuration_dict['input_id'], {})
algorithmAttributes=copy(data['general'])
nodes['DPG']={
"name": "DemandPlannerGenerator",
"prioritizeIfCanFinish": 1,
"interval": 1,
"start": 0,
"stop": 0.5,
"_class": "dream.simulation.EventGenerator.EventGenerator",
"method": "dream.simulation.applications.DemandPlanning.executor_ACO.main",
"argumentDict": {'input':data_uri_encoded_input_data, 'algorithmAttributes':algorithmAttributes}
}
#print nodes
return data
\ No newline at end of file
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
for bottleneck in ['BE_A_VF78_DSO_3','BE_A_VK18_DKO_5']:
bottleNeckUtilization=G.Utilisation[bottleneck]
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[bottleneck] = {
"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
from dream.plugins import plugin
class PostProcessDemandPlanning(plugin.OutputPreparationPlugin):
""" Output the result of demand planning in a format compatible with
Output_viewDownloadFile
"""
def postprocess(self, data):
# XXX the event generator should store its result in data and not in global
# variable.
from dream.simulation.applications.DemandPlanning.Globals import G
data['result']['result_list'][-1][self.configuration_dict['output_id']] = {
'name': 'Result.xlsx',
'mime_type': 'application/vnd.ms-excel',
'data': G.reportResults.xlsx.encode('base64')
}
return data
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