I would like to optimize a simple function such as:
max = a1 * x1 + a2 * x2 + a3 * x3
where the x's are known in advance and a1 + a2 + a3 = limit
.
Furthermore, I need to add a constraint where a1 = a2 = a3
. Would some know how this can be implemented using lpSolveAPI
? This is what I already have:
library(lpSolveAPI)
limit = 50
a <- c(1.5, 1.6, 2.5)
my.lp <- make.lp(0,3)
set.objfn(my.lp, a)
add.constraint(my.lp, 1:3, "=", limit)
lp.control(my.lp,sense='max')
my.lp
solve(my.lp)
Currently, I cannot seem to find a way to add the constraint a1 = a2 = a3
(or C1 = C2 = C3
).