2
I am trying to optimize profit by 4 different products, one that profits 600reais/unit other that profits 550/unit other that profits 400/unit and another that profits 300/unit. However, the demand for X1 = 50 for x2 = 50 for X3 = 80 and X4 = 120.
How I specify the individual demand of each one within lpSolveAPI??
library(lpSolveAPI)
lprec <- make.lp(0,4) #numero de linhas e de variaveis de decisao
lp.control(lprec,sense='max') #maximzar ou minimizar
set.objfn(lprec, c(600, 550, 400, 300)) # funcao objetivo
add.constraint(lprec, c(31540, 40000, 29600, 14700), "<=", 108000) #restricao 1
add.constraint(lprec, c(36290,22500,42550,7350), "<=", 110000) #restricao 2
add.constraint(lprec, c(19000, 11250,11840,16800), "<=", 60000) #restricao 3
solve(lprec) #resolver ppl
get.objective(lprec) #funcao objetivo resolvida
get.variables(lprec) #qto de cada variavel otimiza o sistema
get.constraints(lprec)
lprec