R优化营销策略

R优化营销策略,r,optimization,R,Optimization,我是R新手,我正在尝试运行一个优化函数。 我有3个变量: 美元收入 在电视宣传上花了50美元 在一次广播活动上花了50美元 如何优化电视和广播活动的预算分配? 换句话说,我如何为每个司机找到最佳的花费 There are 3 characteristics of an optimization problem: 1.Decision Variables -The variables whose value is to be decided in order to achieve our obje

我是R新手,我正在尝试运行一个优化函数。 我有3个变量: 美元收入 在电视宣传上花了50美元 在一次广播活动上花了50美元

如何优化电视和广播活动的预算分配? 换句话说,我如何为每个司机找到最佳的花费

There are 3 characteristics of an optimization problem:
1.Decision Variables -The variables whose value is to be decided in order to achieve our objective
2.Objective Function – linear function of decision variables
3.Constraints – restrictions which cause hinderance in achieving the objective.
我认为线性规划是说明这一点的最好方法

require(lpSolveAPI)

model<-make.lp(ncol=4)
m1<-lp.control(model, sense="max", verbose="neutral")
m2<-set.objfn(model, obj=c(1/250,1/200,1/150,1/100))
m3<-set.bounds(model, lower=c(250000,200000,75000,50000))
m4<-add.constraint(model, c(1,1,0,0), "<=",600000)
m5<-add.constraint(model, c(1,1,1,1), type="<=",1000000)
m6<-add.constraint(model, c((1500/250-500/250),(800/200-500/200),(300/150-500/150),(100/100-500/100)), type=">=",0)


rownames=c("facebook & Adword budget constraint","total budget","LTV")
colnames=c("Adword","Facebook","Email","Affiliated")
dimnames(model)=list(rownames,colnames)
name.lp(model,"Maximize Number Of Users")
write.lp(model, filename="lp_model.lp")
kable(readLines("lp_model.lp"))


solve(model)
get.variables(model)
get.objective(model)
require(lpSolveAPI)

这个问题写得很可笑。如果你甚至不知道自己需要什么,就不要问问题。。