Skip to content

Commit c7a06c4

Browse files
Merge branch 'SciML:master' into master
2 parents cb0668a + fd771c8 commit c7a06c4

File tree

2 files changed

+18
-62
lines changed

2 files changed

+18
-62
lines changed

lib/OptimizationMOI/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OptimizationMOI"
22
uuid = "fd9f6733-72f4-499f-8506-86b2bdd0dea1"
33
authors = ["Vaibhav Dixit <[email protected]> and contributors"]
4-
version = "0.5.3"
4+
version = "0.5.4"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -22,7 +22,7 @@ Ipopt_jll = "300.1400"
2222
Juniper = "0.9"
2323
LinearAlgebra = "1"
2424
MathOptInterface = "1"
25-
ModelingToolkit = "9"
25+
ModelingToolkit = "9, 10"
2626
NLopt = "1"
2727
Optimization = "4"
2828
Reexport = "1.2"

lib/OptimizationNLopt/src/OptimizationNLopt.jl

Lines changed: 16 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,82 +10,38 @@ using Optimization: deduce_retcode
1010
SciMLBase.allowsbounds(opt::Union{NLopt.Algorithm, NLopt.Opt}) = true
1111
SciMLBase.supports_opt_cache_interface(opt::Union{NLopt.Algorithm, NLopt.Opt}) = true
1212

13-
function SciMLBase.requiresgradient(opt::Union{NLopt.Algorithm, NLopt.Opt}) #https://github.com/JuliaOpt/NLopt.jl/blob/master/src/NLopt.jl#L18C7-L18C16
14-
str_opt = if opt isa NLopt.Algorithm
15-
string(opt)
16-
else
17-
string(opt.algorithm)
18-
end
19-
if str_opt[2] == 'N'
20-
return false
21-
else
22-
return true
23-
end
13+
function SciMLBase.requiresgradient(opt::Union{NLopt.Algorithm, NLopt.Opt})
14+
# https://github.com/JuliaOpt/NLopt.jl/blob/master/src/NLopt.jl#L18C7-L18C16
15+
str_opt = string(opt isa NLopt.Algorithm ? opt : opt.algorithm)
16+
return str_opt[2] != 'N'
2417
end
2518

2619
#interferes with callback handling
2720
# function SciMLBase.allowsfg(opt::Union{NLopt.Algorithm, NLopt.Opt})
28-
# str_opt = if opt isa NLopt.Algorithm
29-
# string(opt)
30-
# else
31-
# string(opt.algorithm)
32-
# end
33-
# if str_opt[2] == 'D'
34-
# return true
35-
# else
36-
# return false
37-
# end
21+
# str_opt = string(opt isa NLopt.Algorithm ? opt : opt.algorithm)
22+
# return str_opt[2] == 'D'
3823
# end
3924

40-
function SciMLBase.requireshessian(opt::Union{NLopt.Algorithm, NLopt.Opt}) #https://github.com/JuliaOpt/NLopt.jl/blob/master/src/NLopt.jl#L18C7-L18C16
41-
str_opt = if opt isa NLopt.Algorithm
42-
string(opt)
43-
else
44-
string(opt.algorithm)
45-
end
46-
47-
if str_opt[2] == 'N' || occursin("LD_LBFGS", str_opt) || occursin("LD_SLSQP", str_opt)
48-
return false
49-
else
50-
return true
51-
end
25+
function SciMLBase.requireshessian(opt::Union{NLopt.Algorithm, NLopt.Opt})
26+
# https://github.com/JuliaOpt/NLopt.jl/blob/master/src/NLopt.jl#L18C7-L18C16
27+
str_opt = string(opt isa NLopt.Algorithm ? opt : opt.algorithm)
28+
return !(str_opt[2] == 'N' || occursin(r"LD_LBFGS|LD_SLSQP", str_opt))
5229
end
5330

54-
function SciMLBase.requiresconsjac(opt::Union{NLopt.Algorithm, NLopt.Opt}) #https://github.com/JuliaOpt/NLopt.jl/blob/master/src/NLopt.jl#L18C7-L18C16
55-
str_opt = if opt isa NLopt.Algorithm
56-
string(opt)
57-
else
58-
string(opt.algorithm)
59-
end
60-
if str_opt[3] == 'O' || str_opt[3] == 'I' || str_opt[5] == 'G'
61-
return true
62-
else
63-
return false
64-
end
31+
function SciMLBase.requiresconsjac(opt::Union{NLopt.Algorithm, NLopt.Opt})
32+
# https://github.com/JuliaOpt/NLopt.jl/blob/master/src/NLopt.jl#L18C7-L18C16
33+
str_opt = string(opt isa NLopt.Algorithm ? opt : opt.algorithm)
34+
return str_opt[3] ['O', 'I'] || str_opt[5] == 'G'
6535
end
6636

6737
function SciMLBase.allowsconstraints(opt::NLopt.Algorithm)
6838
str_opt = string(opt)
69-
if occursin("AUGLAG", str_opt) || occursin("CCSA", str_opt) ||
70-
occursin("MMA", str_opt) || occursin("COBYLA", str_opt) ||
71-
occursin("ISRES", str_opt) || occursin("AGS", str_opt) ||
72-
occursin("ORIG_DIRECT", str_opt) || occursin("SLSQP", str_opt)
73-
return true
74-
else
75-
return false
76-
end
39+
return occursin(r"AUGLAG|CCSA|MMA|COBYLA|ISRES|AGS|ORIG_DIRECT|SLSQP", str_opt)
7740
end
7841

7942
function SciMLBase.requiresconsjac(opt::NLopt.Algorithm)
8043
str_opt = string(opt)
81-
if occursin("AUGLAG", str_opt) || occursin("CCSA", str_opt) ||
82-
occursin("MMA", str_opt) || occursin("COBYLA", str_opt) ||
83-
occursin("ISRES", str_opt) || occursin("AGS", str_opt) ||
84-
occursin("ORIG_DIRECT", str_opt) || occursin("SLSQP", str_opt)
85-
return true
86-
else
87-
return false
88-
end
44+
return occursin(r"AUGLAG|CCSA|MMA|COBYLA|ISRES|AGS|ORIG_DIRECT|SLSQP", str_opt)
8945
end
9046

9147
function SciMLBase.__init(prob::SciMLBase.OptimizationProblem, opt::NLopt.Algorithm,

0 commit comments

Comments
 (0)