Turnovers=A.Input_data(worksheet_RapidMiner,workbook)#Dictionary with the data from the Excel file
#Create lists with the MAs' names and the Turnovers for the first twelve weeks of 2010 retrieving this data from the dictionary
PPOS=Turnovers.get('Ppos',[])
SP=Turnovers.get('SP',[])
MA=Turnovers.get('FP Material No PGS+',[])
GlobalDemand=Turnovers.get('Global demand',[])
#Call the Distributions object and fit the data from the list in Normal distribution, so as to have info on Global demand (mean and standard deviation)
D=Distributions()
E=HandleMissingValues()
MA=E.DeleteMissingValue(MA)
t=D.Normal_distrfit(GlobalDemand)
avg=t.get('mean')
stdev=t.get('stdev')
defconstrained_sum_sample_pos(n,total):
defgenerateDemandPlanning(input_url):
"""Generate random demand from spreadsheet at input_url.
"""
# Read data from the exported Excel file from RapidMiner and call the Import_Excel object of the KE tool to import this data in the tool
Turnovers=A.Input_data(worksheet_RapidMiner,workbook)#Dictionary with the data from the Excel file
#Create lists with the MAs' names and the Turnovers for the first twelve weeks of 2010 retrieving this data from the dictionary
PPOS=Turnovers.get('Ppos',[])
SP=Turnovers.get('SP',[])
MA=Turnovers.get('FP Material No PGS+',[])
GlobalDemand=Turnovers.get('Global demand',[])
#Call the Distributions object and fit the data from the list in Normal distribution, so as to have info on Global demand (mean and standard deviation)
D=Distributions()
E=HandleMissingValues()
MA=E.DeleteMissingValue(MA)
t=D.Normal_distrfit(GlobalDemand)
avg=t.get('mean')
stdev=t.get('stdev')
defconstrained_sum_sample_pos(n,total):
"""Return a randomly chosen list of n positive integers summing to total.
week=[1,2,3,4,5,6,7,8,9,10]# list that defines the planning horizon, i.e. 10 weeks
DemandProfile={}#Create a dictionary
MinPackagingSize=10
week=[1,2,3,4,5,6,7,8,9,10]# list that defines the planning horizon, i.e. 10 weeks
foriinweek:
foriinweek:
Demand=int(abs(random.normalvariate(avg,stdev)))# Generate a random, non-negative, integer number from the Normal distribution
AllocatedPercent=0.8-(0.05*i)# Defines a number starts with 0.8 or 80% and reduced with every iteration at 0.05 or 5%
Remaining_Demand=int((1-AllocatedPercent)*Demand)# Defines the Remaining demand
...
...
@@ -95,21 +104,21 @@ for i in week:
dicta.update({MA[index]:[TotalUnits,MinUnits]})# it updates a dictionary with key the different MAs and values the remaining demand and (b[index]*lista[index])
DemandProfile.update({i:dicta})#It updates a dictionary with key the number of each iteration (week) and value the dictionary dicta