From 9cb3780145a78a649f33c225183697f5de582631 Mon Sep 17 00:00:00 2001 From: Evangelos Michelioudakis Date: Fri, 15 Nov 2024 23:02:32 +0100 Subject: [PATCH] fix: updates to support for Gurobi 12 --- README.md | 2 +- build.sbt | 18 +++++------------- project/Dependencies.scala | 4 ++++ .../scala/optimus/optimization/Gurobi.scala | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f192c45..8d2d3f8 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you a 3. Available solvers: * Open source [LpSolve](http://sourceforge.net/projects/lpsolve/) can be used for LP and MIP. * Open source [oJSolver](http://ojalgo.org/) can be used for LP, QP and MIP. - * Proprietary solver [Gurobi 9](http://www.gurobi.com/) can be used for efficiently solving LP, QP, QCQP and MIP. + * Proprietary solver [Gurobi 12](http://www.gurobi.com/) can be used for efficiently solving LP, QP, QCQP and MIP. * Proprietary solver [Mosek 9](https://www.mosek.com/) can be used for efficiently solving LP, QP, QCQP and MIP. ## How to get Optimus diff --git a/build.sbt b/build.sbt index 2dd7645..93f5df8 100644 --- a/build.sbt +++ b/build.sbt @@ -40,19 +40,11 @@ lazy val lpsolve = Project("solver-lp", file("solver-lp")) .settings(libraryDependencies += Dependencies.LpSolve) // Build settings for Optimus gurobi solver -lazy val gurobi = - if (file("lib/gurobi.jar").exists) Project("solver-gurobi", file("solver-gurobi")) - .dependsOn(core % "compile->compile ; test->test") - .enablePlugins(AutomateHeaderPlugin) - .settings(name := "optimus-solver-gurobi") - .settings(Compile / unmanagedJars += file("lib/gurobi.jar")) - else Project("solver-gurobi", file("solver-gurobi")) - .settings { - logger.warn { - "Building in the absence of support for the Gurobi solver [ 'gurobi.jar' not found in 'lib' directory ]." - } - Seq(name := "optimus-solver-gurobi", publish := {}, publishLocal := {}) - } +lazy val gurobi = Project("solver-gurobi", file("solver-gurobi")) + .dependsOn(core % "compile->compile ; test->test") + .enablePlugins(AutomateHeaderPlugin) + .settings(name := "optimus-solver-gurobi") + .settings(libraryDependencies += Dependencies.Gurobi) // Build settings for Optimus mosek solver lazy val mosek = diff --git a/project/Dependencies.scala b/project/Dependencies.scala index be346c5..7112503 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -27,6 +27,7 @@ object Dependencies { final val ScalaTestPlus = "3.2.11.0" final val LpSolve = "5.5.2.0" + final val Gurobi = "12.0.0" final val ojAlgorithms = "51.4.0" final val Trove = "3.1.0" final val ScalaXML = "2.3.0" @@ -56,4 +57,7 @@ object Dependencies { // oj! Algorithms library for linear and quadratic programming lazy val ojAlgorithms: ModuleID = "org.ojalgo" % "ojalgo" % v.ojAlgorithms + + // Gurobi library for mathematical programming + lazy val Gurobi: ModuleID = "com.gurobi" % "gurobi" % v.Gurobi } diff --git a/solver-gurobi/src/main/scala/optimus/optimization/Gurobi.scala b/solver-gurobi/src/main/scala/optimus/optimization/Gurobi.scala index 30ce8d0..487aedd 100644 --- a/solver-gurobi/src/main/scala/optimus/optimization/Gurobi.scala +++ b/solver-gurobi/src/main/scala/optimus/optimization/Gurobi.scala @@ -16,7 +16,7 @@ package optimus.optimization -import gurobi._ +import com.gurobi.gurobi._ import optimus.algebra._ import optimus.optimization.enums.PreSolve._ import optimus.optimization.enums.{ PreSolve, SolutionStatus }