Offical Pytorch implementation for the paper "Analytical Lyapunov Function Discovery: An RL-based Generative Approach", presented at ICML 2025. We introduce the first RL-based framework for directly discovering analytical Lyapunov functions for nonlinear dynamical systems, bypassing the need for supervised learning with large-scale datasets. Our framework succeeds on various non-polynomial dynamics, like the simple pendulum, quadrotor, and power system frequency control, and notably scales to a 10-D system and discovers a valid local Lyapunov function for power system frequency control with lossy transmission lines, which is previously unknown in the literature. For details, see Analytical Lyapunov Function Discovery: An RL-based Generative Approach.
Clone this repository and install the required Conda environment and dependencies by running:
run install.sh
Before training, you need to specify the test dynamics and parameters defining the desirable output expressions. Follow these steps:
In config.py, edit the function dynamics()
to define your system's ODEs. Specify the state-space variables and return the dynamics in symbolic form.
Modify the state space domain conf.exp.benchmark
in
Lyapunov_test_dso.py at Line 67.
In config.py, update the config_factory()
function to customize training hyperparameters, such as:
-
symbolic library
$\mathcal{L}$ , -
length of sampled candidates (max & min),
-
learning rates of training,
-
hyperparameter
$\epsilon$ of risk-seeking policy gradient and so on.
Note: In folder example_config, you can find a few examples on how to define system dynamics and relevant training parameters.
Once your dynamics and training domain are configured, start training by running:
python Lyapunov_test_dso.py
Intermediate training statistics and final training result (if training converges) can be found in the log directory ./log/{$RUN}
.
To configure and test the experiments with different initialization, please modify at the top of Lyapunov_test_dso.py
conf.exp.seed_start = 13
If you found this work useful or interesting for your own research, we would appreciate if you could cite our work:
@article{zou2025analytical,
title={Analytical Lyapunov Function Discovery: An RL-based Generative Approach},
author={Zou, Haohan and Feng, Jie and Zhao, Hao and Shi, Yuanyuan},
journal={arXiv preprint arXiv:2502.02014},
year={2025}
}
Feel free to leave any questions in the issues of Github or email the author at hazou@ucsd.edu.