11using ACEfit
2- using LinearAlgebra, Random, Test
2+ using LinearAlgebra, Random, Test
33
44# #
55
@@ -47,7 +47,7 @@ for (select, tolr, tolc) in [ (:final, 10*epsn, 1),
4747 results = ACEfit. solve (solver, A, y)
4848 C = results[" C" ]
4949 full_path = results[" path" ]
50- @show results[" nnzs" ]
50+ # @show results["nnzs"]
5151 @show norm (A * C - y)
5252 @show norm (C)
5353 @show norm (C - c_ref)
@@ -60,7 +60,7 @@ for (select, tolr, tolc) in [ (:final, 10*epsn, 1),
6060 results = ACEfit. solve (solver, At, yt, Av, yv)
6161 C = results[" C" ]
6262 full_path = results[" path" ]
63- @show results[" nnzs" ]
63+ # @show results["nnzs"]
6464 @show norm (Av * C - yv)
6565 @show norm (C)
6666 @show norm (C - c_ref)
@@ -91,7 +91,7 @@ for (select, tolr, tolc) in [ (:final, 20*epsn, 1.5),
9191 C_tsvd = results_tsvd[" C" ]
9292 C = results[" C" ]
9393
94- @show results[" nnzs" ]
94+ # @show results["nnzs"]
9595 @show norm (A * C - y)
9696 @show norm (A * C_tsvd - y)
9797 if norm (A * C_tsvd - y)< norm (A * C - y)
@@ -106,7 +106,7 @@ for (select, tolr, tolc) in [ (:final, 20*epsn, 1.5),
106106 results = ACEfit. solve (solver, At, yt, Av, yv)
107107 C_tsvd = results_tsvd[" C" ]
108108 C = results[" C" ]
109- @show results[" nnzs" ]
109+ # @show results["nnzs"]
110110 @show norm (A * C - y)
111111 @show norm (A * C_tsvd - y)
112112
@@ -117,3 +117,36 @@ for (select, tolr, tolc) in [ (:final, 20*epsn, 1.5),
117117 end
118118end
119119
120+ # #
121+
122+ # Testing the "select" function
123+ solver_final = ACEfit. ASP (
124+ P = I,
125+ select = :final ,
126+ tsvd = false ,
127+ nstore = 100 ,
128+ loglevel = 0
129+ )
130+
131+ results_final = ACEfit. solve (solver_final, At, yt, Av, yv)
132+ tracer_final = results_final[" path" ]
133+
134+ # Warm-start the solver using the tracer from the final iteration
135+ # select best solution with <= 73 non-zero entries
136+ select = (:bysize , 73 )
137+ C_select, _ = ACEfit. asp_select (tracer_final, select)
138+ @test ( length (C_select. nzind) <= 73 )
139+
140+ # Check if starting the solver initially with (:bysize, 73) gives the same result
141+ solver_bysize = ACEfit. ASP (
142+ P = I,
143+ select = (:bysize , 73 ),
144+ tsvd = false ,
145+ nstore = 100 ,
146+ loglevel = 0
147+ )
148+
149+ results_bysize = ACEfit. solve (solver_bysize, At, yt, Av, yv)
150+ @test results_bysize[" C" ] == C_select # works
151+
152+
0 commit comments