0

I have prepared the following reproducible example showing that lpSolve in R crashes with example 2 and I'm needing some help to identify why so it doesn't crash R.

The data and constraints were a bit large so I placed those on github and they can be read in for the example. The only difference between the one that works and the one that crashes R is the objective function values. Same constraints used in both but the values in the vector f.obj1 and f.obj2 differ.

Now I believe example 2 is infeasible. However, in smaller examples lpSolve returns to the user a solution is infeasible. In this case, it's simply crashing but I'm not certain why. Perhaps there is a setting in lpSolve that might stop this from crashing R?

Thank you in advance for any help on this problem.

library(lpSolve)
f.con <- as.matrix(read.csv('https://raw.githubusercontent.com/hdoran/Blog/master/SOData/f.con.csv'))
dat <- read.csv('https://raw.githubusercontent.com/hdoran/Blog/master/SOData/dat.csv')
constraintMat <- structure(list(constraint = c("total", "strand1", "strand2", 
"strand3", "strand4", "tminus1min", "tminus1max", "at0min", "at0max", 
"tplus1min", "tplus1max"), value = c(100L, 25L, 25L, 25L, 25L, 
5L, 8L, 22L, 26L, 40L, 45L), direction = c("=", "=", "=", "=", 
"=", ">=", "<=", ">=", "<=", ">=", "<=")), class = "data.frame", row.names = c(NA, 
-11L))

K <- 2000
f.dir <- c(constraintMat$direction, rep("<=",K))
f.rhs <- c(constraintMat$value,rep(1,K)) 
result <- lp("max", dat$f.obj1, f.con, f.dir, f.rhs, all.bin=TRUE) # Works
result <- lp("max", dat$f.obj2, f.con, f.dir, f.rhs, all.bin=TRUE) # Crashes R 4.2.0
dhc
  • 625
  • 1
  • 6
  • 14
  • About how long did it take before example 2 crashed with K 2000? – Chris Jul 18 '22 at 12:32
  • It appears almost immediately. My R session (using RGUI for example) just becomes unresponsive. – dhc Jul 18 '22 at 12:41
  • I'm trying it in terminal session, very old box, R4.1.3, RAM very stable (htop readings, ~4.24G to ~4.36G), and your using 1 core? (I am) been running about 10 min. From your description was expecting a process killed, after some freeze. Perhaps try in terminal. How long did example 1 `min` take to complete? – Chris Jul 18 '22 at 12:48
  • Example 1 completes virtually immediately. I also let example 2 run overnight on my laptop using R 4.2.0. Even after many hours, it yields no solution and when I click in the GUI it just tells me R is not responsive – dhc Jul 18 '22 at 13:35
  • 1
    Okay, same experience here, so not R 4.2.0 or memory related. – Chris Jul 18 '22 at 14:10

0 Answers0