Learning Optimal Control with Stochastic Models of Hamiltonian Dynamics

Chandrajit Bajaj, Minh Nguyen

Introduction

Researchers at UT Austin have introduced NeuralPMP, a physics-informed framework designed to solve optimal control problems by learning underlying Hamiltonian dynamics. By integrating the Pontryagin Maximum Principle (PMP) with a variational autoencoder (VAE) structure, NeuralPMP navigates complex control tasks with improved exploration and lower costs compared to standard reinforcement learning (RL) approaches.

The Challenge of Optimal Control

Optimal control involves finding a sequence of actions that minimizes a specific cost—such as fuel consumption or time—while adhering to physical laws. This is traditionally addressed via RL or numerical optimization. However, RL often struggles with high-dimensional state spaces and high variance, frequently neglecting known physical constraints. NeuralPMP bridges the gap between "black-box" machine learning and classical control theory, specifically targeting continuous-time control problems where actions are part of a dynamical flow governed by physics.

Methodology: NeuralPMP

NeuralPMP operates in two distinct phases to learn the system's dynamics and optimal control strategy.

The NeuralPMP architecture, showing the P Net and the Reduced Hamiltonian net used to determine optimal trajectories.

Phase 1: Forward Hamiltonian Learning

Rather than learning a direct policy mapping states to actions, the model learns a reduced Hamiltonian ($h_\theta$) and an adjoint variable ($p$). In physical terms, $p$ acts as a generalized momentum that encodes the optimal control strategy. The network is trained using a loss function derived directly from the Pontryagin Maximum Principle (PMP), ensuring the learned dynamics are physically consistent. The architecture employs a "P Net" ($P_\phi$) to estimate the initial adjoint variable $p_0$ from the initial state $q_0$, which then flows through the Hamiltonian network to reach the optimal terminal state $q_{opt}$.

Phase 2: Backward Variational Training

To prevent the model from converging on sub-optimal or "static" solutions, stochasticity is injected via a Variational Autoencoder (VAE). The model learns a "reverse" Hamiltonian flow that attempts to reconstruct the initial state from the terminal state. This bidirectional approach forces the model to learn a distribution of paths, significantly improving its ability to explore the environment and generalize to new starting positions. Because Hamiltonian systems are theoretically reversible, this backward flow acts as a powerful regularizer.

Experimental Results

The framework was evaluated on three classic continuous-control benchmarks from the OpenAI Gym suite: Mountain Car, Cart Pole, and Pendulum.

Training loss convergence and the resulting behavior of the trained car agent in the Mountain Car environment.

NeuralPMP demonstrated superior performance and faster convergence compared to baselines. In the Mountain Car task, the full NeuralPMP model reduced the average evaluation cost to 0.4945, significantly lower than the 0.8285 achieved by a Random Hamiltonian baseline. The stochasticity added in Phase 2 allowed the model to drop costs faster across time steps compared to the deterministic version, particularly in the Pendulum task.

Environment Random Hamiltonian NeuralPMP (Phase 1) NeuralPMP (Full)
Mountain Car 0.8285 0.5793 0.4945
Cart Pole 0.1924 0.0212 0.0202
Pendulum 2.375 0.1701 0.1986

Key Insights

  • Beyond Policy Functions: For certain problems, such as irregular Linear Quadratic Regulators (LQR), a standard policy function $\pi(q)$ might not exist mathematically. NeuralPMP bypasses this by focusing on dynamics rather than direct mapping.
  • Handling Uneven Time: The discrete-time version of the algorithm successfully handled "irregular" control problems where time steps are not equally spaced—a common challenge in real-world sensor data.

Limitations and Future Directions

While successful on classic benchmarks, the framework currently requires access to a simulated environment (black-box) to evaluate dynamics and costs during training. Future work aims to develop "model-free" versions and scale the framework to higher-dimensional systems, such as complex humanoid robots or multi-agent systems. Additionally, the loss function relies on weighting parameters ($\alpha, \beta$) that currently require grid search to optimize.

Summary updated

BibTeX
@misc{bajaj2021learning,
  author = {Chandrajit Bajaj and Minh Nguyen},
  title = {{Learning Optimal Control with Stochastic Models of Hamiltonian Dynamics}},
  year = {2021},
  eprint = {2111.08108},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2111.08108},
}
Figure