I have this problem and I know the answer but I need to be able to solve it via R
There are 5 campaigns called A,B,C,D,E there is a maximum possible budget that can be spent on each campaign and a ROI for each dollar spent on each campaign.
it will look like this
Campaign Max Budget ROI
A 156.09 0.77
B 73.92 1.46
C 65.8 2.14
D 43.68 0.77
E 41.01 1.81
there is two constrain, you can only spend a total of 100 in all the campaigns, and you cant spend more than your max budget on each campaing, and you are trying to maximize your profits and that is your ROI times the budget you spent on the campaign.
I know the answer will be to spend 65.8 on campaign C because it has the higher ROI then spend 34.2 on campaign E because you have your second highest ROI and with that you will hit the constrain of max spend of 100.
If somebody can help me to set this up with lpSolveAPI or lpsolve, thanks in advance
this is what I have tried so far
library("lpSolveAPI")
model<-make.lp(ncol=5)
m1<-lp.control(model, sense="max", verbose="neutral")
m2<-set.objfn(model, obj=c(120.1893,107.9232,140.812,33.6336,74.2462))
m3<-set.bounds(model, upper =c(156.09,73.92,65.8,43.68,41.02))
m4<-add.constraint(model, c(1,1,1,1,1), "<=",100)
solve(model)
get.variables(model)
34.2 0.0 65.8 0.0 0.0
Why am I getting 65.8 on campaing C but 34.2 on A, should it be on E?? I assume my objective function is incorrect, for the objective function I multiply the ROI by the max budget and use those coefficients.