11@testset " R2N" begin
2- # BASIC TESTS
3- # Test basic NLP with 2-norm
4- @testset " BASIC" begin
5- rosenbrock_nlp = construct_rosenbrock_nlp ()
6- rosenbrock_reg_nlp = RegularizedNLPModel (rosenbrock_nlp, NormL2 (0.01 ))
2+ # BASIC TESTS
3+ # Test basic NLP with 2-norm
4+ @testset " BASIC" begin
5+ rosenbrock_nlp = construct_rosenbrock_nlp ()
6+ rosenbrock_reg_nlp = RegularizedNLPModel (rosenbrock_nlp, NormL2 (0.01 ))
77
8- # Test first order status
9- first_order_kwargs = (atol = 1e-6 , rtol = 1e-6 )
10- test_solver (rosenbrock_reg_nlp,
11- " R2N" ,
12- expected_status = :first_order ,
13- solver_kwargs= first_order_kwargs)
14- solver, stats = R2NSolver (rosenbrock_reg_nlp), RegularizedExecutionStats (rosenbrock_reg_nlp)
8+ # Test first order status
9+ first_order_kwargs = (atol = 1e-6 , rtol = 1e-6 )
10+ test_solver (
11+ rosenbrock_reg_nlp,
12+ " R2N" ,
13+ expected_status = :first_order ,
14+ solver_kwargs = first_order_kwargs,
15+ )
16+ solver, stats = R2NSolver (rosenbrock_reg_nlp), RegularizedExecutionStats (rosenbrock_reg_nlp)
1517
16- # Test max time status
17- max_time_kwargs = (x0 = [π, - π], atol = 1e-16 , rtol = 1e-16 , max_time = 1e-12 )
18- test_solver (rosenbrock_reg_nlp,
19- " R2N" ,
20- expected_status = :max_time ,
21- solver_kwargs= max_time_kwargs)
18+ # Test max time status
19+ max_time_kwargs = (x0 = [π, - π], atol = 1e-16 , rtol = 1e-16 , max_time = 1e-12 )
20+ test_solver (
21+ rosenbrock_reg_nlp,
22+ " R2N" ,
23+ expected_status = :max_time ,
24+ solver_kwargs = max_time_kwargs,
25+ )
2226
23- # Test max iter status
24- max_iter_kwargs = (x0 = [π, - π], atol = 1e-16 , rtol = 1e-16 , max_iter = 1 )
25- test_solver (rosenbrock_reg_nlp,
26- " R2N" ,
27- expected_status = :max_iter ,
28- solver_kwargs= max_iter_kwargs)
29-
30- # Test max eval status
31- max_eval_kwargs = (x0 = [π, - π], atol = 1e-16 , rtol = 1e-16 , max_eval = 1 )
32- test_solver (rosenbrock_reg_nlp,
33- " R2N" ,
34- expected_status = :max_eval ,
35- solver_kwargs= max_eval_kwargs)
36-
37- end
38- # BPDN TESTS
27+ # Test max iter status
28+ max_iter_kwargs = (x0 = [π, - π], atol = 1e-16 , rtol = 1e-16 , max_iter = 1 )
29+ test_solver (
30+ rosenbrock_reg_nlp,
31+ " R2N" ,
32+ expected_status = :max_iter ,
33+ solver_kwargs = max_iter_kwargs,
34+ )
3935
40- # Test bpdn with L-BFGS and 1-norm
41- @testset " BPDN " begin
42- bpdn_kwargs = (x0 = zeros (bpdn . meta . nvar),σk = 1.0 , β = 1e16 , atol = 1e-6 , rtol = 1e-6 )
43- reg_nlp = RegularizedNLPModel ( LBFGSModel (bpdn), NormL1 (λ))
44- test_solver (reg_nlp,
45- " R2N " ,
46- expected_status = :first_order ,
47- solver_kwargs = bpdn_kwargs )
48- solver, stats = R2NSolver (reg_nlp), RegularizedExecutionStats (reg_nlp)
49- @test @wrappedallocs ( solve! (solver, reg_nlp, stats, σk = 1.0 , β = 1e16 , atol = 1e-6 , rtol = 1e-6 )) == 0
36+ # Test max eval status
37+ max_eval_kwargs = (x0 = [π, - π], atol = 1e-16 , rtol = 1e-16 , max_eval = 1 )
38+ test_solver (
39+ rosenbrock_reg_nlp,
40+ " R2N " ,
41+ expected_status = :max_eval ,
42+ solver_kwargs = max_eval_kwargs ,
43+ )
44+ end
45+ # BPDN TESTS
5046
51- # test_solver(reg_nlp, # FIXME
52- # "R2N",
53- # expected_status = :first_order,
54- # solver_kwargs=bpdn_kwargs,
55- # solver_constructor_kwargs=(subsolver=R2DHSolver,))
47+ # Test bpdn with L-BFGS and 1-norm
48+ @testset " BPDN" begin
49+ bpdn_kwargs = (x0 = zeros (bpdn. meta. nvar), σk = 1.0 , β = 1e16 , atol = 1e-6 , rtol = 1e-6 )
50+ reg_nlp = RegularizedNLPModel (LBFGSModel (bpdn), NormL1 (λ))
51+ test_solver (reg_nlp, " R2N" , expected_status = :first_order , solver_kwargs = bpdn_kwargs)
52+ solver, stats = R2NSolver (reg_nlp), RegularizedExecutionStats (reg_nlp)
53+ @test @wrappedallocs (
54+ solve! (solver, reg_nlp, stats, σk = 1.0 , β = 1e16 , atol = 1e-6 , rtol = 1e-6 )
55+ ) == 0
5656
57- # Test bpdn with L-SR1 and 0-norm
58- reg_nlp = RegularizedNLPModel (LSR1Model (bpdn), NormL0 (λ))
59- test_solver (reg_nlp,
60- " R2N" ,
61- expected_status = :first_order ,
62- solver_kwargs= bpdn_kwargs)
63- solver, stats = R2NSolver (reg_nlp), RegularizedExecutionStats (reg_nlp)
64- @test @wrappedallocs (solve! (solver, reg_nlp, stats, σk = 1.0 , β = 1e16 , atol = 1e-6 , rtol = 1e-6 )) == 0
57+ # test_solver(reg_nlp, # FIXME
58+ # "R2N",
59+ # expected_status = :first_order,
60+ # solver_kwargs=bpdn_kwargs,
61+ # solver_constructor_kwargs=(subsolver=R2DHSolver,))
6562
66- test_solver (reg_nlp,
67- " R2N" ,
68- expected_status = :first_order ,
69- solver_kwargs= bpdn_kwargs,
70- solver_constructor_kwargs= (subsolver= R2DHSolver,))
71- solver, stats = R2NSolver (reg_nlp, subsolver = R2DHSolver), RegularizedExecutionStats (reg_nlp)
72- @test @wrappedallocs (solve! (solver, reg_nlp, stats, σk = 1.0 , β = 1e16 , atol = 1e-6 , rtol = 1e-6 )) == 0
73- end
74- end
63+ # Test bpdn with L-SR1 and 0-norm
64+ reg_nlp = RegularizedNLPModel (LSR1Model (bpdn), NormL0 (λ))
65+ test_solver (reg_nlp, " R2N" , expected_status = :first_order , solver_kwargs = bpdn_kwargs)
66+ solver, stats = R2NSolver (reg_nlp), RegularizedExecutionStats (reg_nlp)
67+ @test @wrappedallocs (
68+ solve! (solver, reg_nlp, stats, σk = 1.0 , β = 1e16 , atol = 1e-6 , rtol = 1e-6 )
69+ ) == 0
70+
71+ test_solver (
72+ reg_nlp,
73+ " R2N" ,
74+ expected_status = :first_order ,
75+ solver_kwargs = bpdn_kwargs,
76+ solver_constructor_kwargs = (subsolver = R2DHSolver,),
77+ )
78+ solver, stats = R2NSolver (reg_nlp, subsolver = R2DHSolver), RegularizedExecutionStats (reg_nlp)
79+ @test @wrappedallocs (
80+ solve! (solver, reg_nlp, stats, σk = 1.0 , β = 1e16 , atol = 1e-6 , rtol = 1e-6 )
81+ ) == 0
82+ end
83+ end
0 commit comments