Skip to content

Commit

Permalink
Fix typo when adding vector of constraints (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jan 25, 2023
1 parent 8fcade4 commit a1aeec2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/NLopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ for c in (:inequality, :equality)
$cf(o::Opt, f::Function, tol::AbstractVector{<:Real}) =
$cf(o, f, Array{Float64}(tol))
$cf(o::Opt, m::Integer, f::Function, tol::Real=0.0) =
$cf(o, f, fill!(Cdouble(tol), m))
$cf(o, f, fill(Cdouble(tol), m))
end
end

Expand Down
11 changes: 11 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@ include("tutorial.jl")
include("fix133.jl")
include("MPB_wrapper.jl")
include("MOI_wrapper.jl")

using NLopt
using Test

@testset "Fix #163" begin
opt = Opt(:LN_COBYLA, 2)
opt.min_objective = (x, g) -> sum(x.^2)
inequality_constraint!(opt, 2, (result, x, g) -> (result .= 1 .- x))
(minf, minx, ret) = optimize(opt, [2.0, 2.0])
@test minx [1.0, 1.0]
end

0 comments on commit a1aeec2

Please sign in to comment.