@@ -14,17 +14,22 @@ addprocs(np - 1)
1414 [n for n in names (mod) if isdefined (mod, n)]
1515end
1616
17- const list_problems =
17+ @everywhere const list_problems =
1818 setdiff (union (defined_names (ADNLPProblems), defined_names (PureJuMP)), [:PureJuMP , :ADNLPProblems ])
1919
20+ @testset " Test that all problems have a meta" begin
21+ @test sort (list_problems) == sort (Symbol .(OptimizationProblems. meta[! , :name ]))
22+ end
23+
2024# The problems included should be carefully argumented and issues
2125# to create them added.
2226# TODO : tests are limited for JuMP-only problems
23- const list_problems_not_ADNLPProblems =
27+ @everywhere const list_problems_not_ADNLPProblems =
2428 Symbol[:catmix , :gasoil , :glider , :methanol , :minsurf , :pinene , :rocket , :steering , :torsion ]
25- const list_problems_ADNLPProblems = setdiff (list_problems, list_problems_not_ADNLPProblems)
26- const list_problems_not_PureJuMP = Symbol[]
27- const list_problems_PureJuMP = setdiff (list_problems, list_problems_not_PureJuMP)
29+ @everywhere const list_problems_ADNLPProblems =
30+ setdiff (list_problems, list_problems_not_ADNLPProblems)
31+ @everywhere const list_problems_not_PureJuMP = Symbol[]
32+ @everywhere const list_problems_PureJuMP = setdiff (list_problems, list_problems_not_PureJuMP)
2833
2934include (" test-defined-problems.jl" )
3035include (" test-utils.jl" )
4550 error (" Problem $(prob) is not defined in $mod on pid $(myid ()) ." )
4651 end
4752 ctor = getfield (mod, prob)
48- return MathOptNLPModel (ctor (; kwargs... ))
53+ return MathOptNLPModel (ctor (; kwargs... ); name = " $prob " )
4954end
5055
5156@everywhere function make_ad_nlp (prob:: Symbol ; kwargs... )
5762 return ctor (matrix_free = true ; kwargs... )
5863end
5964
65+ include (" test-in-place-residual.jl" )
66+
6067@everywhere function test_one_problem (prob:: Symbol )
6168 pb = string (prob)
6269
7582
7683 nlp_ad = timed_info (" Instantiating $(pb) " , make_nlp, prob)
7784
78- @test nlp_ad. meta. name == pb
85+ @testset " Sanity check (name, obj)" begin
86+ @test nlp_ad. meta. name == pb
87+ @test ! isnothing (obj (nlp_ad, nlp_ad. meta. x0))
88+ end
7989
80- if pb in meta[(meta. contype .== :quadratic ) .| (meta. contype .== :general ), :name ]
90+ if (typeof (nlp_ad) <: ADNLPModels.AbstractADNLPModel ) &&
91+ (pb in meta[(meta. contype .== :quadratic ) .| (meta. contype .== :general ), :name ])
8192 @testset " Test In-place Nonlinear Constraints for AD-$prob " begin
8293 test_in_place_constraints (prob, nlp_ad)
8394 end
8495 end
8596
86- @testset " Test multi-precision ADNLPProblems for $prob " begin
87- test_multi_precision (prob, nlp_ad)
88- end
89-
90- if pb in meta[meta. objtype .== :least_squares , :name ]
91- @testset " Test Nonlinear Least Squares for $prob " begin
92- test_in_place_residual (prob)
97+ if typeof (nlp_ad) <: ADNLPModels.AbstractADNLPModel
98+ @testset " Test multi-precision ADNLPProblems for $prob " begin
99+ test_multi_precision (prob, nlp_ad)
93100 end
94101 end
95102
96- model = begin
97- mod = PureJuMP
98- if isdefined (mod, prob)
99- getfield (mod, prob)(n = ndef)
100- else
101- nothing
102- end
103- end
104- if ! isnothing (model)
103+ if mod in intersect (list_problems_PureJuMP, list_problems_ADNLPProblems)
105104 @testset " Test problems compatibility for $prob " begin
106- nlp_jump = MathOptNLPModel (model )
105+ nlp_jump = make_jump_nlp (prob; n = ndef )
107106 test_compatibility (prob, nlp_jump, nlp_ad, ndef)
108107 end
109108 end
110109end
111110
112- pmap (test_one_problem, list_problems_ADNLPProblems )
111+ pmap (test_one_problem, list_problems )
113112
114113include (" test-scalable.jl" )
115114
0 commit comments