1 Star 2 Fork 1

QingMuSang / VRP_DRL_MHA

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

CVRP solver with Multi-Head Attention

TensorFlow2 and PyTorch implementation of ATTENTION, LEARN TO SOLVE ROUTING PROBLEMS!(Kool et al. 2019)(https://arxiv.org/pdf/1803.08475.pdf)

Description

Slide Share -- CVRP solver with Multi Heads Attention --

Dependencies

  • Python >= 3.6
  • TensorFlow >= 2.0
  • PyTorch = 1.5
  • tqdm
  • scipy
  • numpy
  • plotly (only for plotting)
  • matplotlib (only for plotting)

Usage

First move to PyTorch or TensorFlow2 dir.

cd PyTorch

Then, generate the pickle file contaning hyperparameter values by running the following command.

python config.py

you would see the pickle file in Pkl dir. now you can start training the model.

python train.py -p Pkl/***.pkl

Plot prediction of the pretrained model (in this example, batch size is 128, number of customer nodes is 50)

python plot.py -p Weights/***.pt(or ***.h5) -b 128 -n 50

You can change plot.py into plot_2opt.py.

2opt is a local search method, which improves a crossed route by swapping arcs.

If you want to verify your model, you can use opensource dataset in OpenData dir.

Opensource data is obtained from Augerat et al.(1995)

please refer to Capacitated VRP Instances by NEO Research Group

python plot.py -p Weights/***.pt -t ../OpenData/A-n***.txt -b 128

One example would be cd PyTorch && python plot.py -p Weights/VRP50_train_epoch19.pt -t ../OpenData/A-n45-k7.txt -d sampling -b 128

Reference

MIT License Copyright (c) 2020 Rintarooo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

PyTorch1.6, TensorFlow2, "Attention, Learn to Solve Routing Problems!", Transformer, Multi-Head Attention, Deep RL(REINFORCE with Rollout baseline), Capacitated Vehicle Routing Problem 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/QingMuSang/VRP_DRL_MHA.git
git@gitee.com:QingMuSang/VRP_DRL_MHA.git
QingMuSang
VRP_DRL_MHA
VRP_DRL_MHA
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891