</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> <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://yellow-cdn.veclightyear.com/0a4dffa0/12661fe3-3d57-4958-9fec-270778b32cb6.svg"></a> <a href="https://join.slack.com/t/rl4co/shared_invite/zt-1ytz2c1v4-0IkQ8NQH4TRXIX8PrRmDhQ"><img alt="Slack" src="https://yellow-cdn.veclightyear.com/0a4dffa0/d7e0e7a4-7c16-4817-b836-d16341949b52.svg?logo=slack"></a> <a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://yellow-cdn.veclightyear.com/0a4dffa0/154af963-7089-4164-8be4-16e0cb7fc452.svg"></a> <a href="https://colab.research.google.com/github/ai4co/rl4co/blob/main/examples/1-quickstart.ipynb"><img src="https://yellow-cdn.veclightyear.com/0a4dffa0/1f30273e-8073-41ad-acba-3e9e63087c54.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://yellow-cdn.veclightyear.com/0a4dffa0/c8d0857d-a49e-4dcc-a6dd-e1fc4586b083.svg"></a> <a href="https://github.com/ai4co/rl4co/actions/workflows/tests.yml"><img alt="Test" src="https://yellow-cdn.veclightyear.com/0a4dffa0/6477875b-bc20-4a48-bf3e-4ad0f79a71e7.svg"></a>
<p> <a href="https://rl4co.readthedocs.io/"><strong>文档</strong></a> | <a href="#getting-started"><strong>开始使用</strong></a> | <a href="#usage"><strong>用法</strong></a> | <a href="#contributing"><strong>贡献</strong></a> | <a href="https://arxiv.org/abs/2306.17100"><strong>论文</strong></a> | <a href="#join-us"><strong>加入我们</strong></a> </p> </div>一个广泛的强化学习(RL)用于组合优化(CO)的基准。我们的目标是为基于RL的CO算法提供一个统一的框架,并促进该领域的可复现研究,将科学与工程解耦。
RL4CO建立在以下基础之上:
我们提供以下策略的灵活高效实现:
我们提供了几个实用工具和模块化组件。例如,我们将可重用组件(如_环境嵌入_)模块化,这些组件可以轻松交换以解决新问题。
<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><a href="https://colab.research.google.com/github/ai4co/rl4co/blob/main/examples/1-quickstart.ipynb"><img src="https://yellow-cdn.veclightyear.com/0a4dffa0/1f30273e-8073-41ad-acba-3e9e63087c54.svg" alt="在Colab中打开"></a>
RL4CO现在可以通过pip安装了!
pip install rl4co
为了开始使用,我们建议查看我们的快速入门笔记本或下面的最小化示例。
这个命令安装最新的main版本,对于保持最新开发很有用 - 例如,如果自上次官方发布以来修复了一个bug,但还没有推出新的发布版本:
pip install -U git+https://github.com/ai4co/rl4co.git
如果你想开发RL4CO,我们建议你使用pip以可编辑模式在本地安装:
git clone https://github.com/ai4co/rl4co && cd rl4co pip install -e .
我们建议使用虚拟环境(如conda)在本地安装rl4co。
使用默认配置训练模型(AM在TSP环境上):
python run.py
<details> <summary>更改实验设置</summary>[!提示] 你可以查看这个笔记本来开始使用Hydra!
使用从configs/experiment/选择的实验配置训练模型
python run.py experiment=routing/am env=tsp env.num_loc=50 model.optimizer_kwargs.lr=2e-4
在这里,你可以通过命令行更改环境,例如使用env=cvrp,或者通过修改相应的实验配置,例如configs/experiment/routing/am.yaml。
python run.py experiment=routing/am logger=none '~callbacks.learning_rate_monitor'
注意,~用于禁用需要日志记录器的回调。
</details>python run.py -m experiment=routing/am model.optimizer.lr=1e-3,1e-4,1e-5
这里是一个最小化示例,在不到30行代码内训练具有贪婪rollout基线的注意力模型在TSP上:
from rl4co.envs.routing import TSPEnv, TSPGenerator from rl4co.models import AttentionModelPolicy, POMO from rl4co.utils import RL4COTrainer # 实例化生成器和环境 generator = TSPGenerator(num_loc=50, loc_distribution="uniform") env = TSPEnv(generator) # 创建策略和强化学习模型 policy = AttentionModelPolicy(env_name=env.name, num_encoder_layers=6) model = POMO(env, policy, batch_size=64, optimizer_kwargs={"lr": 1e-4}) # 实例化训练器并拟合 trainer = RL4COTrainer(max_epochs=10, accelerator="gpu", precision="16-mixed") trainer.fit(model)
其他示例可以在文档中找到!
从根目录使用pytest运行测试:
pytest tests
通过Conda安装PyG似乎会更新Torch本身。我们发现这个更新会导致torchrl出现一些问题。目前,我们建议使用Pip安装PyG:
pip install torch_geometric
有建议、请求或发现了bug?欢迎提出问题或提交拉取请求。 如果您想贡献,请查看我们的贡献指南这里。我们欢迎并期待所有对RL4CO的贡献!
如果您有任何问题或想与我们讨论RL4CO,我们也在Slack上。我们欢迎合作,很乐意听到您的想法🚀
如果您发现RL4CO对您的研究或应用项目有价值:
@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é 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}} }
请注意,RL4CO的先前版本已被接受为NeurIPS 2023 GLFrontiers研讨会的口头报告。自那时以来,该库已经大大发展和改进!
我们邀请您加入我们的AI4CO社区,这是一个面向组合优化的人工智能开放研究小组!
<div align="center"> <img src="https://yellow-cdn.veclightyear.com/0a4dffa0/acea5bfe-dd94-47d4-a1fb-d7e6484aa05b.svg" alt="AI4CO标志" style="width: 30%; height: auto;"> </div>

AI赋能电商视觉革命,一站式智能商拍平台
潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。


企业专属的AI法律顾问
iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。


稳定高效的流量提升解决方案,助力品牌曝光
稳定高效的流量提升解决方案,助力品牌曝光


最新版Sora2模型免费使用,一键生成无水印视频
最新版Sora2模型免费使用,一键生成无水印视频


实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。


选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。


AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。


最强AI数据分析助手
小浣熊家族Raccoon,您的AI智能助手,致力于通过先进的人工智能技术,为用户提供高效、便捷的智能服务。无论是日常咨询还是专业问题解答,小浣熊都能以快速、准确的响应满足您的需求,让您的生活更加智能便捷。


像人一样思考的AI智能体
imini 是一款超级AI智能体,能根据人类指令,自主思考、自主完成、并且交付结果的AI智能体。


AI数字人视频创作平台
Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。
最新AI工具、AI资讯
独家AI资源、AI项目落地

微信扫一扫关注公众号