我正在编写一个脚本,以便在线性程序中使用R来确定最佳预算分配。我有一个仅使用ROI的示例,但我想添加更多约束,例如"最小转换率"或任何其他指标。
按照示例
library (lpSolve)
library (linprog)
## Channel ROI
## TV 8%
## Google Shop 12%
## Twitter 7%
## Facebook 11%
## Google Brand 4%
ROI <- c(0.08, 0.12, 0.07, 0.11, 0.4)
#b vector is the limits
b <- c(100, 0,0,0,10, 2700)
#a is the constraints
A <- rbind (
c(1,1,1,1,1), #first constraint total budget
c(0.42,-0.58,-0.58,-0.58,-0.58), #second constraint, TV can't be more than 58% of Budget
c(0.2,0.2,-0.8,-0.8,-0.8), #third constriant
c(-0.3, 0.7, 0.7, -0.3, 0.7), #forth constriant
c(0,0,0,1,0), #fifth constriant
)
solveLP(ROI, b, A, TRUE)
基本上,我对ROI有限制(约束),但是可以为另一个指标添加约束吗?
提前致谢:)