@@ -3,12 +3,10 @@ using BenchmarkTools
33using LinearAlgebra
44using NLPModels
55
6- # Test with an unconstrained problem first
76println (" Testing with unconstrained problem (ROSENBR):" )
87nlp1 = CUTEstModel {Float64} (" ROSENBR" )
98x0 = nlp1. meta. x0
109
11- # Test hess_coord allocations
1210println (" ✓ Problem loaded: $(nlp1. meta. name) ($(nlp1. meta. nvar) vars, $(nlp1. meta. ncon) cons)" )
1311vals_h = Vector {Float64} (undef, nlp1. meta. nnzh)
1412hess_coord! (nlp1, x0, vals_h)
@@ -18,36 +16,30 @@ println("✓ hess_coord!: $(b_hess.allocs) allocations, $(BenchmarkTools.prettyt
1816
1917finalize (nlp1)
2018
21- # Test with a constrained problem
2219println (" \n Testing with constrained problem (HS6):" )
2320nlp2 = CUTEstModel {Float64} (" HS6" )
2421x0 = nlp2. meta. x0
2522
2623println (" ✓ Problem loaded: $(nlp2. meta. name) ($(nlp2. meta. nvar) vars, $(nlp2. meta. ncon) cons)" )
2724println (" nnzj: $(nlp2. meta. nnzj) , nnzh: $(nlp2. meta. nnzh) " )
2825
29- # Test basic functionality
3026f = obj (nlp2, x0)
3127g = similar (x0)
3228grad! (nlp2, x0, g)
3329println (" ✓ obj/grad: f = $(round (f, digits= 6 )) , ||g|| = $(round (norm (g), digits= 6 )) " )
3430
35- # Test constraint functions
3631c = Vector {Float64} (undef, nlp2. meta. ncon)
3732cons! (nlp2, x0, c)
3833println (" ✓ constraints: ||c|| = $(round (norm (c), digits= 6 )) " )
3934
40- # Test cons_coord - this should show major allocation improvements
4135println (" \n Testing cons_coord allocation improvements:" )
4236c1, rows1, cols1, vals1 = cons_coord (nlp2, x0)
4337
44- # Benchmark cons_coord
4538b_cons = @benchmark cons_coord ($ nlp2, $ x0) samples= 100 evals= 5
4639println (" ✓ cons_coord: $(b_cons. allocs) allocations, $(BenchmarkTools. prettytime (median (b_cons). time)) " )
4740println (" Memory: $(BenchmarkTools. prettymemory (median (b_cons). memory)) " )
4841println (" Returned $(length (vals1)) Jacobian elements" )
4942
50- # Test cons_coord!
5143rows = Vector {Cint} (undef, nlp2. meta. nnzj)
5244cols = Vector {Cint} (undef, nlp2. meta. nnzj)
5345vals = Vector {Float64} (undef, nlp2. meta. nnzj)
@@ -56,7 +48,6 @@ c_out = Vector{Float64}(undef, nlp2.meta.ncon)
5648b_cons_inplace = @benchmark cons_coord! ($ nlp2, $ x0, $ c_out, $ rows, $ cols, $ vals) samples= 100 evals= 5
5749println (" ✓ cons_coord!: $(b_cons_inplace. allocs) allocations, $(BenchmarkTools. prettytime (median (b_cons_inplace). time)) " )
5850
59- # Test type conversion
6051println (" \n Testing type conversion improvements:" )
6152x0_f32 = Float32 .(x0)
6253g_f32 = Vector {Float32} (undef, nlp2. meta. nvar)
@@ -65,7 +56,6 @@ b_grad_conv = @benchmark grad!($nlp2, $x0_f32, $g_f32) samples=100 evals=5
6556println (" ✓ grad! with Float32->Float64 conversion: $(b_grad_conv. allocs) allocations" )
6657println (" Time: $(BenchmarkTools. prettytime (median (b_grad_conv). time)) " )
6758
68- # Test hess_coord with constraints
6959vals_h2 = Vector {Float64} (undef, nlp2. meta. nnzh)
7060y = zeros (nlp2. meta. ncon)
7161hess_coord! (nlp2, x0, y, vals_h2)
0 commit comments