11function test_stats ()
2- show_statuses ()
32 nlp = ADNLPModel (x-> dot (x,x), zeros (2 ))
4- stats = GenericExecutionStats (
3+ stats = OptSolverOutput (
54 :first_order ,
5+ ones (100 ),
66 nlp,
77 objective= 1.0 ,
88 dual_feas= 1e-12 ,
9- solution= ones (100 ),
109 iter= 10 ,
1110 solver_specific= Dict (:matvec => 10 ,
1211 :dot => 25 ,
@@ -17,39 +16,23 @@ function test_stats()
1716 )
1817 )
1918
20- show (stats)
21- print (stats)
22- println (stats)
23- open (" teststats.out" , " w" ) do f
24- println (f, stats)
25- end
26-
27- println (stats, showvec= (io,x)-> print (io,x))
28- open (" teststats.out" , " a" ) do f
29- println (f, stats, showvec= (io,x)-> print (io,x))
30- end
31-
32- line = [:status , :neval_obj , :objective , :iter ]
33- for field in line
34- value = statsgetfield (stats, field)
35- println (" $field -> $value " )
36- end
37- println (statshead (line))
38- println (statsline (stats, line))
19+ io = IOBuffer ()
20+ show (io, stats)
21+ @test String (take! (io)) == " Solver output of type OptSolverOutput{Float64}\n Status: first-order stationary\n "
3922
4023 @testset " Testing inference" begin
4124 for T in (Float16, Float32, Float64, BigFloat)
4225 nlp = ADNLPModel (x-> dot (x, x), ones (T, 2 ))
4326
44- stats = GenericExecutionStats (:first_order , nlp)
27+ stats = OptSolverOutput (:first_order , nlp . meta . x0 , nlp)
4528 @test stats. status == :first_order
4629 @test typeof (stats. objective) == T
4730 @test typeof (stats. dual_feas) == T
4831 @test typeof (stats. primal_feas) == T
4932
5033 nlp = ADNLPModel (x-> dot (x, x), ones (T, 2 ), x-> [sum (x)- 1 ], [0.0 ], [0.0 ])
5134
52- stats = GenericExecutionStats (:first_order , nlp)
35+ stats = OptSolverOutput (:first_order , nlp . meta . x0 , nlp)
5336 @test stats. status == :first_order
5437 @test typeof (stats. objective) == T
5538 @test typeof (stats. dual_feas) == T
@@ -58,17 +41,16 @@ function test_stats()
5841 end
5942
6043 @testset " Test throws" begin
61- @test_throws Exception GenericExecutionStats (:bad , nlp)
62- @test_throws Exception GenericExecutionStats (:unkwown , nlp, bad= true )
44+ @test_throws Exception OptSolverOutput (:bad , nlp)
45+ @test_throws Exception OptSolverOutput (:unkwown , nlp, bad= true )
6346 end
6447
6548 @testset " Testing Dummy Solver with multi-precision" begin
66- solver = DummySolver ()
6749 for T in (Float16, Float32, Float64, BigFloat)
6850 nlp = ADNLPModel (x-> dot (x, x), ones (T, 2 ))
6951
70- with_logger (NullLogger ()) do
71- stats = solver (nlp)
52+ stats, solver = with_logger (NullLogger ()) do
53+ DummySolver (nlp)
7254 end
7355 @test typeof (stats. objective) == T
7456 @test typeof (stats. dual_feas) == T
@@ -80,8 +62,8 @@ function test_stats()
8062
8163 nlp = ADNLPModel (x-> dot (x, x), ones (T, 2 ), x-> [sum (x)- 1 ], [0.0 ], [0.0 ])
8264
83- with_logger (NullLogger ()) do
84- stats = solver (nlp)
65+ stats, solver = with_logger (NullLogger ()) do
66+ DummySolver (nlp)
8567 end
8668 @test typeof (stats. objective) == T
8769 @test typeof (stats. dual_feas) == T
0 commit comments