LQRax
LQRax is JAX-enabled continuous-time Riccati equation solver for LQR problems.
- 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 $$
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.
Examples
| Example | Code | Example | Code |
|---|---|---|---|
| LQR for double integrator |
[Jupyter Notebook] [Google Colab] |
Nonlinear control with iLQR |
[Jupyter Notebook] [Google Colab] |
| Multi-agent iLQGames |
[Jupyter Notebook] [Google Colab] |
Ergodic control |
[Jupyter Notebook] [Google Colab] |
Please also checkout Linear Quadratic Flow Matching that uses this package (the LQR module).
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.6},
year = {2025}
}
Contact: msun@u.northwestern.edu
Metadata
Release files for lqrax 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lqrax-0.0.6.tar.gz | 16.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lqrax-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.8 kB
Release files / lqrax-0.0.6.tar.gz
| Download URL | lqrax-0.0.6.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
101e9492a8749d0122d1ebee4114137d9ace8af9b5b9771828c45d63bc204f29
|
|
BLAKE2b-256 checksum How to use checksums |
1d1c4f4eac1d9b8f08b6226633563efea0eba5252b4b9c2c5819a0cf6135fec8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.14
|
Release files / lqrax-0.0.6-py3-none-any.whl
| Download URL | lqrax-0.0.6-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e01903414bc0669330d84031e2bbc7da714af1533dcc0cd2af7b57bb14e4b058
|
|
BLAKE2b-256 checksum How to use checksums |
72f9f15a86a278f0ae5e2e566512ac3c60384e4cf7c4fe0b02f15b28360e5d45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.14
|