rl4evrptw
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.1%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: s33zhong
- License: mit
- Language: Python
- Default Branch: main
- Size: 64.5 MB
Statistics
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
An extensive Reinforcement Learning (RL) for Combinatorial Optimization (CO) benchmark. Our goal is to provide a unified framework for RL-based CO algorithms, and to facilitate reproducible research in this field, decoupling the science from the engineering.
RL4CO is built upon: - TorchRL: official PyTorch framework for RL algorithms and vectorized environments on GPUs - TensorDict: a library to easily handle heterogeneous data such as states, actions and rewards - PyTorch Lightning: a lightweight PyTorch wrapper for high-performance AI research - Hydra: a framework for elegantly configuring complex applications
We offer flexible and efficient implementations of the following policies: - Constructive: learn to construct a solution from scratch - Autoregressive (AR): construct solutions one step at a time via a decoder - NonAutoregressive (NAR): learn to predict a heuristic, such as a heatmap, to then construct a solution - Improvement: learn to improve a pre-existing solution
We provide several utilities and modularization. For example, we modularize reusable components such as environment embeddings that can easily be swapped to solve new problems.
Getting started
RL4CO is now available for installation on pip!
bash
pip install rl4co
To get started, we recommend checking out our quickstart notebook or the minimalistic example below.
Install from source
This command installs the bleeding edge main version, useful for staying up-to-date with the latest developments - for instance, if a bug has been fixed since the last official release but a new release hasn’t been rolled out yet:
bash
pip install -U git+https://github.com/ai4co/rl4co.git
Local install and development
If you want to develop RL4CO we recommend you to install it locally with pip in editable mode:
bash
git clone https://github.com/ai4co/rl4co && cd rl4co
pip install -e .
We recommend using a virtual environment such as conda to install rl4co locally.
Usage
Train model with default configuration (AM on TSP environment):
bash
python run.py
[!TIP] You may check out this notebook to get started with Hydra!
Change experiment settings
Train model with chosen experiment configuration from [configs/experiment/](configs/experiment/) ```bash python run.py experiment=routing/am env=tsp env.num_loc=50 model.optimizer_kwargs.lr=2e-4 ``` Here you may change the environment, e.g. with `env=cvrp` by command line or by modifying the corresponding experiment e.g. [configs/experiment/routing/am.yaml](configs/experiment/routing/am.yaml).Disable logging
```bash python run.py experiment=routing/am logger=none '~callbacks.learning_rate_monitor' ``` Note that `~` is used to disable a callback that would need a logger.Create a sweep over hyperparameters (-m for multirun)
```bash python run.py -m experiment=routing/am model.optimizer.lr=1e-3,1e-4,1e-5 ```Minimalistic Example
Here is a minimalistic example training the Attention Model with greedy rollout baseline on TSP in less than 30 lines of code:
```python from rl4co.envs.routing import TSPEnv, TSPGenerator from rl4co.models import AttentionModelPolicy, POMO from rl4co.utils import RL4COTrainer
Instantiate generator and environment
generator = TSPGenerator(numloc=50, locdistribution="uniform") env = TSPEnv(generator)
Create policy and RL model
policy = AttentionModelPolicy(envname=env.name, numencoderlayers=6) model = POMO(env, policy, batchsize=64, optimizer_kwargs={"lr": 1e-4})
Instantiate Trainer and fit
trainer = RL4COTrainer(max_epochs=10, accelerator="gpu", precision="16-mixed") trainer.fit(model) ```
Other examples can be found on our documentation!
Testing
Run tests with pytest from the root directory:
bash
pytest tests
Known Bugs
Bugs installing PyTorch Geometric (PyG)
Installing PyG via Conda seems to update Torch itself. We have found that this update introduces some bugs with torchrl. At this moment, we recommend installing PyG with Pip:
bash
pip install torch_geometric
Contributing
Have a suggestion, request, or found a bug? Feel free to open an issue or submit a pull request. If you would like to contribute, please check out our contribution guidelines here. We welcome and look forward to all contributions to RL4CO!
We are also on Slack if you have any questions or would like to discuss RL4CO with us. We are open to collaborations and would love to hear from you 🚀
Contributors
Citation
If you find RL4CO valuable for your research or applied projects:
bibtex
@article{berto2024rl4co,
title={{RL4CO: an Extensive Reinforcement Learning for Combinatorial Optimization Benchmark}},
author={Federico Berto and Chuanbo Hua and Junyoung Park and Laurin Luttmann and Yining Ma and Fanchen Bu and Jiarui Wang and Haoran Ye and Minsu Kim and Sanghyeok Choi and Nayeli Gast Zepeda and Andr\'e Hottung and Jianan Zhou and Jieyi Bi and Yu Hu and Fei Liu and Hyeonah Kim and Jiwoo Son and Haeyeon Kim and Davide Angioni and Wouter Kool and Zhiguang Cao and Jie Zhang and Kijung Shin and Cathy Wu and Sungsoo Ahn and Guojie Song and Changhyun Kwon and Lin Xie and Jinkyoo Park},
year={2024},
journal={arXiv preprint arXiv:2306.17100},
note={\url{https://github.com/ai4co/rl4co}}
}
Note that a previous version of RL4CO has been accepted as an oral presentation at the NeurIPS 2023 GLFrontiers Workshop. Since then, the library has greatly evolved and improved!
Join us
We invite you to join our AI4CO community, an open research group in Artificial Intelligence (AI) for Combinatorial Optimization (CO)!
Owner
- Login: s33zhong
- Kind: user
- Repositories: 1
- Profile: https://github.com/s33zhong
GitHub Events
Total
- Watch event: 1
- Public event: 1
- Push event: 12
Last Year
- Watch event: 1
- Public event: 1
- Push event: 12
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/download-artifact v4.1.7 composite
- actions/setup-python v4 composite
- actions/upload-artifact v3 composite
- pypa/gh-action-pypi-publish release/v1 composite
- actions/cache v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- codecov/codecov-action v3 composite
- black *
- einops *
- griffe *
- griffe-inherited-docstrings *
- griffe-typingdoc *
- hydra-colorlog *
- hydra-core *
- lightning >=2.1.0
- markdown-gfm-admonition *
- matplotlib *
- mdx-breakless-lists *
- mdx-truly-sane-lists *
- mike *
- mkdocs *
- mkdocs-autolinks-plugin *
- mkdocs-jupyter *
- mkdocs-material *
- mkdocs-redirects *
- mkdocs-same-dir *
- mkdocstrings-python *
- numba >=0.58.1
- omegaconf *
- pre-commit >=3.3.3
- pyrootutils *
- pytest *
- pytest-cov *
- python >=3.9
- pyvrp >=0.9.0
- rich *
- robust-downloader *
- ruff *
- scipy *
- tensordict >=0.4.0
- torch_geometric *
- torchrl >=0.4.0
- wandb *