From b4e88ab333927571cbfcc124a7ab2668e43526da Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Sat, 21 Dec 2024 21:40:28 +0100 Subject: [PATCH] Fix tests --- test/enzyme.jl | 39 +++++---- test/runtests.jl | 55 ++++++++----- test/sparse_hessian.jl | 158 ++++++++++++++++++------------------ test/sparse_hessian_nls.jl | 81 +++++++++--------- test/sparse_jacobian.jl | 108 ++++++++++++------------ test/sparse_jacobian_nls.jl | 94 ++++++++++----------- 6 files changed, 277 insertions(+), 258 deletions(-) diff --git a/test/enzyme.jl b/test/enzyme.jl index 1ed36669..f9cba09c 100644 --- a/test/enzyme.jl +++ b/test/enzyme.jl @@ -75,24 +75,35 @@ end test_autodiff_backend_error() +include("sparse_jacobian.jl") +include("sparse_jacobian_nls.jl") +include("sparse_hessian.jl") +include("sparse_hessian_nls.jl") + +list_sparse_jac_backend = ((ADNLPModels.SparseEnzymeADJacobian, Dict()),) + @testset "Sparse Jacobian" begin - list_sparse_jac_backend = ((ADNLPModels.SparseEnzymeADJacobian, Dict()),) - include("sparse_jacobian.jl") - include("sparse_jacobian_nls.jl") + for (backend, kw) in list_sparse_jac_backend + sparse_jacobian(backend, kw) + sparse_jacobian_nls(backend, kw) + end end +list_sparse_hess_backend = ( + ( ADNLPModels.SparseEnzymeADHessian, + Dict(:coloring_algorithm => GreedyColoringAlgorithm{:direct}()), + ), + ( + ADNLPModels.SparseEnzymeADHessian, + Dict(:coloring_algorithm => GreedyColoringAlgorithm{:substitution}()), + ), +) + @testset "Sparse Hessian" begin - list_sparse_hess_backend = ( - ( ADNLPModels.SparseEnzymeADHessian, - Dict(:coloring_algorithm => GreedyColoringAlgorithm{:direct}()), - ), - ( - ADNLPModels.SparseEnzymeADHessian, - Dict(:coloring_algorithm => GreedyColoringAlgorithm{:substitution}()), - ), - ) - include("sparse_hessian.jl") - include("sparse_hessian_nls.jl") + for (backend, kw) in list_sparse_hess_backend + sparse_hessian(backend, kw) + sparse_hessian_nls(backend, kw) + end end for problem in NLPModelsTest.nlp_problems ∪ ["GENROSE"] diff --git a/test/runtests.jl b/test/runtests.jl index 9704c9e9..da4bf09a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,32 +23,43 @@ end include("manual.jl") end +include("sparse_jacobian.jl") +include("sparse_jacobian_nls.jl") +include("sparse_hessian.jl") +include("sparse_hessian_nls.jl") + +list_sparse_jac_backend = ((ADNLPModels.SparseADJacobian, Dict()), + (ADNLPModels.ForwardDiffADJacobian, Dict())) + @testset "Sparse Jacobian" begin - list_sparse_jac_backend = ((ADNLPModels.SparseADJacobian, Dict()), - (ADNLPModels.ForwardDiffADJacobian, Dict())) - include("sparse_jacobian.jl") - include("sparse_jacobian_nls.jl") + for (backend, kw) in list_sparse_jac_backend + sparse_jacobian(backend, kw) + sparse_jacobian_nls(backend, kw) + end end +list_sparse_hess_backend = ( + (ADNLPModels.SparseADHessian, Dict(:coloring_algorithm => GreedyColoringAlgorithm{:direct}())), + ( + ADNLPModels.SparseADHessian, + Dict(:coloring_algorithm => GreedyColoringAlgorithm{:substitution}()), + ), + ( + ADNLPModels.SparseReverseADHessian, + Dict(:coloring_algorithm => GreedyColoringAlgorithm{:direct}()), + ), + ( + ADNLPModels.SparseReverseADHessian, + Dict(:coloring_algorithm => GreedyColoringAlgorithm{:substitution}()), + ), + (ADNLPModels.ForwardDiffADHessian, Dict()), +) + @testset "Sparse Hessian" begin - list_sparse_hess_backend = ( - (ADNLPModels.SparseADHessian, Dict(:coloring_algorithm => GreedyColoringAlgorithm{:direct}())), - ( - ADNLPModels.SparseADHessian, - Dict(:coloring_algorithm => GreedyColoringAlgorithm{:substitution}()), - ), - ( - ADNLPModels.SparseReverseADHessian, - Dict(:coloring_algorithm => GreedyColoringAlgorithm{:direct}()), - ), - ( - ADNLPModels.SparseReverseADHessian, - Dict(:coloring_algorithm => GreedyColoringAlgorithm{:substitution}()), - ), - (ADNLPModels.ForwardDiffADHessian, Dict()), - ) - include("sparse_hessian.jl") - include("sparse_hessian_nls.jl") + for (backend, kw) in list_sparse_hess_backend + sparse_hessian(backend, kw) + sparse_hessian_nls(backend, kw) + end end for problem in NLPModelsTest.nlp_problems ∪ ["GENROSE"] diff --git a/test/sparse_hessian.jl b/test/sparse_hessian.jl index 802553e1..77c0bf29 100644 --- a/test/sparse_hessian.jl +++ b/test/sparse_hessian.jl @@ -1,87 +1,87 @@ -@testset "Basic Hessian derivative with backend=$(backend) and T=$(T)" for T in (Float32, Float64), - (backend, kw) in list_sparse_hess_backend +function sparse_hessian(backend, kw) + @testset "Basic Hessian derivative with backend=$(backend) and T=$(T)" for T in (Float32, Float64), + c!(cx, x) = begin + cx[1] = x[1] - 1 + cx[2] = 10 * (x[2] - x[1]^2) + cx[3] = x[2] + 1 + cx + end + x0 = T[-1.2; 1.0] + nvar = 2 + ncon = 3 + nlp = ADNLPModel!( + x -> x[1] * x[2]^2 + x[1]^2 * x[2], + x0, + c!, + zeros(T, ncon), + zeros(T, ncon), + hessian_backend = backend; + kw..., + ) - c!(cx, x) = begin - cx[1] = x[1] - 1 - cx[2] = 10 * (x[2] - x[1]^2) - cx[3] = x[2] + 1 - cx - end - x0 = T[-1.2; 1.0] - nvar = 2 - ncon = 3 - nlp = ADNLPModel!( - x -> x[1] * x[2]^2 + x[1]^2 * x[2], - x0, - c!, - zeros(T, ncon), - zeros(T, ncon), - hessian_backend = backend; - kw..., - ) - - x = rand(T, 2) - y = rand(T, 3) - rows, cols = zeros(Int, nlp.meta.nnzh), zeros(Int, nlp.meta.nnzh) - vals = zeros(T, nlp.meta.nnzh) - hess_structure!(nlp, rows, cols) - hess_coord!(nlp, x, vals) - @test eltype(vals) == T - H = sparse(rows, cols, vals, nvar, nvar) - @test H == [2*x[2] 0; 2*(x[1] + x[2]) 2*x[1]] + x = rand(T, 2) + y = rand(T, 3) + rows, cols = zeros(Int, nlp.meta.nnzh), zeros(Int, nlp.meta.nnzh) + vals = zeros(T, nlp.meta.nnzh) + hess_structure!(nlp, rows, cols) + hess_coord!(nlp, x, vals) + @test eltype(vals) == T + H = sparse(rows, cols, vals, nvar, nvar) + @test H == [2*x[2] 0; 2*(x[1] + x[2]) 2*x[1]] - # Test also the implementation of the backends - b = nlp.adbackend.hessian_backend - obj_weight = 0.5 - @test nlp.meta.nnzh == ADNLPModels.get_nln_nnzh(b, nvar) - ADNLPModels.hess_structure!(b, nlp, rows, cols) - ADNLPModels.hess_coord!(b, nlp, x, obj_weight, vals) - @test eltype(vals) == T - H = sparse(rows, cols, vals, nvar, nvar) - @test H == [x[2] 0; x[1]+x[2] x[1]] - ADNLPModels.hess_coord!(b, nlp, x, y, obj_weight, vals) - @test eltype(vals) == T - H = sparse(rows, cols, vals, nvar, nvar) - @test H == [x[2] 0; x[1]+x[2] x[1]] + y[2] * [-20 0; 0 0] + # Test also the implementation of the backends + b = nlp.adbackend.hessian_backend + obj_weight = 0.5 + @test nlp.meta.nnzh == ADNLPModels.get_nln_nnzh(b, nvar) + ADNLPModels.hess_structure!(b, nlp, rows, cols) + ADNLPModels.hess_coord!(b, nlp, x, obj_weight, vals) + @test eltype(vals) == T + H = sparse(rows, cols, vals, nvar, nvar) + @test H == [x[2] 0; x[1]+x[2] x[1]] + ADNLPModels.hess_coord!(b, nlp, x, y, obj_weight, vals) + @test eltype(vals) == T + H = sparse(rows, cols, vals, nvar, nvar) + @test H == [x[2] 0; x[1]+x[2] x[1]] + y[2] * [-20 0; 0 0] - if backend != ADNLPModels.ForwardDiffADHessian - H_sp = get_sparsity_pattern(nlp, :hessian) - @test H_sp == SparseMatrixCSC{Bool, Int}([ - 1 0 - 1 1 - ]) - end + if backend != ADNLPModels.ForwardDiffADHessian + H_sp = get_sparsity_pattern(nlp, :hessian) + @test H_sp == SparseMatrixCSC{Bool, Int}([ + 1 0 + 1 1 + ]) + end - nlp = ADNLPModel!( - x -> x[1] * x[2]^2 + x[1]^2 * x[2], - x0, - c!, - zeros(T, ncon), - zeros(T, ncon), - matrix_free = true; - kw..., - ) - @test nlp.adbackend.hessian_backend isa ADNLPModels.EmptyADbackend + nlp = ADNLPModel!( + x -> x[1] * x[2]^2 + x[1]^2 * x[2], + x0, + c!, + zeros(T, ncon), + zeros(T, ncon), + matrix_free = true; + kw..., + ) + @test nlp.adbackend.hessian_backend isa ADNLPModels.EmptyADbackend - n = 4 - x = ones(T, 4) - nlp = ADNLPModel( - x -> sum(100 * (x[i + 1] - x[i]^2)^2 + (x[i] - 1)^2 for i = 1:(n - 1)), - x, - hessian_backend = backend, - name = "Extended Rosenbrock", - ) - @test hess(nlp, x) == T[802 -400 0 0; -400 1002 -400 0; 0 -400 1002 -400; 0 0 -400 200] + n = 4 + x = ones(T, 4) + nlp = ADNLPModel( + x -> sum(100 * (x[i + 1] - x[i]^2)^2 + (x[i] - 1)^2 for i = 1:(n - 1)), + x, + hessian_backend = backend, + name = "Extended Rosenbrock", + ) + @test hess(nlp, x) == T[802 -400 0 0; -400 1002 -400 0; 0 -400 1002 -400; 0 0 -400 200] - x = ones(T, 2) - nlp = ADNLPModel(x -> x[1]^2 + x[1] * x[2], x, hessian_backend = backend) - @test hess(nlp, x) == T[2 1; 1 0] + x = ones(T, 2) + nlp = ADNLPModel(x -> x[1]^2 + x[1] * x[2], x, hessian_backend = backend) + @test hess(nlp, x) == T[2 1; 1 0] - nlp = ADNLPModel( - x -> sum(100 * (x[i + 1] - x[i]^2)^2 + (x[i] - 1)^2 for i = 1:(n - 1)), - x, - name = "Extended Rosenbrock", - matrix_free = true, - ) - @test nlp.adbackend.hessian_backend isa ADNLPModels.EmptyADbackend + nlp = ADNLPModel( + x -> sum(100 * (x[i + 1] - x[i]^2)^2 + (x[i] - 1)^2 for i = 1:(n - 1)), + x, + name = "Extended Rosenbrock", + matrix_free = true, + ) + @test nlp.adbackend.hessian_backend isa ADNLPModels.EmptyADbackend + end end diff --git a/test/sparse_hessian_nls.jl b/test/sparse_hessian_nls.jl index 066cf949..6a02b6ae 100644 --- a/test/sparse_hessian_nls.jl +++ b/test/sparse_hessian_nls.jl @@ -1,48 +1,45 @@ -if test_enzyme - list_sparse_hess_backend = ( - ( ADNLPModels.SparseEnzymeADHessian, -@testset "Basic Hessian of residual derivative with backend=$(backend) and T=$(T)" for T in (Float32, Float64), - (backend, kw) in list_sparse_hess_backend +function sparse_hessian_nls(backend, kw) + @testset "Basic Hessian of residual derivative with backend=$(backend) and T=$(T)" for T in (Float32, Float64), + F!(Fx, x) = begin + Fx[1] = x[1] - 1 + Fx[2] = 10 * (x[2] - x[1]^2) + Fx[3] = x[2] + 1 + Fx + end + x0 = T[-1.2; 1.0] + nvar = 2 + nequ = 3 + nls = ADNLPModels.ADNLSModel!(F!, x0, 3, hessian_residual_backend = backend; kw...) - F!(Fx, x) = begin - Fx[1] = x[1] - 1 - Fx[2] = 10 * (x[2] - x[1]^2) - Fx[3] = x[2] + 1 - Fx - end - x0 = T[-1.2; 1.0] - nvar = 2 - nequ = 3 - nls = ADNLPModels.ADNLSModel!(F!, x0, 3, hessian_residual_backend = backend; kw...) + x = rand(T, nvar) + v = rand(T, nequ) + rows, cols = zeros(Int, nls.nls_meta.nnzh), zeros(Int, nls.nls_meta.nnzh) + vals = zeros(T, nls.nls_meta.nnzh) + hess_structure_residual!(nls, rows, cols) + hess_coord_residual!(nls, x, v, vals) + @test eltype(vals) == T + H = Symmetric(sparse(rows, cols, vals, nvar, nvar), :L) + @test H == [-20*v[2] 0; 0 0] - x = rand(T, nvar) - v = rand(T, nequ) - rows, cols = zeros(Int, nls.nls_meta.nnzh), zeros(Int, nls.nls_meta.nnzh) - vals = zeros(T, nls.nls_meta.nnzh) - hess_structure_residual!(nls, rows, cols) - hess_coord_residual!(nls, x, v, vals) - @test eltype(vals) == T - H = Symmetric(sparse(rows, cols, vals, nvar, nvar), :L) - @test H == [-20*v[2] 0; 0 0] + # Test also the implementation of the backends + b = nls.adbackend.hessian_residual_backend + @test nls.nls_meta.nnzh == ADNLPModels.get_nln_nnzh(b, nvar) + ADNLPModels.hess_structure_residual!(b, nls, rows, cols) + ADNLPModels.hess_coord_residual!(b, nls, x, v, vals) + @test eltype(vals) == T + H = Symmetric(sparse(rows, cols, vals, nvar, nvar), :L) + @test H == [-20*v[2] 0; 0 0] - # Test also the implementation of the backends - b = nls.adbackend.hessian_residual_backend - @test nls.nls_meta.nnzh == ADNLPModels.get_nln_nnzh(b, nvar) - ADNLPModels.hess_structure_residual!(b, nls, rows, cols) - ADNLPModels.hess_coord_residual!(b, nls, x, v, vals) - @test eltype(vals) == T - H = Symmetric(sparse(rows, cols, vals, nvar, nvar), :L) - @test H == [-20*v[2] 0; 0 0] + if backend != ADNLPModels.ForwardDiffADHessian + H_sp = get_sparsity_pattern(nls, :hessian_residual) + @test H_sp == SparseMatrixCSC{Bool, Int}([ + 1 0 + 0 0 + ]) + end - if backend != ADNLPModels.ForwardDiffADHessian - H_sp = get_sparsity_pattern(nls, :hessian_residual) - @test H_sp == SparseMatrixCSC{Bool, Int}([ - 1 0 - 0 0 - ]) + nls = ADNLPModels.ADNLSModel!(F!, x0, 3, matrix_free = true; kw...) + @test nls.adbackend.hessian_backend isa ADNLPModels.EmptyADbackend + @test nls.adbackend.hessian_residual_backend isa ADNLPModels.EmptyADbackend end - - nls = ADNLPModels.ADNLSModel!(F!, x0, 3, matrix_free = true; kw...) - @test nls.adbackend.hessian_backend isa ADNLPModels.EmptyADbackend - @test nls.adbackend.hessian_residual_backend isa ADNLPModels.EmptyADbackend end diff --git a/test/sparse_jacobian.jl b/test/sparse_jacobian.jl index dd24e5c8..4c0801eb 100644 --- a/test/sparse_jacobian.jl +++ b/test/sparse_jacobian.jl @@ -1,60 +1,60 @@ -@testset "Basic Jacobian derivative with backend=$(backend) and T=$(T)" for T in (Float32, Float64), - (backend, kw) in list_sparse_jac_backend +function sparse_jacobian(backend, kw) + @testset "Basic Jacobian derivative with backend=$(backend) and T=$(T)" for T in (Float32, Float64) + c!(cx, x) = begin + cx[1] = x[1] - 1 + cx[2] = 10 * (x[2] - x[1]^2) + cx[3] = x[2] + 1 + cx + end + x0 = T[-1.2; 1.0] + nvar = 2 + ncon = 3 + nlp = ADNLPModel!( + x -> sum(x), + x0, + c!, + zeros(T, ncon), + zeros(T, ncon), + jacobian_backend = backend; + kw..., + ) - c!(cx, x) = begin - cx[1] = x[1] - 1 - cx[2] = 10 * (x[2] - x[1]^2) - cx[3] = x[2] + 1 - cx - end - x0 = T[-1.2; 1.0] - nvar = 2 - ncon = 3 - nlp = ADNLPModel!( - x -> sum(x), - x0, - c!, - zeros(T, ncon), - zeros(T, ncon), - jacobian_backend = backend; - kw..., - ) - - x = rand(T, 2) - rows, cols = zeros(Int, nlp.meta.nln_nnzj), zeros(Int, nlp.meta.nln_nnzj) - vals = zeros(T, nlp.meta.nln_nnzj) - jac_nln_structure!(nlp, rows, cols) - jac_nln_coord!(nlp, x, vals) - @test eltype(vals) == T - J = sparse(rows, cols, vals, ncon, nvar) - @test J == [ - 1 0 - -20*x[1] 10 - 0 1 - ] - - # Test also the implementation of the backends - b = nlp.adbackend.jacobian_backend - @test nlp.meta.nnzj == ADNLPModels.get_nln_nnzj(b, nvar, ncon) - ADNLPModels.jac_structure!(b, nlp, rows, cols) - ADNLPModels.jac_coord!(b, nlp, x, vals) - @test eltype(vals) == T - J = sparse(rows, cols, vals, ncon, nvar) - @test J == [ - 1 0 - -20*x[1] 10 - 0 1 - ] + x = rand(T, 2) + rows, cols = zeros(Int, nlp.meta.nln_nnzj), zeros(Int, nlp.meta.nln_nnzj) + vals = zeros(T, nlp.meta.nln_nnzj) + jac_nln_structure!(nlp, rows, cols) + jac_nln_coord!(nlp, x, vals) + @test eltype(vals) == T + J = sparse(rows, cols, vals, ncon, nvar) + @test J == [ + 1 0 + -20*x[1] 10 + 0 1 + ] - if backend != ADNLPModels.ForwardDiffADJacobian - J_sp = get_sparsity_pattern(nlp, :jacobian) - @test J_sp == SparseMatrixCSC{Bool, Int}([ + # Test also the implementation of the backends + b = nlp.adbackend.jacobian_backend + @test nlp.meta.nnzj == ADNLPModels.get_nln_nnzj(b, nvar, ncon) + ADNLPModels.jac_structure!(b, nlp, rows, cols) + ADNLPModels.jac_coord!(b, nlp, x, vals) + @test eltype(vals) == T + J = sparse(rows, cols, vals, ncon, nvar) + @test J == [ 1 0 - 1 1 + -20*x[1] 10 0 1 - ]) - end + ] - nlp = ADNLPModel!(x -> sum(x), x0, c!, zeros(T, ncon), zeros(T, ncon), matrix_free = true; kw...) - @test nlp.adbackend.jacobian_backend isa ADNLPModels.EmptyADbackend + if backend != ADNLPModels.ForwardDiffADJacobian + J_sp = get_sparsity_pattern(nlp, :jacobian) + @test J_sp == SparseMatrixCSC{Bool, Int}([ + 1 0 + 1 1 + 0 1 + ]) + end + + nlp = ADNLPModel!(x -> sum(x), x0, c!, zeros(T, ncon), zeros(T, ncon), matrix_free = true; kw...) + @test nlp.adbackend.jacobian_backend isa ADNLPModels.EmptyADbackend + end end diff --git a/test/sparse_jacobian_nls.jl b/test/sparse_jacobian_nls.jl index f8249b86..fc6f8e98 100644 --- a/test/sparse_jacobian_nls.jl +++ b/test/sparse_jacobian_nls.jl @@ -1,53 +1,53 @@ -@testset "Basic Jacobian of residual derivative with backend=$(backend) and T=$(T)" for T in (Float32, Float64), - (backend, kw) in list_sparse_jac_backend +function sparse_jacobian_nls(backend, kw) + @testset "Basic Jacobian of residual derivative with backend=$(backend) and T=$(T)" for T in (Float32, Float64) + F!(Fx, x) = begin + Fx[1] = x[1] - 1 + Fx[2] = 10 * (x[2] - x[1]^2) + Fx[3] = x[2] + 1 + Fx + end + x0 = T[-1.2; 1.0] + nvar = 2 + nequ = 3 + nls = ADNLPModels.ADNLSModel!(F!, x0, 3, jacobian_residual_backend = backend; kw...) - F!(Fx, x) = begin - Fx[1] = x[1] - 1 - Fx[2] = 10 * (x[2] - x[1]^2) - Fx[3] = x[2] + 1 - Fx - end - x0 = T[-1.2; 1.0] - nvar = 2 - nequ = 3 - nls = ADNLPModels.ADNLSModel!(F!, x0, 3, jacobian_residual_backend = backend; kw...) - - x = rand(T, 2) - rows, cols = zeros(Int, nls.nls_meta.nnzj), zeros(Int, nls.nls_meta.nnzj) - vals = zeros(T, nls.nls_meta.nnzj) - jac_structure_residual!(nls, rows, cols) - jac_coord_residual!(nls, x, vals) - @test eltype(vals) == T - J = sparse(rows, cols, vals, nequ, nvar) - @test J == [ - 1 0 - -20*x[1] 10 - 0 1 - ] - - # Test also the implementation of the backends - b = nls.adbackend.jacobian_residual_backend - @test nls.nls_meta.nnzj == ADNLPModels.get_nln_nnzj(b, nvar, nequ) - ADNLPModels.jac_structure_residual!(b, nls, rows, cols) - ADNLPModels.jac_coord_residual!(b, nls, x, vals) - @test eltype(vals) == T - J = sparse(rows, cols, vals, nequ, nvar) - @test J == [ - 1 0 - -20*x[1] 10 - 0 1 - ] + x = rand(T, 2) + rows, cols = zeros(Int, nls.nls_meta.nnzj), zeros(Int, nls.nls_meta.nnzj) + vals = zeros(T, nls.nls_meta.nnzj) + jac_structure_residual!(nls, rows, cols) + jac_coord_residual!(nls, x, vals) + @test eltype(vals) == T + J = sparse(rows, cols, vals, nequ, nvar) + @test J == [ + 1 0 + -20*x[1] 10 + 0 1 + ] - if backend != ADNLPModels.ForwardDiffADJacobian - J_sp = get_sparsity_pattern(nls, :jacobian_residual) - @test J_sp == SparseMatrixCSC{Bool, Int}([ + # Test also the implementation of the backends + b = nls.adbackend.jacobian_residual_backend + @test nls.nls_meta.nnzj == ADNLPModels.get_nln_nnzj(b, nvar, nequ) + ADNLPModels.jac_structure_residual!(b, nls, rows, cols) + ADNLPModels.jac_coord_residual!(b, nls, x, vals) + @test eltype(vals) == T + J = sparse(rows, cols, vals, nequ, nvar) + @test J == [ 1 0 - 1 1 + -20*x[1] 10 0 1 - ]) - end + ] - nls = ADNLPModels.ADNLSModel!(F!, x0, 3, matrix_free = true; kw...) - @test nls.adbackend.jacobian_backend isa ADNLPModels.EmptyADbackend - @test nls.adbackend.jacobian_residual_backend isa ADNLPModels.EmptyADbackend + if backend != ADNLPModels.ForwardDiffADJacobian + J_sp = get_sparsity_pattern(nls, :jacobian_residual) + @test J_sp == SparseMatrixCSC{Bool, Int}([ + 1 0 + 1 1 + 0 1 + ]) + end + + nls = ADNLPModels.ADNLSModel!(F!, x0, 3, matrix_free = true; kw...) + @test nls.adbackend.jacobian_backend isa ADNLPModels.EmptyADbackend + @test nls.adbackend.jacobian_residual_backend isa ADNLPModels.EmptyADbackend + end end