Skip to content

Commit

Permalink
Move MathOptInterface support to extension (#204)
Browse files Browse the repository at this point in the history
* compat and version bumps

* strip out MathProgBase support

* move MathOptInterface support to extension

* update CI

* support Julia 1.6

* remove dead comment

* be less explicit

* change extension name

Co-authored by: Alex Arslan <[email protected]>

* bump to 1.0
  • Loading branch information
palday authored Aug 19, 2023
1 parent f90c218 commit 16f5598
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 256 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
- version: '1'
os: windows-latest
arch: x86
- version: '1.3'
- version: '1.6'
os: ubuntu-latest
arch: x64
- version: '1.3'
- version: '1.6'
os: ubuntu-latest
arch: x86
- version: 'nightly'
Expand Down
17 changes: 11 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
name = "NLopt"
uuid = "76087f3c-5699-56af-9a33-bf431cd00edd"
version = "0.6.6"
version = "1.0.0"

[deps]
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
MathProgBase = "fdba3010-5040-5b88-9595-932c9decdf73"
NLopt_jll = "079eb43e-fd8e-5478-9966-2cf3e3edb778"

[compat]
MathOptInterface = "0.10.4, 1"
MathProgBase = "0.5, 0.6, 0.7, 0.8"
MathOptInterface = "1"
NLopt_jll = "2.7"
julia = "1.3"
julia = "1.6"

[extensions]
NLoptMathOptInterfaceExt = ["MathOptInterface"]

[extras]
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["MathOptInterface", "Test"]

[weakdeps]
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
13 changes: 13 additions & 0 deletions src/MOI_wrapper.jl → ext/NLoptMathOptInterfaceExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

module NLoptMathOptInterfaceExt

using NLopt

import MathOptInterface

const MOI = MathOptInterface

function __init__()
# we need to add extension types back to the toplevel module
@static if VERSION >= v"1.9"
setglobal!(NLopt, :Optimizer, Optimizer)
end
end

mutable struct _ConstraintInfo{F,S}
func::F
set::S
Expand Down Expand Up @@ -1177,3 +1188,5 @@ function MOI.get(
MOI.throw_if_not_valid(model, ci)
return model.constraint_primal_quadratic_eq[ci.value]
end

end # module
225 changes: 0 additions & 225 deletions src/MPB_wrapper.jl

This file was deleted.

12 changes: 5 additions & 7 deletions src/NLopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ export Opt, NLOPT_VERSION, algorithm, algorithm_name, ForcedStop,
min_objective!, max_objective!, equality_constraint!, inequality_constraint!, remove_constraints!,
optimize!, optimize, Algorithm, Result

import MathProgBase.SolverInterface
import MathProgBase.SolverInterface.optimize!

using NLopt_jll

############################################################################
Expand Down Expand Up @@ -633,9 +630,10 @@ end
optimize(o::Opt, x::AbstractVector{<:Real}) =
optimize!(o, copyto!(Array{Cdouble}(undef,length(x)), x))

############################################################################

include("MPB_wrapper.jl")
include("MOI_wrapper.jl")
if !isdefined(Base, :get_extension)
include("../ext/NLoptMathOptInterfaceExt.jl")
using .NLoptMathOptInterfaceExt
const Optimizer = NLoptMathOptInterfaceExt.Optimizer
end

end # module
14 changes: 0 additions & 14 deletions test/MPB_wrapper.jl

This file was deleted.

2 changes: 0 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

include("tutorial.jl")
include("fix133.jl")
include("MPB_wrapper.jl")
include("MOI_wrapper.jl")

using NLopt
Expand All @@ -27,4 +26,3 @@ end
)
@test_throws err opt.initial_step
end

2 comments on commit 16f5598

@stevengj
Copy link
Collaborator

Choose a reason for hiding this comment

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

@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/89929

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 v1.0.0 -m "<description of version>" 16f5598fd6026759a9d41636c338dce658901118
git push origin v1.0.0

Please sign in to comment.