Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Aug 19, 2024
1 parent c03887c commit 49c4203
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 52 deletions.
8 changes: 5 additions & 3 deletions gen/gen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ header = """

filename = joinpath(@__DIR__, "..", "src", "libnlopt.jl")
contents = read(filename, String)
contents = header * contents
contents = replace(contents, "const nlopt_opt = Ptr{nlopt_opt_s}" => "const nlopt_opt = Ptr{Cvoid}")
write(filename, contents)
contents = replace(
contents,
"const nlopt_opt = Ptr{nlopt_opt_s}" => "const nlopt_opt = Ptr{Cvoid}",
)
write(filename, header * contents)
98 changes: 49 additions & 49 deletions src/NLopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,9 @@

module NLopt

export Opt,
NLOPT_VERSION,
algorithm,
algorithm_name,
ForcedStop,
lower_bounds!,
lower_bounds,
upper_bounds!,
upper_bounds,
stopval!,
stopval,
ftol_rel!,
ftol_rel,
ftol_abs!,
ftol_abs,
xtol_rel!,
xtol_rel,
xtol_abs!,
xtol_abs,
maxeval!,
maxeval,
maxtime!,
maxtime,
force_stop!,
force_stop,
population!,
population,
vector_storage!,
vector_storage,
initial_step!,
initial_step,
default_initial_step!,
local_optimizer!,
min_objective!,
max_objective!,
equality_constraint!,
inequality_constraint!,
remove_constraints!,
optimize!,
optimize,
Algorithm,
Result

using NLopt_jll
using CEnum: @cenum
using NLopt_jll: libnlopt

using CEnum
include("libnlopt.jl")

############################################################################
Expand Down Expand Up @@ -105,14 +62,14 @@ end

Base.convert(::Type{nlopt_algorithm}, a::Algorithm) = nlopt_algorithm(Int(a))

const sym2alg = Dict(Symbol(i) => i for i in instances(Algorithm))
const _SYMBOL_TO_ALGORITHM = Dict(Symbol(i) => i for i in instances(Algorithm))

function Algorithm(name::Symbol)
alg = get(sym2alg, name, nothing)
if alg === nothing
algorithm = get(_SYMBOL_TO_ALGORITHM, name, nothing)
if algorithm === nothing
throw(ArgumentError("unknown algorithm $name"))
end
return alg::Algorithm
return algorithm::Algorithm
end

# enum nlopt_result
Expand Down Expand Up @@ -853,4 +810,47 @@ else
global Optimizer
end

export Opt,
NLOPT_VERSION,
algorithm,
algorithm_name,
ForcedStop,
lower_bounds!,
lower_bounds,
upper_bounds!,
upper_bounds,
stopval!,
stopval,
ftol_rel!,
ftol_rel,
ftol_abs!,
ftol_abs,
xtol_rel!,
xtol_rel,
xtol_abs!,
xtol_abs,
maxeval!,
maxeval,
maxtime!,
maxtime,
force_stop!,
force_stop,
population!,
population,
vector_storage!,
vector_storage,
initial_step!,
initial_step,
default_initial_step!,
local_optimizer!,
min_objective!,
max_objective!,
equality_constraint!,
inequality_constraint!,
remove_constraints!,
optimize!,
optimize,
Algorithm,
Result

end # module

0 comments on commit 49c4203

Please sign in to comment.