This repository contains the code for the journal paper 'Grammar-based Ordinary Differential Equation Discovery' published in Mechanical Systems & Signal Processing by K. Yu, E. Chatzi and G. Kissas, available under https://doi.org/10.1016/j.ymssp.2025.113395.
GODE is a methodology for the end-to-end discovery of symbolic ordinary differential equations (ODEs). It combines formal grammars with dimensionality reduction and stochastic search to efficiently search high-dimensional combinatorial spaces. Grammars allow us to seed domain knowledge and structure in both the generation of large pretrained libraries as well as inference processes, effectively reducing the exploration space. This method has been validated on first- and second-order linear and nonlinear ODEs with examples from structural dynamics.
- GODE: contains code to train the GODE and discover equations with the GODE.
- odeformer: code to discover equations with ODEFormer. It was slightly adapted to fit the purpose of the comparison and to generate own models. (https://github.com/sdascoli/odeformer)
- ProGED: code to discover equations with ProGED, used version is 0.8.5. (https://github.com/brencej/ProGED)
- PySR: code to discover equations with PySR, used version is 0.19.4. (https://github.com/MilesCranmer/PySR)
- Plots: contains csv-files of the discovered equations by all models and jupyter notebooks to visualize the results
To test GODE, please install the requirements of the file 'requirements.txt' in the GODE folder.
The paper presents three benchmarks: Benchmark 1 on one-dimensional explicit ODEs, Benchmark 2 on linear and nonlinear ODEs, Benchmark 3 on nonlinear ODEs from structural dynamics and Benchmark 4 contains the Silverbox benchmark.
For each benchmark, a separate model has been trained (besides Benchmark 3 and 4 use the same model). Depending on the benchmark, different grammars with different maximum lengths of the rule sequence are used, this needs to be specified udner 'grammar/common_args.py'. To for instance test example ID 5 from Benchmark 1 with three runs, after specifying the maximum length of the rule sequence 'MAX_LEN', run in the command line:
python GODE/EquationDiscovery_B1.py 5 3
Some code snippets from the files 'GODE/parser/cfg_parser.py', 'GODE/model/vae.py' are from the SDVAE implementation: https://github.com/Hanjun-Dai/sdvae, however, the GVAE algorithm follows the original GVAE implementation (https://github.com/mkusner/grammarVAE).
If you are using the code or find it useful, please consider citing the journal paper.
@article{yu_grammar-based_2025,
title = {Grammar-based ordinary differential equation discovery},
volume = {240},
issn = {08883270},
url = {https://linkinghub.elsevier.com/retrieve/pii/S0888327025010969},
doi = {10.1016/j.ymssp.2025.113395},
language = {en},
urldate = {2025-10-02},
journal = {Mechanical Systems and Signal Processing},
author = {Yu, Karin and Chatzi, Eleni and Kissas, Georgios},
month = nov,
year = {2025},
pages = {113395},
}