Learning for CasADi: Data-driven Models in Numerical Optimization

Tim Salzmann,Jon Arrizabalaga,Joel Andersson,Marco Pavone,Markus Ryll
2023-12-10
Abstract:While real-world problems are often challenging to analyze analytically, deep learning excels in modeling complex processes from data. Existing optimization frameworks like CasADi facilitate seamless usage of solvers but face challenges when integrating learned process models into numerical optimizations. To address this gap, we present the Learning for CasADi (L4CasADi) framework, enabling the seamless integration of PyTorch-learned models with CasADi for efficient and potentially hardware-accelerated numerical optimization. The applicability of L4CasADi is demonstrated with two tutorial examples: First, we optimize a fish's trajectory in a turbulent river for energy efficiency where the turbulent flow is represented by a PyTorch model. Second, we demonstrate how an implicit Neural Radiance Field environment representation can be easily leveraged for optimal control with L4CasADi. L4CasADi, along with examples and documentation, is available under MIT license at <a class="link-external link-https" href="https://github.com/Tim-Salzmann/l4casadi" rel="external noopener nofollow">this https URL</a>
Systems and Control,Artificial Intelligence,Machine Learning,Robotics,Symbolic Computation
What problem does this paper attempt to address?
The paper primarily addresses the issue of how to seamlessly integrate deep learning models into numerical optimization frameworks, specifically how to use PyTorch-based models in CasADi for efficient numerical optimization. Specifically, the authors propose a framework called Learning for CasADi (L4CasADi), which achieves the following: 1. **Seamless Integration**: L4CasADi allows users to easily combine PyTorch-trained models with CasADi, thereby leveraging these models in numerical optimization problems. 2. **Hardware Acceleration**: L4CasADi supports the acceleration of learning model computations through hardware accelerators like GPUs, which is particularly important when dealing with complex optimization problems. 3. **Code Generation and Compilation**: To improve runtime efficiency, L4CasADi can automatically generate C/C++ code and compile it into shared libraries for use in different programming environments. 4. **Simplified User Interface**: L4CasADi is designed with user experience in mind, making the process of building and using models as simple and intuitive as possible. 5. **Generality**: The framework aims to support various PyTorch model architectures, not just limited to specific types of network structures. The paper also provides two specific case studies to demonstrate the application scenarios of L4CasADi: 1. **Fish Navigation in Turbulence**: In this example, L4CasADi is used to find an energy-efficient path for a fish to swim upstream in turbulent water. The turbulence is simulated through a PyTorch neural network, while the entire trajectory optimization problem is defined in CasADi. 2. **Collision-Free Trajectory Optimization in NeRF Environment**: Another example shows how to find an optimal collision-free trajectory in an environment represented by Neural Radiance Fields (NeRF). This example demonstrates how L4CasADi can integrate advanced computer vision models into optimization problems. In summary, the L4CasADi framework bridges the gap between deep learning models and numerical optimization techniques, enabling researchers to utilize data-driven methods in complex optimization problems.