-
Notifications
You must be signed in to change notification settings - Fork 56
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
Power Manifolds usage and bugs #497
Comments
Hm, in my mind neither Power manifolds are far more homogeneous in the sense that on
is three columns of points on the manifold and My disadvantage in this is for images of matrix-valued data (4D arrays) this is a little clumsy (though I only worked with this in Matlab and it was my main reason to switch) bith nested ones are similar but the same point as above would look like
Again of course so here we have an array (of length 3, since we have length 3 of power manifold) where each entry is an array itself of a point on S2. So it is nested arrays. The replacing one is just a variant of this handling the internal arrays in the nested setting differently (for technical reasons that is sometimes nicer).
A power manifold does not have a group structure per se, so that again depends heavily on what you use as
Similar to 3, we first need an identity on a power manifold (given that it is a group, for example by element wise group action which would be the default) then the identity would exist automatically and the log would work element wise (on the identities as well, sure) PS: I wouldn't‘t say that the general Manifolds interface is that much under development anymore, the new (0.13.0 ManifoldsBase) one is quite robust and nice I hope. What is not yet covered that much (because we do not have many people using it) is the Lie group part, especially when its about the interplay between product, power, metric and Lie. This is also quite tricky as quite some discussions show, since there is usually not one single way to decide for a certain default. |
Sorry, I should have been clearer. I'm currently only testing with Points (TranslationGroup) and Poses (SE) The problem can have a lot of points and Poses. So I figured I'd start with M1 = PowerManifold(TranslationGroup(N), NestedReplacingPowerRepresentation(), number_of_points_on_1)
M2 = PowerManifold(SpecialEuclidean(N), NestedReplacingPowerRepresentation(), number_of_points_on_2)
M = ProductManifold(M1, M2) Then points on M can be |
I think that is what I'm after, thanks |
Ah this is quite a complicated structure then, sure, the first is just an array of arrays, since translation group is just Rn, the second is an array of ProductRepr? And those two should be part of a ProductRepr then. The main problem here (again) is that the power manifold does not “look into” its (element) manifold to inherit its poperties (in principle it could, since 0.13.0 automatically become a PowerLieGroup for example, but for now it does not). The thing here is that for any of these interplays (of power with something or Product with something - like metric, like Lie like any other decorated feature) this is only doable in a reasonable way since 0.13.0 and I was happy to finish that in general, so these interplays are a next step.
To me this is not so clear but if this is clear, we can surely provide that One general remark why I said ProductRepr is the wrong thing on Power manifolds: I now know what confused me. Here
It looked like p1 and p2 where points on M, but it was a long day and you actually do |
Yes, we definitely need more documentation about which types of power manifold are suitable for which cases. "ArrayPartition SA NestedReplacingPowerRepresentation" should work fine in this case, I will look into why it fails. Ronny has explained quite nicely how it works, and I also think that the interface works well here and the issues are that not everything is implemented and documented, and such complex interactions between power, product and Lie need to be ironed out -- but that definitely looks doable to me. I will look into implementing some missing things tomorrow. |
#113) * Fix power manifold options 1 and 2 from JuliaManifolds/Manifolds.jl#497 * remove unnecessary code
#498 and JuliaManifolds/ManifoldsBase.jl#113 should make all these options working. |
Thanks a lot. We will work towards 'ArrayPartition SA NestedReplacingPowerRepresentation' and I'll open separate issues as they come up. |
You're welcome 🙂 . Your reports are really helpful (they tell me which parts need improvements) and I appreciate that you are willing to deal with these issues. |
An update:
|
|
Thank you very much. I already experimented with it a bit and it seemed to be easy to use. I upgraded to do a solve without errors. Also, it was a bit faster, thanks! I made my own I overload a function from function DFG.getPointIdentity(G::ProductGroup, ::Type{T}=Float64) where T
M = G.manifold
return ArrayPartition(map(x->getPointIdentity(x, T), M.manifolds))
end
function DFG.getPointIdentity(G::SpecialOrthogonal{N}, ::Type{T}=Float64) where {N,T}
return SMatrix{N,N, T}(I)
end Note: I don't mind adding our defaults with a fallback to |
Great, that was the idea 🙂 .
That's a good idea, I will add variants of |
To make ArrayPartition work a bit more nicely we also need this: SciML/RecursiveArrayTools.jl#219 . |
This is an updated test script that uses the new power group and manifold-specific allocation: using Manifolds
using RecursiveArrayTools: ArrayPartition
using StaticArrays
using Test
using PreallocationTools
G = SpecialEuclidean(2)
# the different options
options = []
#ProductRepr
o = (name = "ProductRepr NestedPowerRepresentation",
p1 = ProductRepr([0.0,0.0], [1.0 0.0; 0.0 1.0]),
p2 = ProductRepr([0.0,0.0], [0.0 -1.0; 1.0 0.0]),
M = PowerManifold(G, NestedPowerRepresentation(), 2));
push!(options, o);
#ArrayPartition
o = (name = "ArrayPartition NestedPowerRepresentation",
p1 = ArrayPartition([0.0,0.0], [1.0 0.0; 0.0 1.0]),
p2 = ArrayPartition([0.0,0.0], [0.0 -1.0; 1.0 0.0]),
M = PowerManifold(G, NestedPowerRepresentation(), 2));
push!(options, o);
#ProductRepr with NestedReplacingPowerRepresentation
o = (name = "ProductRepr NestedReplacingPowerRepresentation",
p1 = ProductRepr([0.0,0.0], [1.0 0.0; 0.0 1.0]),
p2 = ProductRepr([0.0,0.0], [0.0 -1.0; 1.0 0.0]),
M = PowerManifold(G, NestedReplacingPowerRepresentation(), 2));
push!(options, o);
o = (name = "ProductRepr SA NestedReplacingPowerRepresentation",
p1 = ProductRepr(SA[0.0,0.0], SA[1.0 0.0; 0.0 1.0]),
p2 = ProductRepr(SA[0.0,0.0], SA[0.0 -1.0; 1.0 0.0]),
M = PowerManifold(G, NestedReplacingPowerRepresentation(), 2));
push!(options, o);
#ArrayPartition
o = (name = "ArrayPartition NestedReplacingPowerRepresentation",
p1 = ArrayPartition([0.0,0.0], [1.0 0.0; 0.0 1.0]),
p2 = ArrayPartition([0.0,0.0], [0.0 -1.0; 1.0 0.0]),
M = PowerManifold(G, NestedReplacingPowerRepresentation(), 2));
push!(options, o);
o = (name = "ArrayPartition SA NestedReplacingPowerRepresentation",
p1 = ArrayPartition(SA[0.0,0.0], SA[1.0 0.0; 0.0 1.0]),
p2 = ArrayPartition(SA[0.0,0.0], SA[0.0 -1.0; 1.0 0.0]),
M = PowerManifold(G, NestedReplacingPowerRepresentation(), 2));
push!(options, o);
#ArrayPartition
o = (name = "Vector NestedReplacingPowerRepresentation",
p1 = [0.0,0.0],
p2 = [1.0,1.0],
M = PowerManifold(TranslationGroup(2), NestedReplacingPowerRepresentation(), 2));
push!(options, o);
o = (name = "SVector NestedReplacingPowerRepresentation",
p1 = SA[0.0,0.0],
p2 = SA[1.0,1.0],
M = PowerManifold(TranslationGroup(2), NestedReplacingPowerRepresentation(), 2));
push!(options, o);
## Try to find one that fully Works
for (i,o) in enumerate(options)
@info "option $i: $(o.name)"
try
p = [o.p1,o.p1]
q = [o.p1,o.p2]
M = o.M
log(M, p, q)
X = allocate(M, p)
log!(M, X, p, q)
X = [allocate(M, o.p1),allocate(M, o.p1)]
log!(M, X, p, q)
exp(M, p, X)
exp!(M, q, p, X)
Xc = get_coordinates(M, p, X, DefaultBasis())
get_coordinates!(M, Xc, p, X, DefaultBasis())
get_vector(M, p, Xc, DefaultBasis())
get_vector!(M, X, p, Xc, DefaultBasis())
MG = PowerGroup(M)
identity_element(MG)
Xc2 = vee(MG, p, X)
hat(MG, p, Xc2)
# @info "Success of Manifols functions, checking dualcache"
# dualcache(X)
@info "Success"
println()
catch ex
@error ex
println()
end
end Note the use of So the last remaining point here is |
Thanks, it looks to be working well now and |
It looks like |
For log and exp there are |
|
ah, sure, forgot about that; do you want to use |
So I think the current master (soon to be tagged as 0.8.19) has everything listed in this issue implemented 🙂 . |
When you register that, keep in mind that some not-so-clever person accidentally increased vision number twice, so the PR for 0.8.19 exists in JuliaRegistry and might be used (again), so it might not automatically merge (I am not sure). |
Thank you very much! |
Hello,
As Mateusz sugested in #495 (comment)
I experimented with using power manifolds to represent points for optimization.
From the documentation, I figured the
NestedReplacingPowerRepresentation
with anArrayPartition
of<:StaticArrays
looked the most promising. So I tried it and ran into errors, so I triedNestedPowerRepresentation
withArrayPartition
and again errors.I completely understand Manifolds.jl is still under development so I tried to help by writing a simple script for testing which combination to try.
I ended up using "ProductRepr SA NestedReplacingPowerRepresentation" and I got it to work.
PowerManifold
to use? So we can focus on implementing it and fixing bugs as they come up.ProductRepr
andArrayPartition
?I think you already answered it here (so linking for the next person): There are almost no drawbacks to ArrayPartition vs ProductRepr
identity_element
,vee
,hat
log(M, Identity(M), p)
where all points are calculated from the identity element can be quite handy, I currently create a vector of identity elements and use that.Thanks again for the support. I tried to fix the errors myself, but couldn't quite figure out the trait macros.
Here is the script in case you find it handy:
The text was updated successfully, but these errors were encountered: