-
Notifications
You must be signed in to change notification settings - Fork 28
Labels
backendRelated to one or more autodiff backendsRelated to one or more autodiff backends
Description
We cannot pre-allocate sparse Jacobians with AutoSymbolics in AutoSparse since sparsity_pattern is not defined. Here is a MWE:
using DifferentiationInterface, SparseConnectivityTracer, SparseMatrixColorings
import Symbolics
x = float.(1:8)
y = Vector{eltype(x)}(undef, length(x)-1)
function f!(y, x)
for i in eachindex(y)
y[i] = (x[i+1]^2-x[i]^2)
end
for i in eachindex(y)
j = length(x) - i
y[i] += (x[j]^2-x[j+1]^2)
end
return y
end
backend = AutoSparse(
AutoSymbolics();
sparsity_detector=TracerSparsityDetector(),
coloring_algorithm=GreedyColoringAlgorithm(),
)
prep = prepare_jacobian(f!, y, backend, x; strict=Val(true))
J = similar(sparsity_pattern(prep), eltype(x))giving:
ERROR: MethodError: no method matching sparsity_pattern(::DifferentiationInterfaceSymbolicsExt.SymbolicsTwoArgJacobianPrep{…})
The function `sparsity_pattern` exists, but no method is defined for this combination of argument types.
Closest candidates are:
sparsity_pattern(::DifferentiationInterfaceSparseMatrixColoringsExt.SparseJacobianPrep)
@ DifferentiationInterfaceSparseMatrixColoringsExt ~/.julia/packages/DifferentiationInterface/Av6Jb/ext/DifferentiationInterfaceSparseMatrixColoringsExt/DifferentiationInterfaceSparseMatrixColoringsExt.jl:20
sparsity_pattern(::DifferentiationInterfaceSparseMatrixColoringsExt.SparseHessianPrep)
@ DifferentiationInterfaceSparseMatrixColoringsExt ~/.julia/packages/DifferentiationInterface/Av6Jb/ext/DifferentiationInterfaceSparseMatrixColoringsExt/hessian.jl:21
sparsity_pattern(::AbstractColoringResult)
@ SparseMatrixColorings ~/.julia/packages/SparseMatrixColorings/BED6Y/src/result.jl:127
Stacktrace:
[1] top-level scope
@ ~/Dropbox/Programmation/Julia/TestMPC/src/di.jl:22
Some type information was truncated. Use `show(err)` to see complete types.Thanks for all the good work!
Metadata
Metadata
Assignees
Labels
backendRelated to one or more autodiff backendsRelated to one or more autodiff backends