Skip to content

Commit

Permalink
Add support for Gurobi 9.1.0 (#365)
Browse files Browse the repository at this point in the history
* Add support for Gurobi 9.1.0

* Bump patch version

* Fix typo in README
  • Loading branch information
odow authored Nov 3, 2020
1 parent 937d46a commit b6766a5
Show file tree
Hide file tree
Showing 11 changed files with 1,547 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Gurobi"
uuid = "2e9cd046-0924-5485-92f1-d5272153d98b"
repo = "https://github.com/jump-dev/Gurobi.jl"
version = "0.9.2"
version = "0.9.3"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ Julia from Gurobi, let them know!*

## Installation

**Minimum version requirement:** Gurobi.jl requires Gurobi version 9.0.
**Minimum version requirement:** Gurobi.jl requires Gurobi version 9.0 or 9.1.

First, obtain a license of Gurobi and install Gurobi solver, following the
instructions on [Gurobi's website](http://www.gurobi.com). Then, set the
`GUROBI_HOME` environment variable as appropriate and run `Pkg.add("Gurobi")`,
the `Pkg.build("Gurobi")`. For example:
```julia
# On Windows, this might be
ENV["GUROBI_HOME"] = "C:\\Program Files\\gurobi902\\win64"
ENV["GUROBI_HOME"] = "C:\\Program Files\\gurobi910\\win64"
# ... or perhaps ...
ENV["GUROBI_HOME"] = "C:\\gurobi902\\win64"
ENV["GUROBI_HOME"] = "C:\\gurobi910\\win64"
import Pkg
Pkg.add("Gurobi")
Pkg.build("Gurobi")

# On Mac, this might be
ENV["GUROBI_HOME"] = "/Library/gurobi902/mac64"
ENV["GUROBI_HOME"] = "/Library/gurobi910/mac64"
import Pkg
Pkg.add("Gurobi")
Pkg.build("Gurobi")
Expand Down
7 changes: 4 additions & 3 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ end

const ALIASES = [
"gurobi90",
"gurobi91",
]

paths_to_try = copy(ALIASES)
Expand Down Expand Up @@ -54,19 +55,19 @@ function _print_GUROBI_HOME_help()
correct location if needed):
```
# On Windows, this might be
ENV["GUROBI_HOME"] = "C:\\\\Program Files\\\\gurobi902\\\\win64\\\\"
ENV["GUROBI_HOME"] = "C:\\\\Program Files\\\\gurobi910\\\\win64\\\\"
import Pkg
Pkg.add("Gurobi")
Pkg.build("Gurobi")
# On OSX, this might be
ENV["GUROBI_HOME"] = "/Library/gurobi902/mac64/"
ENV["GUROBI_HOME"] = "/Library/gurobi910/mac64/"
import Pkg
Pkg.add("Gurobi")
Pkg.build("Gurobi")
# On Unix, this might be
ENV["GUROBI_HOME"] = "/opt/gurobi902/linux64/"
ENV["GUROBI_HOME"] = "/opt/gurobi910/linux64/"
import Pkg
Pkg.add("Gurobi")
Pkg.build("Gurobi")
Expand Down
17 changes: 10 additions & 7 deletions scripts/clang.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# TODO(odow):
#
# This script can be used to build the C interface to Gurobi. However, it requires
# you to manually do the following steps first:
#
# 1) Copy gurobi_c.h from Gurobi into this /scripts directory
# This script can be used to build the C interface to Gurobi. However, it
# requires you to manually set the path to the appropriate gurobi_c.h.

import Clang

const LIBGRB_HEADERS = [
joinpath(@__DIR__, "gurobi_c.h"),
"/Library/gurobi910/mac64/include/gurobi_c.h",
]

const GEN_DIR = joinpath(dirname(@__DIR__), "src", "gen")
const GRB_VERSION = "91"

const GEN_DIR = joinpath(dirname(@__DIR__), "src", "gen$(GRB_VERSION)")
if !isdir(GEN_DIR)
mkdir(GEN_DIR)
end

wc = Clang.init(
headers = LIBGRB_HEADERS,
Expand All @@ -36,4 +39,4 @@ function manual_corrections()
end
manual_corrections()

rm(joinpath(dirname(@__DIR__), "src", "gen", "LibTemplate.jl"))
rm(joinpath(GEN_DIR, "LibTemplate.jl"))
33 changes: 23 additions & 10 deletions src/Gurobi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,39 @@ end

using CEnum

include("gen/ctypes.jl")
include("gen/libgrb_common.jl")
include("gen/libgrb_api.jl")

const _GUROBI_VERSION = if libgurobi == "julia_registryci_automerge"
VersionNumber(9, 0, 0)
VersionNumber(9, 1, 0)
else
let
majorP, minorP, technicalP = Ref{Cint}(), Ref{Cint}(), Ref{Cint}()
GRBversion(majorP, minorP, technicalP)
VersionNumber("$(majorP[]).$(minorP[]).$(technicalP[])")
ccall(
(:GRBversion, libgurobi),
Cvoid,
(Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
majorP, minorP, technicalP,
)
VersionNumber(majorP[], minorP[], technicalP[])
end
end

if !(v"9.0.0" <= _GUROBI_VERSION < v"9.1")
function _is_patch(x::VersionNumber, reference::VersionNumber)
return x.major == reference.major && x.minor == reference.minor
end

if _is_patch(_GUROBI_VERSION, v"9.0")
include("gen90/ctypes.jl")
include("gen90/libgrb_common.jl")
include("gen90/libgrb_api.jl")
elseif _is_patch(_GUROBI_VERSION, v"9.1")
include("gen91/ctypes.jl")
include("gen91/libgrb_common.jl")
include("gen91/libgrb_api.jl")
else
error("""
You have installed version $_GUROBI_VERSION of Gurobi, which is not
supported by Gurobi.jl. We require Gurobi version 9 or greater.
supported by Gurobi.jl. We require Gurobi version 9.0 or 9.1.
After installing Gurobi 9, run:
After installing a supported version of Gurobi, run:
import Pkg
Pkg.rm("Gurobi")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions src/gen91/ctypes.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## TODO: pending https://github.com/JuliaLang/julia/issues/29420
# this one is suggested in the issue, but it looks like time_t and tm are two different things?
# const Ctime_t = Base.Libc.TmStruct

const Ctm = Base.Libc.TmStruct
const Ctime_t = UInt
const Cclock_t = UInt
Loading

2 comments on commit b6766a5

@odow
Copy link
Member Author

@odow odow commented on b6766a5 Nov 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/24111

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.3 -m "<description of version>" b6766a5f9b25b2117e7e5fd15051c3801ad1f814
git push origin v0.9.3

Please sign in to comment.