Learning to Choose Optimizers (l2co)
Summary
L2CO is a Python project accompanying the paper Learning to Choose Optimizers (IEEE CEC 2026).
Statement of need
Optimization plays a central role in data-driven design. However, choosing an appropriate optimization algorithm for a specific task is often challenging, as it depends on the structure of the optimization problem and practical limitations such as the computational budget. To tackle this challenge, the field has seen a shift from manually designing optimizers toward using machine learning methods that attempt to learn the optimization process itself. Despite significant progress, existing approaches frequently exhibit limited generalization to new distributions and typically require retraining to transfer their knowledge.
We introduce a new approach called ''Learning to Choose Optimizers'' (L2CO). In our approach, a meta-learner first selects an optimizer before any function evaluations---based solely on available problem characteristics---and then reassesses that choice using a unified model that jointly encodes problem context, optimizer identity, and the observed optimization trajectory. By restricting selection to well-established algorithms, L2CO avoids the convergence issues of learned update rules while retaining the adaptability of dynamic selection.
In this work, we train our model offline on a collection of benchmark functions, employing a mixture of gradient-based, population-based, and probabilistic model-based optimizers. We demonstrate the effectiveness of our method by comparing its performance to classical optimizers on standard benchmark problems and a neural net classification task. The empirical results indicate that L2CO is a promising tool with improved generalization capabilities.
Key Features
- 30+ optimizers -- gradient-based (Optax: Adam, SGD, L-BFGS, ...) and evolutionary (EvoSax: CMA-ES, PSO, DE, ...)
- Two-stage selection -- Stage 0 (cold-start from task features) + Stage 1 (trajectory-aware reassessment via LSTM)
- Built on JAX/Equinox -- JIT-compiled, vmappable, functional
- Multiple benchmarks -- BBOB, CEC 2005, PDE, neural network training tasks
- Hydra + f3dasm pipeline -- reproducible experiment orchestration with HPC/SLURM support
Dependencies
L2CO builds on the following packages:
| Package | Description |
|---|---|
| f3dasm | Framework for data-driven design and analysis of structures and materials |
| bbob-jax | JAX implementation of the BBOB benchmark functions |
| l2co-tasks | Benchmark functions and tasks used by L2CO (BBOB, CEC 2005, PDE, neural network training) |
| l2co-optimizers | Bare optimizers compatible with the L2CO library |
| bessaplots | Plotting utilities |
| JAX | Composable transformations of NumPy programs |
| Equinox | Neural networks and more for JAX |
| Optax | Gradient-based optimization in JAX |
| EvoSax | Evolutionary strategies in JAX |
| scikit-learn | Machine learning in Python |
Getting started
Installation instructions for users
Install l2co from PyPI into an environment with Python 3.12 or newer:
pip install l2co
Installation instructions for developers
Clone the repository and install it in editable mode, with the development dependencies (also needed for building the mkdocs documentation):
git clone https://github.com/bessagroup/l2co.git
cd l2co
pip install -e '.[dev,docs,tests]'
With uv, a plain uv sync expects checkouts of f3dasm, l2co-tasks, l2co-optimizers and bessaplots next to this repository (see [tool.uv.sources] in pyproject.toml). Run uv sync --no-sources to take them from PyPI instead.
For detailed instructions on how to develop on this package, please refer to the Contributing Guide.
After installation, start by looking at the Getting Started Guide. To plug your own optimizer into the RolloutWrapper, see Register your own optimizer in l2co-optimizers.
Experiments
The experimental pipeline consists of three stages, available in the /experiments/ folder:
| Experiment | Description |
|---|---|
create_optimization_dataset |
Run algorithm portfolio on benchmark tasks, collect RTD trajectories |
l2co_train_stage0 |
Train cold-start algorithm selection model (sklearn regressors) |
l2co_train_stage1 |
Train trajectory-aware reassessment model (LSTM + MLP) |
The experiments/ folder also includes generate_figures.py for ERTD plot generation and submit_job.sh for SLURM cluster submission. See experiments/README.md for full documentation on configuration, parameters, and Hydra overrides.
The results in the paper were produced with l2co v1.3.1. The code has evolved since.
Authorship & Citation
Current creator and developer: M.P. van der Schelling (M.P.vanderSchelling@tudelft.nl, ORCID)
If you use l2co in your research or in a scientific publication, it is appreciated that you cite the paper below:
IEEE Congress on Evolutionary Computation (CEC) 2026 (paper):
@inproceedings{vanderSchelling2026,
title = {Learning to Choose Optimizers},
author = {M. P. van der Schelling and D. Toshniwal and M. A. Bessa},
booktitle = {2026 IEEE Congress on Evolutionary Computation (CEC)},
year = {2026},
pages = {1--8},
publisher = {IEEE},
doi = {10.1109/CEC69861.2026.11727310},
url = {https://doi.org/10.1109/CEC69861.2026.11727310}
}
Community Support
- If you find any issues, bugs or problems within this repository, please use the GitHub issue tracker to report them.
- If you have questions, feature requests or ideas for this project, please use the GitHub Discussions
Please refer to L2CO's Code of Conduct
License
Copyright 2026, Martin van der Schelling
All rights reserved.
This project is licensed under the BSD 3-Clause License. See LICENSE for the full license text.
Metadata
Release files for l2co 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| l2co-2.0.1.tar.gz | 249.5 kB | Without provenance | Details for l2co-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| l2co-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for l2co-2.0.1-py3-none-any.whl |
Total release size: 515.5 kB
Release files / l2co-2.0.1.tar.gz
| Download URL | l2co-2.0.1.tar.gz |
|---|---|
| Size | 249.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e445be5ea6b038bd055e03dda7d0749d2df7ad2eaf59f56cfa5137f3ca94c2f7
|
|
BLAKE2b-256 checksum How to use checksums |
75d26fb8854ff2942d63b4cb1808d528121263804591f9121f485da227002d8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / l2co-2.0.1-py3-none-any.whl
| Download URL | l2co-2.0.1-py3-none-any.whl |
|---|---|
| Size | 266.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eab32aa7aff698d9ded155474cedc6e2d98a7863b7f073cf09abf7f54e838737
|
|
BLAKE2b-256 checksum How to use checksums |
72c2ebd3a7c1efb842e6fffcfa9d6c714776aa086aa9c0d61cf8d666480f4fcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for l2co 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.