diff --git a/Project.toml b/Project.toml index 0d680594..9bf9cd24 100644 --- a/Project.toml +++ b/Project.toml @@ -84,10 +84,10 @@ Interpolations = "0.15" JSON3 = "1" KernelDensityEstimate = "0.5.6" LinearAlgebra = "1.10" -ManifoldDiff = "0.3" +ManifoldDiff = "0.3, 0.4" Manifolds = "0.10" ManifoldsBase = "0.15" -Manopt = "0.4.40, 0.5" +Manopt = "^0.5.3" MetaGraphs = "0.7, 0.8" Optim = "1" OrderedCollections = "1" diff --git a/src/parametric/services/ParametricOptim.jl b/src/parametric/services/ParametricOptim.jl index b203c084..17033fd8 100644 --- a/src/parametric/services/ParametricOptim.jl +++ b/src/parametric/services/ParametricOptim.jl @@ -8,7 +8,11 @@ function optimizeManifold_FD( ) # finitediff setup r_backend = ManifoldDiff.TangentDiffBackend( - ManifoldDiff.FiniteDifferencesBackend() + if v"0.4" <= pkgversion(ManifoldDiff) + ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1)) + else + ManifoldDiff.FiniteDifferencesBackend() + end ) ## finitediff gradient (non-manual) diff --git a/src/services/FactorGradients.jl b/src/services/FactorGradients.jl index 6bee605d..f8e67f54 100644 --- a/src/services/FactorGradients.jl +++ b/src/services/FactorGradients.jl @@ -6,7 +6,13 @@ function factorJacobian( fg, faclabel::Symbol, p0 = ArrayPartition(first.(getVal.(fg, getVariableOrder(fg, faclabel), solveKey = :parametric))...), - backend = ManifoldDiff.TangentDiffBackend(ManifoldDiff.FiniteDiffBackend()), + backend = ManifoldDiff.TangentDiffBackend( + if v"0.4" <= pkgversion(ManifoldDiff) + ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1)) + else + ManifoldDiff.FiniteDifferencesBackend() + end + ) ) fac = getFactor(fg, faclabel) diff --git a/test/manifolds/factordiff.jl b/test/manifolds/factordiff.jl index a870559c..d1df6118 100644 --- a/test/manifolds/factordiff.jl +++ b/test/manifolds/factordiff.jl @@ -97,11 +97,15 @@ function resid_SE2(X, p, q) end +# finitediff setup # finitediff setup r_backend = ManifoldDiff.TangentDiffBackend( - ManifoldDiff.FiniteDifferencesBackend() + if v"0.4" <= pkgversion(ManifoldDiff) + ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1)) + else + ManifoldDiff.FiniteDifferencesBackend() + end ) - Me = Euclidean(3) function _factorJac!(J, z, p1, p2) @@ -123,9 +127,15 @@ J_ = _factorJac!(J, z, p1, p2) # @profview _factorJac!(J, z, p1, p2) if false + # finitediff setup z_backend = ManifoldDiff.TangentDiffBackend( - ManifoldDiff.ZygoteDiffBackend() + if v"0.4" <= pkgversion(ManifoldDiff) + ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1)) + else + ManifoldDiff.FiniteDifferencesBackend() + end ) + g = ManifoldDiff.jacobian(M, Euclidean(3), f_SE2_x0, p1, z_backend) else @info "ManifoldDiff.ZygoteDiffBackend usage still under development (23Q3)" diff --git a/test/manifolds/manifolddiff.jl b/test/manifolds/manifolddiff.jl index 71b0035e..2e6e0591 100644 --- a/test/manifolds/manifolddiff.jl +++ b/test/manifolds/manifolddiff.jl @@ -13,7 +13,11 @@ import Rotations as _Rot # finitediff setup r_backend = ManifoldDiff.TangentDiffBackend( + if v"0.4" <= pkgversion(ManifoldDiff) + ManifoldDiff.AutoFiniteDifferences(central_fdm(5, 1)) + else ManifoldDiff.FiniteDifferencesBackend() + end ) ##