                            Geometric Contact Flows: Contactomorphisms for Dynamics and Control

B. Methodology Details                                                   B.2. Integrating a Contact Hamiltonian Flow
This section presents the training algorithms for the single             A contact Hamiltonian dynamic system can be defined using
contactomorphism and ensemble approaches. We also                        a contact Hamiltonian function H on a contact manifold
outline the integration method for a contact Hamiltonian                 (M, η). The contact form η establishes a connection be-
dynamics, essential to implementing contactomorphism net-                tween H and its associated vector field XH via Equation (2).
works. Finally, we examine the implications of preserving                In local coordinates, the vector field XH is expressed as,
the contact structure for the physical interpretability of the                                    ∂H
ambient dynamics.                                                                          q̇i = ∂pi ,
                                                                                           
                                                                                       XH : ṗi = − ∂H         ∂H
                                                                                                      ∂qi − pi ∂s ,
                                                                                                                                  (31)
B.1. Training Algorithms                                                                   
                                                                                                    ∂H
                                                                                             ṡ = pi ∂p  − H.
                                                                                                       i


Algorithm 1 Training a Contactomorphism φr (T )                          This vector field generates a flow φ satisfying
                          t∈[0,tb ]
Input:  Dataset: {x̄b (t)}b∈[1,B]                                                  d
                                                                                      φt (x) = XH (φt (x)),     φ0 (x) = x.       (32)
Output: A trained contactomorphism φr (T )                                         dt
 1: for e = 1 to E do                     ▷ Iterate over epochs
 2:     for b = 1 to B do            ▷ Iterate over trajectories         The flow preserves the contact form η up to a scaling fac-
                                                                        tor a ∈ R, such that φ∗ η ′ = aη. Therefore, the resulting
 3:         {z̄b (t)}t∈[0,tb ] = φr (T ) {x̄b (t)}t∈[0,tb ] ;            transformation x(t) = φ(t)(x0 ) is formally a contactomor-
       ▷ Map the trajectories into the latent space using (9)            phism within (M, η). However, the numerical integration
 4:          {zb (t)}t∈[0,tb ] = φg (t) ({z̄b (0)}) ;                    of this flow can introduce errors, depending on the method
       ▷ Integrate the latent dynamics according to flow (6)             used. Contact splitting integrators are a family of numerical
                                                                         algorithms to integrate contact Hamiltonian flows while pre-
             {xb (t)}t∈[0,tb ] = φ−1
                                                          
 5:                               r (T ) {zb (t)}t∈[0,tb ] ;             serving the contact structure (Zadra, 2023). This algorithm
                   ▷ Map back to the ambient space with (9)              applies to Hamiltonian functions that can be expressed as
 6:        argmin ℓ(xb (t), x̄b (t), zb (t), z̄b (t));                   a sum of separate terms, with the state {q, p, s} updated in
                ▷ Update φr (T ) by minimizing loss (12)                 a corresponding number of steps. In our case, the Hamilto-
 7:    end for                                                           nian function (11) of the individual contactomorphism φrθk
 8: end for                                                              consists of three terms, resulting in the following three-step
                                                                         update process,
                                                                            
                                                                            qj+1 = qj ,
                                                                            
Algorithm 2 Training the Ensemble {φrn (T )}n∈[1,N ]                     1. pj+1 = pj − pj Fj + ∇Fj sj τ,
                                                                                                                
                                                                                                                                  (33a)
                                                                            
                           t∈[0,t ]                                            sj+1 = sj − Fj sj τ,
Input: Dataset: {x̄b (t)}b∈[1,B]
                              b
                                                                            

Output: A trained ensemble {φrn (T )}n∈[1,N ]
                                                                            
                                                                            qj+2 = qj+1 ,
                                                                            
 1: for e = 1 to E do                 ▷ Iterate over epochs              2. pj+2 = pj+1 − ∇Vj+1 τ,                                (33b)
 2:     for b = 1 to B do        ▷ Iterate over trajectories                
                                                                               sj+2 = sj+1 − Vj+1 τ,
                                                                            
 3:       for n = 1 to N do                                                 
                                                                                                             ⊤
                                                                                                                         
                                                                            qj+3 = qj+2 + Mj+2 + pj+2 ∇Mj+2 pj+2 τ,
                                                                
 4:           {z̄nb (t)}t∈[0,tb ] = φrn (T ) {x̄b (t)}t∈[0,tb ]             
    ▷ Map the trajectories into the latent space using (14a)             3. pj+3 = pj+2 ,
                                                                               sj+3 = sj+2 + p⊤         ⊤
                                                                                                                             
 5:       end for                                                           
                                                                                                 j+2 pj+2 ∇Mj+2 + Mj+2 pj+2 τ,
 6:          {znb (t)}t∈[0,tb ] = φg (t) ({z̄nb (0)}) ;                                                                           (33c)
       ▷ Integrate the latent dynamics according to flow (6)
                                                                         where Mj = M (pj ), Vj = V (qj ), and Fj = F (qj ). This
 7:        for j ∼ RandomShuffle(1, 2, . . . , N ) do                    integration method has the key advantage of being analyt-
               {xjb (t)}t∈[0,tb ] = φ−1         n
                                                                
 8:                                  r j (T ) {zb (t)}t∈[0,tb ]          ically invertible. As a result, a contactomorphism imple-
              ▷ Map back to the ambient space with (14b)                 mented according to this scheme can be efficiently reversed
 9:        end for                                                       with minimal computational cost.
                       PN
10:        argmin N1 n,j=1 ℓ(xjb (t), x̄b (t), znb (t), z̄nb (t));
           ▷ Update the ensemble by minimizing loss (12)                 B.3. Approximation Error of the Contactomorphism
11:    end for                                                           We experimentally evaluate the numerical error introduced
12: end for
                                                                         by our implementation of the mapping between the ambient

                                                                    16
