Using R, it is very easy to do linear programming with the lpSolve
and lpSolveAPI
packages. Now, I want to do linear programming with part of the constraints satisfied. Say, with 80% of the constraints are satisfied. It can not predefine which constraints should be satisfied. How to implement it using R?
An example here. There are 100 different tissue samples, for each sample, 10000 ~ 20000 genes were expressed. Now, I want to select at most 10 samples with the purpose to cover as many genes as possible. One solution based on lpSolve
is set 100 samples as variables and 20000 genes as constraints. First, manually filter the genes, and do lp
, until the solution hit 10 samples. However, this is laborious and not the most optimal.
set.seed(123)
t.mt <- matrix(sample(c(0,1),100000,rep=TRUE),nr=1000)
f.obj <- rep(1,100)
f.dir <- rep(">=",1000)
f.rhs <- rep(1,1000)
t.lp <- lp("min",f.obj,t.mt,f.dir,f.rhs,all.int=TRUE,all.bin=TRUE)
t.lp$solution
Is there possible solution using R for this problem?
Thank you!