Skip to content

Commit 01253d3

Browse files
authored
Use NLPModelsTest instead of ADNLPModels (#84)
1 parent cb02e10 commit 01253d3

File tree

6 files changed

+16
-37
lines changed

6 files changed

+16
-37
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ NLPModels = "0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21"
1212
julia = "^1.6"
1313

1414
[extras]
15-
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
1615
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1716
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
17+
NLPModelsTest = "7998695d-6960-4d3a-85c4-e1bceb8cd856"
1818
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1919

2020
[targets]
21-
test = ["ADNLPModels", "LinearAlgebra", "Logging", "Test"]
21+
test = ["LinearAlgebra", "Logging", "NLPModelsTest", "Test"]

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
using SolverCore
33

44
# Auxiliary packages
5-
using ADNLPModels, NLPModels
5+
using NLPModels, NLPModelsTest
66

77
# stdlib
88
using LinearAlgebra, Logging, Test
99

1010
if VERSION v"1.6"
1111
@testset "Test allocations of solver specific" begin
12-
nlp = ADNLPModel(x -> sum(x), ones(2))
12+
nlp = BROWNDEN()
1313
stats = GenericExecutionStats(nlp) # stats = GenericExecutionStats(nlp, solver_specific = Dict{Symbol, Bool}())
1414
function fake_solver(stats)
1515
set_solver_specific!(stats, :test, true)

test/test_callback.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@testset "test callback" begin
2-
nlp =
3-
ADNLPModel(x -> dot(x, x) / 2, ones(2), x -> [sum(x .^ 3) - 1], [0.0], [0.0], name = "linquad")
2+
nlp = HS10()
43
callback(nlp, solver, stats) = begin
54
if stats.iter 3
65
set_status!(stats, :user)

test/test_logging.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
function test_logging()
2-
nlps = [ADNLPModel(x -> sum(x .^ k), ones(2k), name = "Sum of power $k") for k = 2:4]
3-
push!(
4-
nlps,
5-
ADNLPModel(x -> dot(x, x), ones(2), x -> [sum(x) - 1], [0.0], [0.0], name = "linquad"),
6-
)
2+
nlp = HS10()
73

84
@info "Testing logger"
95
log_header([:col_float, :col_int, :col_symbol, :col_string], [Float64, Int, Symbol, String])
@@ -12,8 +8,7 @@ function test_logging()
128

139
with_logger(ConsoleLogger()) do
1410
@info "Testing dummy solver with logger"
15-
SolverCore.dummy_solver(nlps[1], max_eval = 20)
16-
reset!.(nlps)
11+
SolverCore.dummy_solver(nlp, max_eval = 20)
1712
end
1813
end
1914

test/test_restart.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@testset "test restart" begin
2-
nlp = ADNLPModel(x -> dot(x, x) / 2, ones(2), x -> [sum(x .^ 3) - 1], [0.0], [0.0])
2+
nlp = HS10()
33
solver = SolverCore.DummySolver(nlp)
44
stats = GenericExecutionStats(nlp)
55
solve!(solver, nlp, stats, verbose = false)
@@ -10,7 +10,7 @@
1010
solve!(solver, nlp, stats, verbose = false)
1111
@test stats.status == :first_order
1212
# Try with a new problem of the same size
13-
nlp = ADNLPModel(x -> dot(x, x) / 2, ones(2), x -> [sum(x .^ 3)], [0.0], [0.0])
13+
nlp = HS10()
1414
reset!(solver, nlp)
1515
solve!(solver, nlp, stats, verbose = false)
1616
@test stats.status == :first_order

test/test_stats.jl

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function test_stats()
22
show_statuses()
3-
nlp = ADNLPModel(x -> dot(x, x), zeros(2))
3+
nlp = HS10()
44
stats = GenericExecutionStats(nlp)
55
set_status!(stats, :first_order)
66
set_objective!(stats, 1.0)
@@ -36,7 +36,7 @@ function test_stats()
3636

3737
@testset "Testing inference" begin
3838
for T in (Float16, Float32, Float64, BigFloat)
39-
nlp = ADNLPModel(x -> dot(x, x), ones(T, 2))
39+
nlp = BROWNDEN(T)
4040

4141
stats = GenericExecutionStats(nlp)
4242
set_status!(stats, :first_order)
@@ -46,7 +46,7 @@ function test_stats()
4646
@test typeof(stats.dual_feas) == T
4747
@test typeof(stats.primal_feas) == T
4848

49-
nlp = ADNLPModel(x -> dot(x, x), ones(T, 2), x -> [sum(x) - 1], T[0], T[0])
49+
nlp = HS14(T)
5050

5151
stats = GenericExecutionStats(nlp)
5252
set_status!(stats, :first_order)
@@ -78,7 +78,7 @@ function test_stats()
7878

7979
@testset "Testing Dummy Solver with multi-precision" begin
8080
for T in (Float16, Float32, Float64, BigFloat)
81-
nlp = ADNLPModel(x -> dot(x, x), ones(T, 2))
81+
nlp = HS10(T)
8282
solver = SolverCore.DummySolver(nlp)
8383

8484
stats = with_logger(NullLogger()) do
@@ -92,21 +92,6 @@ function test_stats()
9292
@test eltype(stats.multipliers_L) == T
9393
@test eltype(stats.multipliers_U) == T
9494

95-
nlp = ADNLPModel(x -> dot(x, x), ones(T, 2), x -> [sum(x) - 1], T[0], T[0])
96-
solver = SolverCore.DummySolver(nlp)
97-
stats = GenericExecutionStats(nlp)
98-
99-
with_logger(NullLogger()) do
100-
solve!(solver, nlp, stats)
101-
end
102-
@test typeof(stats.objective) == T
103-
@test typeof(stats.dual_feas) == T
104-
@test typeof(stats.primal_feas) == T
105-
@test eltype(stats.solution) == T
106-
@test eltype(stats.multipliers) == T
107-
@test eltype(stats.multipliers_L) == T
108-
@test eltype(stats.multipliers_U) == T
109-
11095
stats = GenericExecutionStats{T, Vector{T}, Vector{T}, Any}()
11196
reset!(stats, nlp)
11297
with_logger(NullLogger()) do
@@ -124,7 +109,7 @@ function test_stats()
124109

125110
@testset "Test stats setters" begin
126111
T = Float64
127-
nlp = ADNLPModel(x -> dot(x, x), ones(T, 2), x -> [sum(x) - 1], T[0], T[0])
112+
nlp = HS14(T)
128113
stats = GenericExecutionStats(nlp)
129114
fields = (
130115
"status",
@@ -173,7 +158,7 @@ end
173158
test_stats()
174159

175160
@testset "Test get_status" begin
176-
nlp = ADNLPModel(x -> sum(x), ones(2))
161+
nlp = BROWNDEN()
177162
@test get_status(nlp, optimal = true) == :first_order
178163
@test get_status(nlp, small_residual = true) == :small_residual
179164
@test get_status(nlp, infeasible = true) == :infeasible
@@ -191,7 +176,7 @@ test_stats()
191176
end
192177

193178
@testset "Test get_status for NLS" begin
194-
nlp = ADNLSModel(x -> x, ones(2), 2)
179+
nlp = BNDROSENBROCK()
195180
@test get_status(nlp, optimal = true) == :first_order
196181
@test get_status(nlp, small_residual = true) == :small_residual
197182
@test get_status(nlp, infeasible = true) == :infeasible

0 commit comments

Comments
 (0)