Implementing a custom metric on Euclidean space #645
Replies: 8 comments
-
Hi, Cool, that you want to do that! I think you would also need to define You can also see that you would just use Let me know whether you have further questions :) |
Beta Was this translation helpful? Give feedback.
-
This is a very nice and helpful example, thank you for sharing! It is actually not unlike what I'm working on, where I am trying to test a metric derived from the graph of a function and using it for optimization. Great timing, I will try to work from this today and close the issue thereafter unless more questions arise. |
Beta Was this translation helpful? Give feedback.
-
If you end up with a nice small example, we could also consider adding it here in |
Beta Was this translation helpful? Give feedback.
-
I think I have the MetricManifold established as in your example, defining something like M = MetricManifold( As I understand there is a numerical solver that it can fall back to when you don't implement it explicitly. What would that function call look like, e.g.: |
Beta Was this translation helpful? Give feedback.
-
Yes, in principle, when you have loaded Still, said solver needs a way to “walk around” on the manifold, i.e. a retraction. You could take the exponential map from the original manifold (i.e. So here's a trick that should work. You define a https://juliamanifolds.github.io/ManifoldsBase.jl/stable/retractions.html#ManifoldsBase.ApproximateRetraction
and set the default retraction to this one
then the ode solver uses the + you just defined as an approximation for the ODE solver (I think, just typed not tested ;) ). |
Beta Was this translation helpful? Give feedback.
-
So the solver, to approximate the exponential map, needs to move between points on the manifold as part of its procedure. Seems sensible, and since the underlying manifold is really R^n we can just feed it the most natural retraction +. Now we need to define this + retraction so that it can be used by the solver. You suggest I define an approximate retraction, so I initialize: Then I redefine this function per your suggestion: Similarly I write: How then should I call the numerical exponential map? Sorry for all the questions, I think we're nearing the resolution. If it's helpful, I've attached the essential elements of my code to give you an idea of how I've implemented what we've talked about.
|
Beta Was this translation helpful? Give feedback.
-
HM, until now I just always assumed to know/anticipated what you wanted to do – now I am not sure? Well, first things first, this line
does not do what you think it does. None of the parameters it typed, so this introduces a retraction on any manifold (actually works for _any type
would be the right one – in naming, I would use capital letters for types (and maybe not abbreviations), but that is just style but when you call it you have to instantiate the type so that is
but you also get the allocating one (it creates the memory q itself) for free, so
also just works :) Now – why is the retraction method you declare an inverse retraction method? The correct one would be
and I noticed my default retraction idea was a bit vague we actually have to define
and then – well we still need OrdinaryDiffEq to actually solve the ODE ;)
and note that I switched to floats, I think you do not want to compute that in integer arithmetics? ...oh In theory – in practice it does not yet “find” your local metric implementation – you forgot to import that I think? Check also its signature again (sorry I am running out of time, already sitting here 30 minutes). |
Beta Was this translation helpful? Give feedback.
-
Manifolds.jl currently has two different ODE solvers for exponential map. Both actually work for any manifold with an affine connection, not necessarily a Riemannian one. The older one, less tested, uses |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to implement a custom metric on$\mathbb{R}^n$ . My goal is to test out the built-in ODE geodesic solver when I fully specify the metric as a matrix function (e.g., g= local_metric(M, p) where $p \in \mathbb{R}^n$ , $M = \mathbb{R}^n$ and local_metric is implemented by me and returns an $n \times n$ matrix). From the documentation it seems like the types and functionality for this exist, but I could not figure out how to actually implement it. Do you have any further information or examples I could look it?
Beta Was this translation helpful? Give feedback.
All reactions