Turnovers=A.Input_data(worksheet_RapidMiner,workbook)#Dictionary with the data from the Excel file
worksheets=workbook.sheet_names()
worksheet_RapidMiner=worksheets[0]
#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',[])
PPOSToBeDisaggregated='PPOS4'
SP=Turnovers.get('SP',[])
PPOSQuantity=1000
MA=Turnovers.get('FP Material No PGS+',[])
PlannedWeek=2
GlobalDemand=Turnovers.get('Global demand',[])
A=Import_Excel()
#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)
Turnovers=A.Input_data(worksheet_RapidMiner,workbook)#Dictionary with the data from the Excel file
D=Distributions()
E=HandleMissingValues()
#Create lists with the MAs' names and the Turnovers for the first twelve weeks of 2010 retrieving this data from the dictionary
MA=E.DeleteMissingValue(MA)
PPOS=Turnovers.get('Ppos',[])
t=D.Normal_distrfit(GlobalDemand)
SP=Turnovers.get('SP',[])
avg=t.get('mean')
MA=Turnovers.get('FP Material No PGS+',[])
stdev=t.get('stdev')
GlobalDemand=Turnovers.get('Global demand',[])
defconstrained_sum_sample_pos(n,total):
#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)
"""Return a randomly chosen list of n positive integers summing to total.
Remaining_Demand=int((1-AllocatedPercent)*Demand)# Defines the Remaining demand
a=constrained_sum_sample_nonneg(len(MA),100)
myInt=100
a=robjects.FloatVector(a)
lista=[x/myIntforxina]# Define a list with the same length as the MA list and elements float numbers with total sum equal to 1
b=constrained_sum_sample_nonneg(len(MA),Remaining_Demand)# Define a list with the same length as the MA list and elements with total sum the Remaining demand
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
week=[1,2,3,4,5,6,7,8,9,10]# list that defines the planning horizon, i.e. 10 weeks
dictPPOS={}
dictPPOSMA={}
foriinweek:
Demand=int(abs(random.normalvariate(avg,stdev)))# Generate a random, non-negative, integer number from the Normal distribution
forindinuniquePPOS:
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%
indices=[ifori,jinenumerate(PPOS)ifj==ind]
Remaining_Demand=int((1-AllocatedPercent)*Demand)# Defines the Remaining demand
mas=[maformainMAif(MA.index(ma)inindices)]
a=constrained_sum_sample_nonneg(len(MA),100)
dictPPOSMA.update({ind:mas})
myInt=100
a=robjects.FloatVector(a)
t=1
lista=[x/myIntforxina]# Define a list with the same length as the MA list and elements float numbers with total sum equal to 1
forkeyindictPPOSMA.keys():
b=constrained_sum_sample_nonneg(len(MA),Remaining_Demand)# Define a list with the same length as the MA list and elements with total sum the Remaining demand
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])
TotalUnits=c[i]
DemandProfile.update({i:dicta})#It updates a dictionary with key the number of each iteration (week) and value the dictionary dicta