-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests fail on QuadraticModels with ADNLPModels 0.8 #255
Comments
I will add |
@gdalle any idea if this is supposed to work with SparseConnectivityTracer 0.6? |
The surface-level issue is that we're missing an overload for ```julia
julia> ADNLPModel(
s -> fx + dot(gx, s) + dot(s, Hx * s) / 2,
zeros(nlp.meta.nvar),
nlp.meta.lvar - x,
nlp.meta.uvar - x,
)
ERROR: TypeError: non-boolean (SparseConnectivityTracer.HessianTracer{SparseConnectivityTracer.IndexSetHessianPattern{Int64, BitSet, Set{Tuple{Int64, Int64}}, false}}) used in boolean context
Stacktrace:
[1] _mul!(nzrang::typeof(SparseArrays.nzrangelo), diagop::typeof(identity), odiagop::typeof(transpose), C::Vector{…}, A::SparseArrays.SparseMatrixCSC{…}, B::Vector{…}, α::SparseConnectivityTracer.HessianTracer{…}, β::SparseConnectivityTracer.HessianTracer{…})
@ SparseArrays ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/SparseArrays/src/linalg.jl:881
[2] spdensemul!(C::Vector{…}, tA::Char, tB::Char, A::SparseArrays.SparseMatrixCSC{…}, B::Vector{…}, _add::LinearAlgebra.MulAddMul{…})
@ SparseArrays ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/SparseArrays/src/linalg.jl:50
[3] generic_matvecmul!
@ ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/SparseArrays/src/linalg.jl:35 [inlined]
[4] mul!
@ ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/matmul.jl:66 [inlined]
[5] mul!
@ ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/matmul.jl:237 [inlined]
[6] *(A::Symmetric{Float64, SparseArrays.SparseMatrixCSC{…}}, x::Vector{SparseConnectivityTracer.HessianTracer{…}})
@ LinearAlgebra ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/matmul.jl:57
[7] (::var"#13#14")(s::Vector{SparseConnectivityTracer.HessianTracer{SparseConnectivityTracer.IndexSetHessianPattern{…}}})
@ Main ./REPL[7]:2
[8] (::ADNLPModels.var"#lagrangian#55"{…})(x::Vector{…})
@ ADNLPModels ~/.julia/packages/ADNLPModels/vcIV9/src/sparsity_pattern.jl:42
[9] trace_function(::Type{…}, f::ADNLPModels.var"#lagrangian#55"{…}, x::Vector{…})
@ SparseConnectivityTracer ~/Work/GitHub/Julia/SparseConnectivityTracer.jl/src/interface.jl:33
[10] _hessian_sparsity(f::Function, x::Vector{Float64}, ::Type{SparseConnectivityTracer.HessianTracer{…}})
@ SparseConnectivityTracer ~/Work/GitHub/Julia/SparseConnectivityTracer.jl/src/interface.jl:120
[11] hessian_sparsity
@ ~/Work/GitHub/Julia/SparseConnectivityTracer.jl/src/adtypes.jl:57 [inlined]
[12] compute_hessian_sparsity(f::var"#13#14", nvar::Int64, c!::ADNLPModels.var"#2#3", ncon::Int64; detector::SparseConnectivityTracer.TracerSparsityDetector{…})
@ ADNLPModels ~/.julia/packages/ADNLPModels/vcIV9/src/sparsity_pattern.jl:51
[13] ADNLPModels.SparseADHessian(nvar::Int64, f::Function, ncon::Int64, c!::ADNLPModels.var"#2#3"; x0::Vector{…}, coloring::SparseMatrixColorings.GreedyColoringAlgorithm{…}, detector::SparseConnectivityTracer.TracerSparsityDetector{…}, kwargs::@Kwargs{})
@ ADNLPModels ~/.julia/packages/ADNLPModels/vcIV9/src/sparse_hessian.jl:29
[14] macro expansion
@ ~/.julia/packages/ADNLPModels/vcIV9/src/ad.jl:90 [inlined]
[15] macro expansion
@ ./timing.jl:395 [inlined]
[16] ADNLPModels.ADModelBackend(nvar::Int64, f::var"#13#14"; backend::Symbol, matrix_free::Bool, show_time::Bool, gradient_backend::Type, hprod_backend::Type, hessian_backend::Type, kwargs::@Kwargs{…})
@ ADNLPModels ~/.julia/packages/ADNLPModels/vcIV9/src/ad.jl:86
[17] ADNLPModel(f::Function, x0::Vector{…}, lvar::Vector{…}, uvar::Vector{…}; name::String, minimize::Bool, kwargs::@Kwargs{})
@ ADNLPModels ~/.julia/packages/ADNLPModels/vcIV9/src/nlp.jl:146
[18] ADNLPModel(f::Function, x0::Vector{Float64}, lvar::Vector{Float64}, uvar::Vector{Float64})
@ ADNLPModels ~/.julia/packages/ADNLPModels/vcIV9/src/nlp.jl:133
[19] top-level scope
@ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types. Since this particular method of |
The immediate workaround is always the same, use |
This should probably be documented in ADNLPModels, similar to #283 |
Thanks @gdalle ! I will use TracerLocalSparsityDetector() as a workaround as it is for quadratic problems so the sparsity pattern won't change. |
@gdalle Is it faster to use TracerLocalSparsityDetector() than the default if we know the sparsity pattern won't change? |
It shouldn't be, precisely because the sparsity pattern doesn't change so you should get the same number of colors and so on. Detection might be a bit slower in local mode but it's probably negligible. |
Ok, just wanted to make sure. Depending on how frequent these issues will be, I am thinking about adding a kwarg to the ADNLPModel/ADNLSModel to mention this. |
and the error is
The text was updated successfully, but these errors were encountered: