From 813e72326c6eb081ab228107256582a88c78ebe8 Mon Sep 17 00:00:00 2001 From: Tanubrata Dey Date: Wed, 11 Oct 2023 16:48:59 -0400 Subject: [PATCH 1/3] Fixing a bug where the CPLEX check was forcefully implemented even when using gurobi --- R/JaBbA.R | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/R/JaBbA.R b/R/JaBbA.R index 733027f..ad7f2a4 100755 --- a/R/JaBbA.R +++ b/R/JaBbA.R @@ -55,13 +55,28 @@ low.count=high.count=seg=chromosome=alpha_high=alpha_low=beta_high=beta_low=pred jmessage("${CPLEX_DIR}/cplex/[(include)|(lib)] do not both exist") } - if (!requireNamespace("gurobi", quietly = TRUE)) { - jmessage("Gurobi is not installed! REMEMBER: You need to have either CPLEX or Gurobi!") + if (((!file.exists(paste0(cplex.dir, "/cplex"))) & (!file.exists(paste0(cplex.dir, "/cplex/include")) || + !file.exists(paste0(cplex.dir, "/cplex/lib")))) & (requireNamespace("gurobi", quietly = TRUE))) { + jmessage("Gurobi is installed! Will use Gurobi instead of CPLEX if mentioned use.gurobi=TRUE") - } else { + } else if (((file.exists(paste0(cplex.dir, "/cplex"))) & (file.exists(paste0(cplex.dir, "/cplex/include")) || + file.exists(paste0(cplex.dir, "/cplex/lib")))) & (!requireNamespace("gurobi", quietly = TRUE))) { + + jmessage("CPLEX found, will check if gGnome is wired up with CPLEX...") library(gGnome) gGnome:::testOptimizationFunction() - } + + } else if (((file.exists(paste0(cplex.dir, "/cplex"))) & (file.exists(paste0(cplex.dir, "/cplex/include")) || + file.exists(paste0(cplex.dir, "/cplex/lib")))) & (requireNamespace("gurobi", quietly = TRUE))) { + + jmessage("Both CPLEX and Gurobi is found, will check if gGnome has CPLEX wired since by default JaBbA use CPLEX...") + library(gGnome) + gGnome:::testOptimizationFunction() + + } else { + + jmessage("Both CPLEX and Gurobi not found! REMEMBER: You need any one of these optimizers to run JaBbA") + } invisible() } From 5b5ded867f60af8af702d41ce1e99b8ef703c13d Mon Sep 17 00:00:00 2001 From: Tanubrata Dey Date: Thu, 12 Oct 2023 11:50:42 -0400 Subject: [PATCH 2/3] Made the CPLEX and gurobi check if-else statment more human readable --- R/JaBbA.R | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/R/JaBbA.R b/R/JaBbA.R index ad7f2a4..b058d09 100755 --- a/R/JaBbA.R +++ b/R/JaBbA.R @@ -54,20 +54,24 @@ low.count=high.count=seg=chromosome=alpha_high=alpha_low=beta_high=beta_low=pred !file.exists(paste0(cplex.dir, "/cplex/lib"))){ jmessage("${CPLEX_DIR}/cplex/[(include)|(lib)] do not both exist") } - - if (((!file.exists(paste0(cplex.dir, "/cplex"))) & (!file.exists(paste0(cplex.dir, "/cplex/include")) || - !file.exists(paste0(cplex.dir, "/cplex/lib")))) & (requireNamespace("gurobi", quietly = TRUE))) { + + # variable that stores checks for CPLEX directory and its lib & include folder + cplex_installation = ((file.exists(paste0(cplex.dir, "/cplex"))) & (file.exists(paste0(cplex.dir, "/cplex/include")) || + file.exists(paste0(cplex.dir, "/cplex/lib")))) + # variable that stores boolean information for Gurobi installation + gurobi_installation = (requireNamespace("gurobi", quietly = TRUE)) + + # check to verify whether gurobi or cplex or both or none. if cplex or both cplex and gurobi found, it will run cplex connection for gGnome package + if ((!cplex_installation) & (gurobi_installation)) { jmessage("Gurobi is installed! Will use Gurobi instead of CPLEX if mentioned use.gurobi=TRUE") - } else if (((file.exists(paste0(cplex.dir, "/cplex"))) & (file.exists(paste0(cplex.dir, "/cplex/include")) || - file.exists(paste0(cplex.dir, "/cplex/lib")))) & (!requireNamespace("gurobi", quietly = TRUE))) { + } else if ((cplex_installation) & (!gurobi_installation)) { jmessage("CPLEX found, will check if gGnome is wired up with CPLEX...") library(gGnome) gGnome:::testOptimizationFunction() - } else if (((file.exists(paste0(cplex.dir, "/cplex"))) & (file.exists(paste0(cplex.dir, "/cplex/include")) || - file.exists(paste0(cplex.dir, "/cplex/lib")))) & (requireNamespace("gurobi", quietly = TRUE))) { + } else if ((cplex_installation) & (gurobi_installation)) { jmessage("Both CPLEX and Gurobi is found, will check if gGnome has CPLEX wired since by default JaBbA use CPLEX...") library(gGnome) From 3ae32cc310bb2b62a3dbd9be8a1d1f35cecb7840 Mon Sep 17 00:00:00 2001 From: Tanubrata Dey Date: Thu, 12 Oct 2023 11:50:42 -0400 Subject: [PATCH 3/3] Made the CPLEX and gurobi check if-else statment more human readable --- R/JaBbA.R | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/R/JaBbA.R b/R/JaBbA.R index ad7f2a4..b058d09 100755 --- a/R/JaBbA.R +++ b/R/JaBbA.R @@ -54,20 +54,24 @@ low.count=high.count=seg=chromosome=alpha_high=alpha_low=beta_high=beta_low=pred !file.exists(paste0(cplex.dir, "/cplex/lib"))){ jmessage("${CPLEX_DIR}/cplex/[(include)|(lib)] do not both exist") } - - if (((!file.exists(paste0(cplex.dir, "/cplex"))) & (!file.exists(paste0(cplex.dir, "/cplex/include")) || - !file.exists(paste0(cplex.dir, "/cplex/lib")))) & (requireNamespace("gurobi", quietly = TRUE))) { + + # variable that stores checks for CPLEX directory and its lib & include folder + cplex_installation = ((file.exists(paste0(cplex.dir, "/cplex"))) & (file.exists(paste0(cplex.dir, "/cplex/include")) || + file.exists(paste0(cplex.dir, "/cplex/lib")))) + # variable that stores boolean information for Gurobi installation + gurobi_installation = (requireNamespace("gurobi", quietly = TRUE)) + + # check to verify whether gurobi or cplex or both or none. if cplex or both cplex and gurobi found, it will run cplex connection for gGnome package + if ((!cplex_installation) & (gurobi_installation)) { jmessage("Gurobi is installed! Will use Gurobi instead of CPLEX if mentioned use.gurobi=TRUE") - } else if (((file.exists(paste0(cplex.dir, "/cplex"))) & (file.exists(paste0(cplex.dir, "/cplex/include")) || - file.exists(paste0(cplex.dir, "/cplex/lib")))) & (!requireNamespace("gurobi", quietly = TRUE))) { + } else if ((cplex_installation) & (!gurobi_installation)) { jmessage("CPLEX found, will check if gGnome is wired up with CPLEX...") library(gGnome) gGnome:::testOptimizationFunction() - } else if (((file.exists(paste0(cplex.dir, "/cplex"))) & (file.exists(paste0(cplex.dir, "/cplex/include")) || - file.exists(paste0(cplex.dir, "/cplex/lib")))) & (requireNamespace("gurobi", quietly = TRUE))) { + } else if ((cplex_installation) & (gurobi_installation)) { jmessage("Both CPLEX and Gurobi is found, will check if gGnome has CPLEX wired since by default JaBbA use CPLEX...") library(gGnome)