Koopman Constrained Policy Optimization: A Koopman operator theoretic method for differentiable optimal control in robotics

Matthew Retchin, Brandon Amos, Steven Brunton, Shuran SongDifferentiable Almost Everything @ ICML 2023

TL;DR

This paper introduces Koopman Constrained Policy Optimization (KCPO), a novel method that combines Koopman operator theory with differentiable Model Predictive Control (MPC) to enable robots to learn optimal control policies with hard constraints. KCPO achieves end-to-end training, ensuring safety and performance by guaranteeing constraint satisfaction, and shows promising results in generalizing to unseen constraints.

What Problem Does This Paper Address?

Real-world robotic control is challenging due to nonlinear dynamics and the need for safety guarantees. Traditional optimal control methods often struggle with unknown systems or require complex system identification. While Model Predictive Control (MPC) offers a powerful framework for optimal control, its integration with deep learning for learning policies in unknown systems is hindered by the non-differentiability of standard MPC solvers and the inherent nonconvexity introduced by neural networks approximating system dynamics. This makes end-to-end training difficult, especially when hard constraints on control inputs are crucial for safety. Existing methods often relax these constraints or rely on approximations that can compromise performance.

Methods

The core innovation of KCPO lies in its integration of Koopman operator theory with differentiable MPC. Here's a breakdown:

  • Koopman Autoencoder: The paper utilizes a deep Koopman autoencoder. This neural network architecture learns a "lifting" function that maps the robot's nonlinear state space to a new, linear state space. In this linear space, the system's dynamics become predictable and controllable using linear methods. The autoencoder is trained to simultaneously learn this lifting function and the linear Koopman operator that describes the dynamics in the lifted space.
  • Differentiable MPC: KCPO employs an implicitly differentiable MPC solver. Unlike traditional MPC solvers that are difficult to differentiate through, this approach allows gradients to flow back from the MPC layer to the Koopman autoencoder and other neural network components. This is crucial for end-to-end training.
  • End-to-End Training: By combining the Koopman autoencoder and the differentiable MPC, KCPO enables the entire system—from state observation to control output—to be trained end-to-end. This allows the Koopman embedding and the MPC controller to be optimized jointly for the specific task.
  • Hard Box Constraints: A key feature is the explicit enforcement of hard box constraints on control inputs. This is achieved by the differentiable MPC solver, ensuring that the robot's actions always stay within safe and physically feasible limits. This contrasts with methods that use squashing functions, which can lead to performance degradation.

Datasets

The paper evaluates KCPO on several standard robotics environments:

  • Simple Pendulum
  • Cartpole Swing-Up
  • Reacher (using a custom environment inspired by Ivy Gym)
  • Differential Drive

These environments are used for imitation learning, where KCPO learns to replicate expert policies. The experiments specifically focus on generalization to out-of-distribution constraints, meaning constraints that were not seen during training.

Key Insights and Ideas

  • Linearization for Safety: The paper demonstrates that Koopman operator theory can effectively linearize nonlinear dynamics in a lifted space. This linearization is key to enabling robust and guaranteed optimal control with hard constraints, which is difficult to achieve directly in the original nonlinear space.
  • End-to-End Learning with Constraints: KCPO successfully bridges the gap between deep learning and constrained optimal control by enabling end-to-end training. This allows the system to learn not only how to control but also how to do so safely within specified bounds.
  • Generalization to Unseen Constraints: A significant finding is KCPO's ability to generalize to out-of-distribution constraints. While baselines tend to overfit to training constraints, KCPO shows improved performance when faced with novel constraint sets, suggesting a more robust learning mechanism.
  • Addressing MPC Instability: By using Koopman theory to ensure linear dynamics within the MPC framework, KCPO inherently addresses potential instability issues that can arise when training neural networks with traditional MPC solvers.

Key Results

  • Imitation Learning Performance: KCPO successfully recovers expert policies across the tested environments.
  • Out-of-Distribution Generalization: In most environments (Simple Pendulum, Cartpole Swing-Up, Reacher, and Differential Drive), KCPO outperforms baseline methods in generalizing to out-of-distribution constraints. For instance, in the Differential Drive environment, KCPO shows significantly better performance on new constraints compared to baselines.
  • Speed: The paper notes that KCPO's inference time is currently impractical for real-time control, requiring about one second per batch for a horizon of 20. However, this is an area for future improvement.

Limitations and Future Work

  • Real-time Control Speed: The current inference speed of KCPO is a significant limitation for real-time robotic applications. Future work will focus on improving computational efficiency.
  • Constraint Types: KCPO is currently limited to applying box constraints on controls. The authors suggest future extensions could incorporate state constraints or probabilistic constraints.
  • Stochastic Dynamics: While the paper focuses on deterministic environments, future work could explore extending KCPO to handle stochastic dynamics.
  • Koopman Operator Regularization: The paper omits Koopman operator regularization terms, relying on the AdamW optimizer for regularization. Further investigation into the necessity and impact of such terms could be beneficial.

Summary updated

BibTeX
@inproceedings{retchin2023koopman,
  author = {Matthew Retchin and Brandon Amos and Steven Brunton and Shuran Song},
  title = {{Koopman Constrained Policy Optimization: A Koopman operator theoretic method for differentiable optimal control in robotics}},
  booktitle = {Differentiable Almost Everything @ ICML},
  year = {2023},
  url = {https://openreview.net/forum?id=3W7vPqWCeM},
}
Figure