Commit 6145eaf1 authored by Jérome Perrin's avatar Jérome Perrin

DemandPlanning: Use KE for demand profile xlsx

parent d7fcb763
...@@ -27,6 +27,8 @@ module that creates the future demand and appends it to buffers ...@@ -27,6 +27,8 @@ module that creates the future demand and appends it to buffers
import xlrd import xlrd
import json import json
import urllib
from Globals import G from Globals import G
from JobMA import JobMA from JobMA import JobMA
...@@ -53,8 +55,9 @@ class FutureDemandCreator(): ...@@ -53,8 +55,9 @@ class FutureDemandCreator():
# PPOS initial disaggregation profile # PPOS initial disaggregation profile
G.demandFile = ( '/home/jerome/src/dream/dream/simulation/GUI/DemandProfile.xlsx' ) # XXX this issue arbitrary requests
wbin = xlrd.open_workbook(G.demandFile) demand_data = urllib.urlopen(G.demandFile).read()
wbin = xlrd.open_workbook(file_contents=demand_data)
MAData=G.RouteDict MAData=G.RouteDict
for k in range(2): for k in range(2):
......
...@@ -26,7 +26,6 @@ test script to convert the static excels to JSON. It does not communicate with G ...@@ -26,7 +26,6 @@ test script to convert the static excels to JSON. It does not communicate with G
''' '''
import xlwt import xlwt
import xlrd
import json import json
from dream.simulation.AllocationManagement import AllocationManagement from dream.simulation.AllocationManagement import AllocationManagement
from dream.simulation.LineGenerationJSON import main as simulate_line_json from dream.simulation.LineGenerationJSON import main as simulate_line_json
...@@ -137,8 +136,6 @@ def readGeneralInput(data): ...@@ -137,8 +136,6 @@ def readGeneralInput(data):
def writeOutput(): def writeOutput():
wbin = xlwt.Workbook() wbin = xlwt.Workbook()
for k in range(G.ReplicationNo): for k in range(G.ReplicationNo):
#export info on lateness #export info on lateness
sheet1=wbin.add_sheet('Lateness'+str(k+1)) sheet1=wbin.add_sheet('Lateness'+str(k+1))
sheet1.write(0,0,'replication') sheet1.write(0,0,'replication')
...@@ -149,7 +146,7 @@ def writeOutput(): ...@@ -149,7 +146,7 @@ def writeOutput():
sheet1.write(3,1,G.PPOSEarliness[k]) sheet1.write(3,1,G.PPOSEarliness[k])
sheet1.write(1,3,'Unconstrained Excess Units') sheet1.write(1,3,'Unconstrained Excess Units')
sheet1.write(1,4,'Min Excess Units') sheet1.write(1,4,'Min Excess Units')
excessPPOS = sum([i.qty for i in G.ExcessPPOSBuffer[k]]) excessPPOS = sum([i.qty for i in G.ExcessPPOSBuffer[k]])
minExcessPPOS = sum([i.qty for i in G.ExcessPPOSminBuffer[k]]) minExcessPPOS = sum([i.qty for i in G.ExcessPPOSminBuffer[k]])
sheet1.write(2,3,excessPPOS) sheet1.write(2,3,excessPPOS)
...@@ -166,7 +163,7 @@ def writeOutput(): ...@@ -166,7 +163,7 @@ def writeOutput():
sheet1.write(4,1,G.FutureLateness[k]) sheet1.write(4,1,G.FutureLateness[k])
sheet1.write(5,0,'Future Demand Earliness') sheet1.write(5,0,'Future Demand Earliness')
sheet1.write(5,1,G.FutureEarliness[k]) sheet1.write(5,1,G.FutureEarliness[k])
# Export PPOS/Future allocation Results # Export PPOS/Future allocation Results
for z in range(2): for z in range(2):
if z==0: if z==0:
...@@ -179,8 +176,7 @@ def writeOutput(): ...@@ -179,8 +176,7 @@ def writeOutput():
itemName = 'Initial Future Demand Disaggregation' itemName = 'Initial Future Demand Disaggregation'
profile = G.FutureProfile[k] profile = G.FutureProfile[k]
alloc = G.AllocationFuture[k] alloc = G.AllocationFuture[k]
sheet = wbin.add_sheet(shName) sheet = wbin.add_sheet(shName)
sheet.write_merge(0,0,0,4,itemName) sheet.write_merge(0,0,0,4,itemName)
sheet.write(1,0,'Order ID') sheet.write(1,0,'Order ID')
...@@ -188,14 +184,14 @@ def writeOutput(): ...@@ -188,14 +184,14 @@ def writeOutput():
sheet.write(1,2,'Total # Units') sheet.write(1,2,'Total # Units')
sheet.write(1,3,'Min # Units') sheet.write(1,3,'Min # Units')
sheet.write(1,4,'Planned Week') sheet.write(1,4,'Planned Week')
for i in range(len(profile)): for i in range(len(profile)):
for j in range(len(profile[i])): for j in range(len(profile[i])):
sheet.write(i+2,j,profile[i][j]) sheet.write(i+2,j,profile[i][j])
totQty = sum([i[2] for i in profile]) totQty = sum([i[2] for i in profile])
if z==0: if z==0:
#pposQty = totQty #pposQty = totQty
sheet1.write(2,6,excessPPOS*100.0/totQty) sheet1.write(2,6,excessPPOS*100.0/totQty)
sheet1.write(2,7,minExcessPPOS*100.0/totQty) sheet1.write(2,7,minExcessPPOS*100.0/totQty)
...@@ -345,6 +341,9 @@ class Simulation(DefaultSimulation): ...@@ -345,6 +341,9 @@ class Simulation(DefaultSimulation):
"_class": "Dream.Property", "_class": "Dream.Property",
"_default": 10 "_default": 10
}) })
prop_list.append(overloaded_property(schema['ke_url'],
{'_default':
'http://git.erp5.org/gitweb/dream.git/blob_plain/HEAD:/dream/simulation/Examples/DemandProfile.xlsx'}))
return conf return conf
def run(self, data): def run(self, data):
...@@ -389,6 +388,7 @@ class Simulation(DefaultSimulation): ...@@ -389,6 +388,7 @@ class Simulation(DefaultSimulation):
inputDict['nodes']['AM']['argumentDict']['MAList']=IG.RouteDict inputDict['nodes']['AM']['argumentDict']['MAList']=IG.RouteDict
G.argumentDictString=json.dumps(inputDict, indent=5) G.argumentDictString=json.dumps(inputDict, indent=5)
G.demandFile = data['general']['ke_url']
out = json.loads(simulate_line_json(input_data=(G.argumentDictString))) out = json.loads(simulate_line_json(input_data=(G.argumentDictString)))
......
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