i have 5 variables. each variable has bounds. , investing amount of money on each channel. question there optimizer or logic find out global maximum value given functional form. , sum of combinations should not exceed total spend.
parameters=c(10,120,105,121,180,140) #intercept , variable coefficients spend=c(16,120,180,170,180) # total spend total=sum(spend) upper_bound=c(50,200,250,220,250) lower_bound=c(10,70,100,90,70) var1=seq(lower_bound[1],upper_bound[1],by=1) var2=seq(lower_bound[2],upper_bound[2],by=1) var3=seq(lower_bound[3],upper_bound[3],by=1) var4=seq(lower_bound[4],upper_bound[4],by=1) var5=seq(lower_bound[5],upper_bound[5],by=1)
functional form is: exp(beta 0-beta i/x i)
i have used expand.grid function find existing combinations. getting many combinations.
here code.
seq_data=expand.grid(var1=var1,var2=var2,var3=var3,var4=var4,var5=var5) rs=rowsums(seq_data) seq_data=seq_data[rs<=total,] seq_data1=seq_data for(i in 1:length(seq_data)) seq_data1[,i]=exp(parameters[1]-parameters[i+1]/seq_data1[,i])
how can overcome problem. please suggest me if there other alternative.
thanks in advance.