Skip to content

Commit

Permalink
Merge pull request #201 from cbhua/doc
Browse files Browse the repository at this point in the history
New Documentation 📜
  • Loading branch information
fedebotu committed Jul 24, 2024
2 parents 907d075 + 229e61e commit ff9ad71
Show file tree
Hide file tree
Showing 160 changed files with 1,564 additions and 20,092 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ preferred-citation:
given-names: Minsu
- family-names: Choi
given-names: Sanghyeok
- family-names: Gast
given-names: Zepeda
- family-names: Gast Zepeda
given-names: Nayeli
- family-names: Hottung
given-names: André
- family-names: Zhou
Expand Down
45 changes: 32 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
<div align="center">


<div align="center">
<img src="https://raw.githubusercontent.com/ai4co/assets/main/svg/rl4co_animated_full.svg" alt="AI4CO Logo" style="width: 40%; height: auto;">
</div>
<img src="https://raw.githubusercontent.com/ai4co/assets/main/svg/rl4co_animated_full.svg" alt="AI4CO Logo" style="width: 40%; height: auto;">

</br></br>


<a href="https://pytorch.org/get-started/locally/"><img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-ee4c2c?logo=pytorch&logoColor=white"></a>
<a href="https://pytorchlightning.ai/"><img alt="Lightning" src="https://img.shields.io/badge/-Lightning-792ee5?logo=pytorchlightning&logoColor=white"></a>
<a href="https://github.com/pytorch/rl"><img alt="base: TorchRL" src="https://img.shields.io/badge/base-TorchRL-red">
<a href="https://hydra.cc/"><img alt="config: Hydra" src="https://img.shields.io/badge/config-Hydra-89b8cd"></a> [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Slack](https://img.shields.io/badge/slack-chat-611f69.svg?logo=slack)](https://join.slack.com/t/rl4co/shared_invite/zt-1ytz2c1v4-0IkQ8NQH4TRXIX8PrRmDhQ)
[![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT) <a href="https://colab.research.google.com/github/ai4co/rl4co/blob/main/examples/1-quickstart.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> [![PyPI](https://img.shields.io/pypi/v/rl4co?logo=pypi)](https://pypi.org/project/rl4co)[![Codecov](https://codecov.io/github/ai4co/rl4co/tree/main/badge.svg)](https://app.codecov.io/github/ai4co/rl4co/tree/main/rl4co)[![Test](https://github.com/ai4co/rl4co/actions/workflows/tests.yml/badge.svg)](https://github.com/ai4co/rl4co/actions/workflows/tests.yml)
<a href="https://github.com/pytorch/rl"><img alt="base: TorchRL" src="https://img.shields.io/badge/base-TorchRL-red"></a>
<a href="https://hydra.cc/"><img alt="config: Hydra" src="https://img.shields.io/badge/config-Hydra-89b8cd"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://join.slack.com/t/rl4co/shared_invite/zt-1ytz2c1v4-0IkQ8NQH4TRXIX8PrRmDhQ"><img alt="Slack" src="https://img.shields.io/badge/slack-chat-611f69.svg?logo=slack"></a>
<a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-red.svg"></a>
<a href="https://colab.research.google.com/github/ai4co/rl4co/blob/main/examples/1-quickstart.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a>
<a href="https://pypi.org/project/rl4co"><img alt="PyPI" src="https://img.shields.io/pypi/v/rl4co?logo=pypi"></a>
<a href="https://app.codecov.io/github/ai4co/rl4co/tree/main/rl4co"><img alt="Codecov" src="https://codecov.io/github/ai4co/rl4co/tree/main/badge.svg"></a>
<a href="https://github.com/ai4co/rl4co/actions/workflows/tests.yml"><img alt="Test" src="https://github.com/ai4co/rl4co/actions/workflows/tests.yml/badge.svg"></a>

<p>
<a href="https://rl4co.readthedocs.io/"><strong>Documentation</strong></a> |
<a href="#getting-started"><strong>Getting Started</strong></a> |
<a href="#usage"><strong>Usage</strong></a> |
<a href="#contributing"><strong>Contributing</strong></a> |
<a href="https://arxiv.org/abs/2306.17100"><strong>Paper</strong></a> |
<a href="#join-us"><strong>Join Us</strong></a>
</p>


[**Documentation**](https://rl4co.readthedocs.io/) | [**Getting Started**](#getting-started) | [**Usage**](#usage) | [**Contributing**](#contributing) | [**Paper**](https://arxiv.org/abs/2306.17100) | [**Join Us**](#join-us)

</div>



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.


Expand All @@ -27,20 +42,26 @@ RL4CO is built upon:
- [PyTorch Lightning](https://github.com/Lightning-AI/lightning): a lightweight PyTorch wrapper for high-performance AI research
- [Hydra](https://github.com/facebookresearch/hydra): a framework for elegantly configuring complex applications

![RL4CO-Overview](https://github.com/ai4co/rl4co/assets/48984123/0e409784-05a9-4799-b7aa-6c0f76ecf27f)
<div align="center">
<img src="https://github.com/ai4co/rl4co/assets/48984123/0e409784-05a9-4799-b7aa-6c0f76ecf27f" alt="RL4CO-Overview" style="max-width: 90%;">
</div>

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 an pre-existing solution

![RL4CO-Policy-Overview](https://github.com/ai4co/rl4co/assets/48984123/9e1f32f9-9884-49b9-b6cd-364861cc8fe7)
<div align="center">
<img src="https://github.com/ai4co/rl4co/assets/48984123/9e1f32f9-9884-49b9-b6cd-364861cc8fe7" alt="RL4CO-Policy-Overview" style="max-width: 90%;">
</div>

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](https://github.com/ai4co/rl4co/blob/main/examples/3-creating-new-env-model.ipynb).

![RL4CO-Env-Embeddings](https://github.com/ai4co/rl4co/assets/48984123/c47a9301-4c9f-43fd-b21f-761abeae9717)

<div align="center">
<img src="https://github.com/ai4co/rl4co/assets/48984123/c47a9301-4c9f-43fd-b21f-761abeae9717" alt="RL4CO-Env-Embedding" style="max-width: 90%;">
</div>


## Getting started
Expand Down Expand Up @@ -200,6 +221,4 @@ We invite you to join our AI4CO community, an open research group in Artificial

<div align="center">
<img src="https://raw.githubusercontent.com/ai4co/assets/main/svg/ai4co_animated_full.svg" alt="AI4CO Logo" style="width: 30%; height: auto;">
</div>


</div>
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

114 changes: 13 additions & 101 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,26 @@
# 📑 RL4CO Docs
# RL4CO Documentation

We are using [Sphinx](https://www.sphinx-doc.org/en/master/) with [Napoleon extension](https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html) to build the documentation.
Moreover, we set [Google style](https://google.github.io/styleguide/pyguide.html) to follow with type convention.
We use [MkDocs](https://www.mkdocs.org/) to generate the documentation with the [MkDocs Material theme](https://squidfunk.github.io/mkdocs-material/).

- [Napoleon formatting with Google style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)
- [ReStructured Text (reST)](https://docs.pylonsproject.org/projects/docs-style-guide/)
- [Paragraph-level markup](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#paragraphs)
## Development

See following short example of a sample function taking one position string and optional
From the root directory:

```python
from typing import Optional
1. Install RL4CO locally


def my_func(param_a: int, param_b: Optional[float] = None) -> str:
"""Sample function.
Args:
param_a: first parameter
param_b: second parameter
Return:
sum of both numbers
Example::
>>> my_func(1, 2)
3
Note:
If you want to add something.
"""
p = param_b if param_b else 0
return str(param_a + p)
```bash
pip install -e ".[dev,graph,routing,docs]"
```

## 🗂️ File structures

```
.
├── _build/ - output website, only for local building
├── _content/ - content for docs pages in Markdown format
├── _theme/
│ └── rl4co/ - website theme files
├── conf.py - main config file for building
├── index.md - content for index page
├── make.bat - building script for Windows
├── Makefile - building script for Unix
├── README.md
└── requirements.txt - requirement python packages for Read the Docs building
```

## ⚙️ Build docs locally

**Step 1**. Install requirement packages (from root folder): `pip install -r docs/requirement.txt`;

**Step 2**. Run the building script:
note that `docs` is the extra requirement for the documentation.

- **Windows**: run `make.bat`;
- **Linux/macOS**: run `make html`;

The generated docs will be under the `_build` folder. You can open `docs/build/html/index.html` in your browser to check the docs.
2. To build the documentation, run:

We need to have LaTeX installed for rendering math equations. You can for example install TeXLive with the necessary extras by doing one of the following:

- **Windows/macOS**: check the [Tex Live install guide](https://www.tug.org/texlive/windows.html) for Windows/macOS;
- **Ubuntu (Linux)**: run `sudo apt-get update && sudo apt-get install -y texlive-latex-extra dvipng texlive-pictures`;
- Use the [RTD docker image](https://hub.docker.com/r/readthedocs/build);

## ⚙️ Build in Read the Docs

In the root of this repository, there is `.readthedocs.yaml` which will be loaded by the Read the Docs to build the docs. Please refer to the [configuration file v2 guide from Read the Docs](https://docs.readthedocs.io/en/stable/config-file/v2.html) for details information of variables.

## 💡 Notes for contents
<details>
<summary>Markdown and RST support</summary>
RST is originally supported by the Sphinx. With the extension `myst_parser` it can support Markdown contents. Follow [this guide](https://www.sphinx-doc.org/en/master/usage/markdown.html) to learn more.

In the meantime, we can still use RST within Markdown files by
````
```{eval-rst}
RST CONTENTS
```
````
</details>
<details>
<summary>Jupyter notebook support</summary>
With the extension `nbsphinx`, Sphinx can support Jupyter notebook. Follow [this guide](https://docs.readthedocs.io/en/stable/guides/jupyter.html) to learn more.

Indexing a Jupyter notebook is the same with a Markdown file in RST:
```
.. toctree::
:maxdepth: 2
:caption: Getting started:
_content/start/installation
_content/start/quickstart_notebook
```
</details>
<details>
<summary>API docs auto generator</summary>
With Sphinx's `automodule` we can easily get the API docs:
```
.. automodule:: rl4co.data.generate_data
:members:
:undoc-members:
```bash
mkdocs serve
```
When deploy in Read the Docs, make sure putting the package to `requirement.txt` mentioned before.
</details>

## 📚 References
### Hooks

We base the above guide on the official [PyTorch Lightning Docs](https://github.com/Lightning-AI/lightning/tree/master/docs).
We are using the [hooks.py](hooks.py) for additional modifications. MkDocs for instance cannot detect files that are not in the same directory as an `__init__.py` (as described [here](https://stackoverflow.com/questions/75232397/mkdocs-unable-to-find-modules)) so we are automatically creating and deleting such files with our script
9 changes: 0 additions & 9 deletions docs/_content/api/algos/a2c.md

This file was deleted.

9 changes: 0 additions & 9 deletions docs/_content/api/algos/base.md

This file was deleted.

11 changes: 0 additions & 11 deletions docs/_content/api/algos/ppo.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/_content/api/algos/reinforce.md

This file was deleted.

33 changes: 0 additions & 33 deletions docs/_content/api/data.md

This file was deleted.

7 changes: 0 additions & 7 deletions docs/_content/api/decoding.md

This file was deleted.

30 changes: 0 additions & 30 deletions docs/_content/api/envs/eda.md

This file was deleted.

Loading

0 comments on commit ff9ad71

Please sign in to comment.