Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Gurobi 9.1.0 #365

Merged
merged 3 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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