# GNN-MCTS-TSP
Implementation of "A Graph Neural Network Assisted Monte Carlo Tree Search Approach to Traveling Salesman Problem" (https://ieeexplore.ieee.org/document/9109309)
![overview](https://s1.ax1x.com/2020/06/29/NhmkH1.png)
# 1. Build
1. Get the source code, and install all the dependencies.
```bash
git clone --recursive https://github.com/snail-ju/GNN-MCTS-TSP.git
```
2. Build the pytorch with the instructions here,
~~~bash
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
~~~
3. Build the pytorch geometric with the instructions here,
https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
**When installing the pytorch geometric, please follow the instructions below,**
~~~bash
pip install torch-scatter==1.3.1
pip install torch-sparse==0.4.0
pip install torch-cluster==1.4.4
pip install torch-spline-conv==1.1.0
pip install torch-geometric==1.3.2
~~~
4. Build other dependencies including tqdm and tensorboardX.
# 2. Experiments on synthetic data
## Generate synthetic data
To generate the synthetic data for TSP, you can do with the instructions here:
1. Visit the website of the DIMACS Implementation Challenge (http://dimacs.rutgers.edu/archive/Challenges/TSP/download.html).
2. Download the instance generator in part “Benchmark Code and Instance Generation Codes” of the above website.
3. Execute the corresponding program to generate different types of instances. Note that the program will generate the data on the fly.
**We also provide codes in the “data-generator” director to generate instances, and the file format generated by codes is adapted to our program. Compile the code with the following instructions, **
~~~bash
cd data-generator
gcc portgen.c -o prorgen -lm
gcc portcgen.c -o prorgen -lm
~~~
## Training SE-GNN on synthetic data
Please modify the corresponding options in the "segnn/config.json" file.
Navigate to the segnn folder and train the SE-GNN with the following instructions,
```bash
cd segnn
python train.py -c config.json
```
By default it will save all the model files in "saved/models/SE-GNN", the logs under "saved/log/SE-GNN".
### Test the GNN-MCTS
Navigate to the gnn-mcts folder and run the evaluation script. Modify the script to change the parameters. Make sure the parameters are consistent with your training script.
```bash
cd gnn-mcts
./run.sh
```
The above script will load the 1000 test instances you generated before, and output the solution in some text files under the result folder.
# Reproducing the results that reported in the paper
Here is the link to the dataset that was used in the paper:
https://www.dropbox.com/sh/4o0tc5aoamat7hy/AABzIz-bOgSLp9_da5GQmjKGa?dl=0
# Reference
Please cite our work if you find our code/paper is useful to your work.
```markdown
@ARTICLE{9109309,
author={Z. {Xing} and S. {Tu}},
journal={IEEE Access},
title={A Graph Neural Network Assisted Monte Carlo Tree Search Approach to Traveling Salesman Problem},
year={2020},
volume={8},
number={},
pages={108418-108428},
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
TSP TS_最短路
共155个文件
pyc:61个
py:61个
txt:25个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 19 浏览量
2022-09-25
01:27:27
上传
评论
收藏 156KB ZIP 举报
温馨提示
求解旅行商问题 用了图神经网路 优化路径
资源推荐
资源详情
资源评论
收起资源包目录
TSP TS_最短路 (155个子文件)
portcgen.c 3KB
portgen.c 2KB
.flake8 88B
config.json 1019B
logger_config.json 869B
logger_config.json 869B
README.md 3KB
mcts_net.py 8KB
base_trainer.py 7KB
gcn.py 6KB
gcn.py 6KB
parse_config.py 6KB
tsp_env.py 5KB
trainer.py 4KB
parse_config.py 4KB
cgconv.py 4KB
cgconv.py 4KB
opt_paras.py 3KB
bfs.py 3KB
visualization.py 3KB
visualization.py 3KB
segnn_share.py 3KB
segnn_share.py 3KB
s2v.py 3KB
gen.py 3KB
generator.py 3KB
data_loaders.py 3KB
base_data_loader.py 3KB
segnn.py 3KB
train.py 2KB
segnn_x.py 2KB
segnn_x.py 2KB
static_env.py 2KB
segnn.py 2KB
policy.py 2KB
beam_width.py 2KB
gnn.py 2KB
segnn_sigma.py 2KB
segnn_sigma.py 2KB
basic_gnn.py 2KB
args.py 2KB
utils.py 2KB
insertion.py 2KB
simulator.py 2KB
agent.py 2KB
main.py 2KB
greedy.py 2KB
nnconv.py 2KB
nnconv.py 1KB
util.py 1KB
model.py 1KB
graph.py 1KB
graph.py 1KB
attention.py 984B
simulator.py 761B
logger.py 750B
logger.py 750B
base_model.py 649B
metric.py 560B
loss.py 102B
__init__.py 86B
__init__.py 50B
__init__.py 50B
__init__.py 23B
__init__.py 20B
__init__.py 0B
__init__.py 0B
__init__.py 0B
mcts_net.cpython-36.pyc 8KB
parse_config.cpython-36.pyc 6KB
parse_config.cpython-37.pyc 6KB
gcn.cpython-36.pyc 6KB
gcn.cpython-37.pyc 6KB
gcn.cpython-36.pyc 6KB
base_trainer.cpython-37.pyc 5KB
base_trainer.cpython-36.pyc 5KB
parse_config.cpython-36.pyc 4KB
trainer.cpython-37.pyc 4KB
trainer.cpython-36.pyc 4KB
data_loaders.cpython-37.pyc 4KB
data_loaders.cpython-36.pyc 4KB
tsp_env.cpython-36.pyc 3KB
policy.cpython-36.pyc 3KB
static_env.cpython-36.pyc 3KB
generator.cpython-37.pyc 3KB
base_data_loader.cpython-37.pyc 3KB
base_data_loader.cpython-36.pyc 3KB
generator.cpython-36.pyc 3KB
utils.cpython-36.pyc 2KB
visualization.cpython-36.pyc 2KB
visualization.cpython-37.pyc 2KB
visualization.cpython-36.pyc 2KB
segnn.cpython-36.pyc 2KB
util.cpython-37.pyc 2KB
util.cpython-36.pyc 2KB
simulator.cpython-37.pyc 2KB
simulator.cpython-36.pyc 2KB
graph.cpython-36.pyc 2KB
agent.cpython-36.pyc 2KB
args.cpython-36.pyc 2KB
共 155 条
- 1
- 2
资源评论
weixin_42653672
- 粉丝: 93
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功