-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathrun_minlptests.jl
168 lines (157 loc) · 5.56 KB
/
run_minlptests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Copyright (c) 2015: AmplNLWriter.jl contributors
#
# 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.
import Pkg
Pkg.pkg"add MINLPTests#od/nlp-expr"
import AmplNLWriter
import MINLPTests
using Test
const TERMINATION_TARGET = Dict(
MINLPTests.FEASIBLE_PROBLEM => AmplNLWriter.MOI.LOCALLY_SOLVED,
MINLPTests.INFEASIBLE_PROBLEM => AmplNLWriter.MOI.LOCALLY_INFEASIBLE,
)
const PRIMAL_TARGET = Dict(
MINLPTests.FEASIBLE_PROBLEM => AmplNLWriter.MOI.FEASIBLE_POINT,
MINLPTests.INFEASIBLE_PROBLEM => AmplNLWriter.MOI.NO_SOLUTION,
)
# Common reasons for exclusion:
# nlp/005_011 : Uses the function `\`
# nlp/006_010 : Uses a user-defined function
# nlp/007_010 : Ipopt returns an infeasible point, not NO_SOLUTION.
# nlp/008_010 : Couenne fails to converge
# nlp/008_011 : Couenne fails to converge
# nlp-cvx/109_010 : Ipopt fails to converge
# nlp-cvx/206_010 : Couenne can't evaluate pow
# nlp-mi/001_010 : Couenne fails to converge
const CONFIG = Dict{String,Any}()
import Bonmin_jll
CONFIG["Bonmin"] = Dict(
"amplexe" => Bonmin_jll.amplexe,
"options" => String["bonmin.nlp_log_level=0"],
"tol" => 1e-5,
"dual_tol" => NaN,
"nlp_exclude" => ["005_011", "006_010"],
"nlpcvx_exclude" => ["109_010"],
# 004_010 and 004_011 are tolerance failures on Bonmin
"nlpmi_exclude" => ["004_010", "004_011", "005_011", "006_010"],
"infeasible_point" => AmplNLWriter.MOI.NO_SOLUTION,
)
import Couenne_jll
CONFIG["Couenne"] = Dict(
"amplexe" => Couenne_jll.amplexe,
"options" => String[],
"tol" => 1e-2,
"dual_tol" => NaN,
"nlp_exclude" => ["005_011", "006_010", "008_010", "008_011"],
"nlpcvx_exclude" => ["109_010", "206_010"],
"nlpmi_exclude" => ["001_010", "005_011", "006_010"],
"infeasible_point" => AmplNLWriter.MOI.NO_SOLUTION,
)
import Ipopt_jll
CONFIG["Ipopt"] = Dict(
"amplexe" => Ipopt_jll.amplexe,
"options" => String["print_level=0"],
"tol" => 1e-5,
"dual_tol" => 1e-5,
"nlp_exclude" => ["005_011", "006_010", "007_010"],
"nlpcvx_exclude" => ["109_010"],
"nlpmi_exclude" => ["005_011", "006_010"],
"infeasible_point" => AmplNLWriter.MOI.NO_SOLUTION,
)
# SHOT fails too many tests to recommend using it.
# e.g., https://github.com/coin-or/SHOT/issues/134
# Even problems such as `@variable(model, x); @objective(model, Min, (x-1)^2)`
#
# import SHOT_jll
# CONFIG["SHOT"] = Dict(
# "amplexe" => SHOT_jll.amplexe,
# "options" => String[
# "Output.Console.LogLevel=6",
# "Output.File.LogLevel=6",
# "Termination.ObjectiveGap.Absolute=1e-6",
# "Termination.ObjectiveGap.Relative=1e-6",
# ],
# "tol" => 1e-2,
# "dual_tol" => NaN,
# "nlp_exclude" => [
# "005_011", # `\` function
# "006_010", # User-defined function
# ],
# "nlpcvx_exclude" => [
# "501_011", # `\` function
# ],
# "nlpmi_exclude" => [
# "005_011", # `\` function
# "006_010", # User-defined function
# ],
# "infeasible_point" => AmplNLWriter.MOI.UNKNOWN_RESULT_STATUS,
# )
@testset "$(name)" for name in ["Ipopt", "Bonmin", "Couenne"]
config = CONFIG[name]
OPTIMIZER =
() -> AmplNLWriter.Optimizer(config["amplexe"], config["options"])
PRIMAL_TARGET[MINLPTests.INFEASIBLE_PROBLEM] = config["infeasible_point"]
@testset "NLP" begin
MINLPTests.test_nlp(
OPTIMIZER,
exclude = config["nlp_exclude"],
termination_target = TERMINATION_TARGET,
primal_target = PRIMAL_TARGET,
objective_tol = config["tol"],
primal_tol = config["tol"],
dual_tol = config["dual_tol"],
)
MINLPTests.test_nlp_expr(
OPTIMIZER,
exclude = config["nlp_exclude"],
termination_target = TERMINATION_TARGET,
primal_target = PRIMAL_TARGET,
objective_tol = config["tol"],
primal_tol = config["tol"],
dual_tol = config["dual_tol"],
)
end
@testset "NLP-CVX" begin
MINLPTests.test_nlp_cvx(
OPTIMIZER,
exclude = config["nlpcvx_exclude"],
termination_target = TERMINATION_TARGET,
primal_target = PRIMAL_TARGET,
objective_tol = config["tol"],
primal_tol = config["tol"],
dual_tol = config["dual_tol"],
)
MINLPTests.test_nlp_cvx_expr(
OPTIMIZER,
exclude = config["nlpcvx_exclude"],
termination_target = TERMINATION_TARGET,
primal_target = PRIMAL_TARGET,
objective_tol = config["tol"],
primal_tol = config["tol"],
dual_tol = config["dual_tol"],
)
end
if name != "Ipopt"
@testset "NLP-MI" begin
MINLPTests.test_nlp_mi(
OPTIMIZER,
exclude = config["nlpmi_exclude"],
termination_target = TERMINATION_TARGET,
primal_target = PRIMAL_TARGET,
objective_tol = config["tol"],
primal_tol = config["tol"],
dual_tol = config["dual_tol"],
)
MINLPTests.test_nlp_mi_expr(
OPTIMIZER,
exclude = config["nlpmi_exclude"],
termination_target = TERMINATION_TARGET,
primal_target = PRIMAL_TARGET,
objective_tol = config["tol"],
primal_tol = config["tol"],
dual_tol = config["dual_tol"],
)
end
end
end