#!/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)