                            Geometric Contact Flows: Contactomorphisms for Dynamics and Control
                          1.00                                                ĝ ′ which is generally Finslerian (see Sec. 3), due to its poten-
                                                          0.8
                          0.75                                                tial asymmetry in q̇. To solve this, we bring back the opti-




                             Uncertainty




                                                            Uncertainty
                                                          0.6                 mization to the contact manifold M = T ∗ RN by adopting
                          0.50                            0.4                 the geodesic interpretation of dynamical systems (Udriste &
                          0.25                            0.2                 Udriste, 2000). This involves the reformulation of the prob-
                                                                              lem as a dynamic optimization under a time reparametriza-
                          0.00                                                tion (López & Martı́nez, 2000). Specifically, we define a
Figure 4. Optimal control problem (18) in both latent (left) and              perturbation u to the velocity field of the learned geodesic
ambient spaces (right). The learned dynamics ż = ZHg is ex-                  q̇g under metric ĝ, resulting in a perturbed direction q̇g′
tended by the control input u (represented by the golden arrow) to            under a modified metric ĝ ′ ,
minimize uncertainty and quickly converge to the data support.                                Z t1
                                                                                                    σz (qg′ , q̇g′ , s) + ∥u(t)∥2 dt,
                                                                                                                                 
                                                                                         min
The average prediction is computed and mapped back to
                                                                                           u   t0                                           (17)
the original space to estimate the predictive variance of the                                                s.t. q̇g′ = q̇g + u(t).
resulting N points,
                                                                              The control term u locally deforms the trajectory to avoid
       σx = σ{φ−1                                                             uncertain regions. Since the learned geodesic flow is en-
                                               
                 r n (T )}n∈[1,N ] µ{z}n∈[1,N ] ,       (15a)
                                                                             coded by the contact Hamiltonian vector field ZHg , we lift
       σz = σ{φrn (T )}n∈[1,N ] µ{x}n∈[1,N ] ,         (15b)
                                                                              the optimization to the latent state space via the Riemannian
where µ and σ denote the mean and variance of the pre-                        connection in Eq. (1),
dictions. Note that this computation requires all contacto-                                     Z t1
                                                                                                      σz2 (z(t)) + ∥u(t)∥2 dt
                                                                                                                            
morphisms to share the same latent space. We ensure this                                  min
by jointly training the ensemble as follows: (1) Transform
                                                                                            u    t0                                    (18)
all B training trajectories into N × B latent trajectories                                   s.t. ż(t) = ZHg (z(t)) + u(t).
                        n∈[1,N ]
{z̄nb (t), t ∈ [0, tb ]}b∈[1,B] using all N contactomorphisms
                                                                              In regions where the uncertainty is low (i.e., σz ≈ 0), the
φrn ; (2) Integrate the latent dynamics starting from the
                                         n∈[1,N ]                             control action vanishes (i.e., u ≈ 0), and the resulting
N × B initial latent states {z̄nb (0)}b∈[1,B] to compute the                  latent dynamics ż(t) = ZHg (z) are unchanged, correspond-
                                                     n∈[1,N ]
predicted latent trajectories {znb (t), t ∈ [0, tb ]}b∈[1,B] ; (3)            ing to the original latent metric, i.e., ĝ ′ ≈ ĝ. Conversely,
Randomly select N inverse maps with replacement from the                      in high-uncertainty regions, the control action u modifies
ensemble to compute the ambient predictions {xnb (t), t ∈                     the dynamics by bending the latent trajectories to guide
         n∈[1,N ]                                                             them away from data-poor regions. Figure 4 illustrates the
[0, tb ]}b∈[1,B] ; (4) Compute the average loss over the N
                                 PN                                           optimal control problem (18) in the reconstruction of the
contactomorphisms as ℓe = N1 n=1 ℓ, with ℓ defined as in
                                                                              damped harmonic oscillator dynamics (Figure 1).
Eq. 12. Algorithm 2 in App. B.1 summarizes this process.
                                                                              Designing safety-aware geodesics. The optimization
Designing uncertainty-aware geodesics. We leverage
                                                                              problem (18) can be extended with other types of energy
the ensemble uncertainty to drive the system dynamics to
                                                                              functions aimed at penalizing the crossing of unsafe re-
remain within or converge toward well-informed, data-rich
                                                                              gions. To illustrate this, consider learning a contact Hamil-
regions. As discussed in Sec. 3, the contact Hamiltonian
                                                                              tonian dynamics for a controlled physical system. Here,
dynamics z(t) on the latent space (N , η ′ ), governed by the
                                                                              an unsafe region can be described by obstacles in the
Hamiltonian function Hg , can be interpreted as geodesics
                                                                              system workspace. Formally, an obstacle in the position
q(s) on the augmented Riemannian manifold (RN × R, ĝ)
                                                                              space RN is represented by a set Υq consisting of posi-
with respect to the metric ĝ in Eq. (5). To guide the dynamics
                                                                              tions qo ∈ Υq , uniformly sampled from the spatial distri-
away from uncertain regions, we propose to reshape ĝ using
                                                                              bution of points occupied by the obstacle. This set ex-
the ensemble uncertainty σz . This increases the traversal
                                                                              tends to the contact ambient space as Υx , where each
cost outside the data manifold, thereby steering the latent
                                                                              state xo = {qo , p, s} ∈ Υx ⊂ (M, η) is obtained by
dynamics away from data-poor regions. The geodesic q(s)
                                                                              augmenting qo with the momentum p and action variable
is obtained by solving the optimization problem,
                                                                              s that the dynamical system can acquire. This formula-
              Z s1 p                                                        tion implies that an obstacle at qo cannot be traversed for
         min           ĝ(q̇, q̇, s) + σz (q, q̇, s) ds,   (16)               any combination of p and s. The sampled points xo are
          q̇   s0
                                                                              mapped to the latent space (N , η ′ ) via the ensemble, as
where canonical coordinates z = {q, p, s} ∈ T ∗ RN × R                        Υz = {φrn (T )(xo )}n∈[1,N ] . In this latent space, the en-
are converted to {q, q̇, s} ∈ T RN ×R. This corresponds to                    ergy assigned to each bin is determined by the density of
computing a geodesic with respect to an augmented metric                      mapped points it contains. This energy distribution is then

                                                                          6
