Skip to content

Commit 48d518c

Browse files
committed
Conditionally define NL opcodes
1 parent 490ce31 commit 48d518c

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ repo = "https://github.com/jump-dev/Gurobi.jl"
44
version = "1.3.1"
55

66
[deps]
7-
Gurobi_jll = "c018c7e6-a5b0-4aea-8f80-9c1ef9991411"
7+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
88
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
99
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
1010

1111
[compat]
12-
Gurobi_jll = "~9.5, ~10.0, ~11.0"
1312
Libdl = "<0.0.1, 1.6"
1413
MathOptInterface = "1.21"
1514
Random = "<0.0.1, 1.6"

src/MOI_wrapper/MOI_nonlinear.jl

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@
44
# Use of this source code is governed by an MIT-style license that can be found
55
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
66

7-
const _OPCODE_MAP = Dict(
8-
:+ => GRB_OPCODE_PLUS,
9-
:- => GRB_OPCODE_MINUS,
10-
:* => GRB_OPCODE_MULTIPLY,
11-
:/ => GRB_OPCODE_DIVIDE,
12-
# GRB_OPCODE_UMINUS 6
13-
# GRB_OPCODE_SQUARE 7
14-
:sqrt => GRB_OPCODE_SQRT,
15-
:sin => GRB_OPCODE_SIN,
16-
:cos => GRB_OPCODE_COS,
17-
:tan => GRB_OPCODE_TAN,
18-
:^ => GRB_OPCODE_POW,
19-
:exp => GRB_OPCODE_EXP,
20-
:log => GRB_OPCODE_LOG,
21-
:log2 => GRB_OPCODE_LOG2,
22-
:log10 => GRB_OPCODE_LOG10,
23-
:logistic => GRB_OPCODE_LOGISTIC,
24-
)
25-
267
_supports_nonlinear() = _GUROBI_VERSION >= v"12.0.0"
278

9+
if _supports_nonlinear()
10+
const _OPCODE_MAP = Dict(
11+
:+ => GRB_OPCODE_PLUS,
12+
:- => GRB_OPCODE_MINUS,
13+
:* => GRB_OPCODE_MULTIPLY,
14+
:/ => GRB_OPCODE_DIVIDE,
15+
# GRB_OPCODE_UMINUS 6
16+
# GRB_OPCODE_SQUARE 7
17+
:sqrt => GRB_OPCODE_SQRT,
18+
:sin => GRB_OPCODE_SIN,
19+
:cos => GRB_OPCODE_COS,
20+
:tan => GRB_OPCODE_TAN,
21+
:^ => GRB_OPCODE_POW,
22+
:exp => GRB_OPCODE_EXP,
23+
:log => GRB_OPCODE_LOG,
24+
:log2 => GRB_OPCODE_LOG2,
25+
:log10 => GRB_OPCODE_LOG10,
26+
:logistic => GRB_OPCODE_LOGISTIC,
27+
)
28+
else
29+
const _OPCODE_MAP = Dict()
30+
end
31+
2832
function MOI.supports_constraint(
2933
::Optimizer,
3034
::Type{MOI.ScalarNonlinearFunction},

0 commit comments

Comments
 (0)