diff --git a/Modules/R/gurobi.R b/Modules/R/gurobi.R new file mode 100644 index 0000000..b19e595 --- /dev/null +++ b/Modules/R/gurobi.R @@ -0,0 +1,31 @@ +#!/usr/bin/env Rscript + +# the gurobi R package must first be installed, the instructions +# can be found next to the archive, in $GUROBI_ROOT/linux64/R/README +# the full path to the archive can be found using: +# ls -l $GUROBI_ROOT/linux64/R/*.tar.gz +# +# an example: +# install.packages('/ssoft/spack/humagne/v1/opt/spack/linux-rhel7-x86_E5v4_Mellanox/gcc-4.8.5/gurobi-9.1.0-cltrssv5sibuou2bmma5zjqxczrtpncq/linux64/R/gurobi_9.1-0_R_4.0.2.tar.gz', repos=NULL) +# +# If there is a mistmatch with the current R version there will be a +# warning at runtime but it might still work. + +library(gurobi) + +model <- list() + +model$A <- matrix(c(1,2,3,1,1,0), nrow=2, ncol=3, byrow=T) +model$obj <- c(1,1,2) +model$modelsense <- 'max' +model$rhs <- c(4,1) +model$sense <- c('<', '>') +model$vtype <- 'B' + +params <- list(OutputFlag=0) + +result <- gurobi(model, params) + +print('Solution:') +print(result$objval) +print(result$x) diff --git a/Modules/R/gurobi.slurm b/Modules/R/gurobi.slurm new file mode 100644 index 0000000..34b6437 --- /dev/null +++ b/Modules/R/gurobi.slurm @@ -0,0 +1,23 @@ +#!/bin/bash -l + +#SBATCH --nodes 1 +#SBATCH --ntasks 1 +#SBATCH --cpus-per-task 1 +#SBATCH --mem 4G +#SBATCH --time 00:05:00 + +echo STARTING AT `date` + +module purge + +module load gcc openblas/0.3.6-openmp +module load r +module load gurobi + +module list + +srun R CMD BATCH ./gurobi.R + +echo "The output can be found in file 'gurobi.Rout'" + +echo FINISHED at `date`