JAX-enabled continuous-time LQR solver
Project description
LQRax
LQRax is JAX-enabled continuous-time LQR solver. It is essentially a Riccati equation solver completely written in JAX:
- It accelerates numerical simulation through JAX's
scanmechanism; - It allows rapid prototyping of iterative LQR (iLQR) for nonlinear control by supporting auto-differentiation on the loss function and dynamics;
- It also enables batch-based large-scale optimal control using JAX's
vmapmechanism.
This repo is currently under active development.
Install
Follow the instructions to install JAX before installing this package.
To install: pip install lqrax
Usage
There are two modules: LQR and iLQR,
The LQR module solves the following time-varying LQR problem:
$$ \arg\min_{u(t)} \int_0^T \Big[ (x(t)-x_{ref}(t))^\top Q (x(t)-x_{ref}(t)) + u(t)^\top R u(t) \Big] dt $$ $$ \text{s.t. } \dot{x}(t) = A(t) x(t) + B(t) u(t), \quad x(0) = x_0 $$
An jupyter notebook example for the LQR module is provided here. You can open it in Google Colab here.
The iLQR module solves a different time-varying LQR problem:
$$ \arg\min_{v(t)} \int_0^T \Big[ z(t)^\top Q z(t) + v(t)^\top R v(t) + z(t)^\top a(t) + v(t)^\top b(t) \Big] dt $$ $$ \text{s.t. } \dot{z}(t) = A(t) z(t) + B(t) v(t), \quad z(0) = 0. $$
This formulation is often used as the sub-problem for iterative linear quadratic regulator (iLQR) to calculate the steepest descent direction on the control for a general nonlinear control problem:
$$ \arg\min_{u(t)} \int_0^T l(x(t), u(t)) dt, \text{ s.t. } \dot{x}(t) = f(x(t), u(t)), $$
where the $z(t)$ and $v(t)$ are perturbations on the system's state $x(t)$ and control $u(t)$, and $A(t)$ and $B(t)$ are the linearized system dynamics $f(x(t), u(t))$ on the current system trajectory with respect to the state and control.
An jupyter notebook example of using the iLQR module for a nonlinear control problem is provided here. You can open it in Google Colab here.
Copyright and License
The implementations contained herein are copyright (C) 2024 - 2025 by Max Muchen Sun, and are distributed under the terms of the GNU General Public License (GPL) version 3 (or later). Please see the LICENSE for more information.
If you use the package in your research, please cite this repository. You can see the citation information at the right side panel under "About". The BibTeX file is attached below:
@software{sun_lqrax_2025,
author = {["Sun"], Max Muchen},
license = {GPL-3.0},
month = march,
title = {{LQRax: JAX-enabled continuous-time LQR solver}},
url = {https://github.com/MaxMSun/lqrax},
version = {0.0.2},
year = {2025}
}
Contact: msun@u.northwestern.edu
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lqrax-0.0.2.tar.gz.
File metadata
- Download URL: lqrax-0.0.2.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f12c815f48a638b28aeca4f2a432adbce359e0db105bf3c4fbbd1b5dc5f6a17
|
|
| MD5 |
c9f7dd0675546e5260862b26a42b4b38
|
|
| BLAKE2b-256 |
18d359674b14b3e40ef0e45091ff53341fba1d0032823c7dee00379c6b906d7f
|
File details
Details for the file lqrax-0.0.2-py3-none-any.whl.
File metadata
- Download URL: lqrax-0.0.2-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82bb8bc306d3ad64272ef7a1b372283de14b3a65583e48f3321798da9a1a7955
|
|
| MD5 |
88bfd36d73405d9a2f31dfd384c96b1b
|
|
| BLAKE2b-256 |
3331d0ac3b32a3b8ee253898e86dca99823bf954f408784ad584dbc8aa318d1f
|