Skip to content

Commit

Permalink
Made the CPLEX and gurobi check if-else statment more human readable
Browse files Browse the repository at this point in the history
  • Loading branch information
tanubrata committed Oct 12, 2023
1 parent 813e723 commit 5b5ded8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions R/JaBbA.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5b5ded8

Please sign in to comment.