Skip to content

Commit b70d847

Browse files
authored
Check that all parameters in parameter set work (#309)
* add parameter test * format * Update test/runtests.jl
1 parent b2d1f33 commit b70d847

3 files changed

Lines changed: 51 additions & 3 deletions

File tree

src/trunk.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,19 @@ end
172172
::Val{:Newton},
173173
nlp::AbstractNLPModel;
174174
x::V = nlp.meta.x0,
175+
bk_max::Int = get(TRUNK_bk_max, nlp),
176+
monotone::Bool = get(TRUNK_monotone, nlp),
177+
nm_itmax::Int = get(TRUNK_nm_itmax, nlp),
175178
subsolver::Symbol = :cg,
176179
kwargs...,
177180
) where {V}
178-
solver = TrunkSolver(nlp; subsolver)
181+
solver = TrunkSolver(
182+
nlp;
183+
bk_max = bk_max,
184+
monotone = monotone,
185+
nm_itmax = nm_itmax,
186+
subsolver = subsolver,
187+
)
179188
return solve!(solver, nlp; x = x, kwargs...)
180189
end
181190

src/trunkls.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,19 @@ end
206206
::Val{:GaussNewton},
207207
nlp::AbstractNLSModel;
208208
x::V = nlp.meta.x0,
209+
bk_max::Int = get(TRUNKLS_bk_max, nlp),
210+
monotone::Bool = get(TRUNKLS_monotone, nlp),
211+
nm_itmax::Int = get(TRUNKLS_nm_itmax, nlp),
209212
subsolver::Symbol = :lsmr,
210213
kwargs...,
211214
) where {V}
212-
solver = TrunkSolverNLS(nlp; subsolver)
215+
solver = TrunkSolverNLS(
216+
nlp;
217+
bk_max = bk_max,
218+
monotone = monotone,
219+
nm_itmax = nm_itmax,
220+
subsolver = subsolver,
221+
)
213222
return solve!(solver, nlp; x = x, kwargs...)
214223
end
215224

test/runtests.jl

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,41 @@ using Printf, LinearAlgebra, Logging, SparseArrays, Test
33

44
# additional packages
55
using ADNLPModels, LinearOperators, NLPModels, NLPModelsModifiers, SolverCore, SolverTools
6-
using NLPModelsTest
6+
using NLPModelsTest, SolverParameters
77

88
# this package
99
using JSOSolvers
1010

11+
@testset "Test parameterset" begin
12+
@testset "Test unconstrained parameters $paramset" for (paramset, fun) in (
13+
(LBFGSParameterSet, lbfgs),
14+
(TRONParameterSet, tron),
15+
(TRUNKParameterSet, trunk),
16+
(FOMOParameterSet, fomo),
17+
)
18+
nlp = BROWNDEN()
19+
params = eval(paramset)(nlp)
20+
args = Dict(
21+
sym => SolverParameters.value(getfield(params, sym)) for sym in fieldnames(typeof(params))
22+
)
23+
stats = fun(nlp; args...)
24+
@test stats.status == :first_order
25+
end
26+
27+
@testset "Test unconstrained NLS parameters $paramset" for (paramset, fun) in (
28+
(TRONLSParameterSet, tron),
29+
(TRUNKLSParameterSet, trunk),
30+
)
31+
nls = MGH01()
32+
params = eval(paramset)(nls)
33+
args = Dict(
34+
sym => SolverParameters.value(getfield(params, sym)) for sym in fieldnames(typeof(params))
35+
)
36+
stats = fun(nls; args...)
37+
@test stats.status == :first_order
38+
end
39+
end
40+
1141
@testset "Test small residual checks $solver" for solver in (:TrunkSolverNLS, :TronSolverNLS)
1242
nls = ADNLSModel(x -> [x[1] - 1; sin(x[2])], [-1.2; 1.0], 2)
1343
stats = GenericExecutionStats(nls)

0 commit comments

Comments
 (0)