Skip to content

Spider-scnu/TSP

Repository files navigation

Generalize a Small Pre-trained Model to Arbitrarily Large TSP Instances

This reposity is the source code for solving the Traveling Salesman Problems (TSP) using Monte Carlo tree search (MCTS) assisted by Graph Convolutional Network with attention mechanism (Att-GraphConvNet).

Paper

  • If you want to get more details, please see our paper "Generalize a Small Pre-trained Model to Arbitrarily Large TSP Instances" by Zhang-Hua Fu (1,2), Kai-Bin Qiu (2) and Hongyuan Zha (1,2), which is accepted by AAAI2021. In addition, our full version has been submitted in this reposity.

    1 Shenzhen Institute of Artificial Intelligence and Robotics for Society, Shenzhen, China

    2 The Chinese University of Hong Kong, Shenzhen, China

Dependencies

  • Needed libraries for the Python programming language:
    • pytorch == 1.0.1.post2
    • tensorboardX
    • tensorboard
    • numpy
    • pandas
    • scikit-learn
    • multiprocessing
    • matplotlib
    • seaborn
    • scipy
    • pyconcorde
  • gcc >= 4.8.5
  • CUDA = 8.0
  • Computing platform : Linux

Configuration

Duing to the limit of platform and hardware, if you fail to build the environment of GPU, you could choose the CPU version of MCTS programs. We would finish the Readme.md of MCTS-CPUver as soon as possible!!!

  • If you want to run our MCTS programs, you need to install CUDA-8.0.

  • After install CUDA-8.0, we need to configure its environment variables, which follow the steps bellow:

    • First, add environment variables in .bashrc

      • gedit ~/.bashrc
    • then add the following two lines of statements at the end of the file which is opened above:

      • export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
      • export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    • Secondly, set environment variables and dynamic link library

      • sudo gedit /etc/profile
    • then add the following statement at the end:

      • export PATH=/usr/local/cuda/bin:$PATH
    • After that, create link file

      • sudo gedit /etc/ld.so.conf.d/cuda.conf
    • then add the following statement:

      • /usr/local/cuda/lib64
    • Finally, run the command to make the file work:

      • sudo ldconfig

Dataset

Usage

Our method is made up of Att-GraphConvNet and MCTS. In our paper, Att-GraphConvNet is used to generate probabilistic heat maps which assist MCTS to solve TSP.

  • First, you can run train-20.ipynb to train Att-GraphConvNet based on TSP-20-trainset. If want to train models based on your own dataset, you just need to modify the path of dataset in ./Att-GraphConvNet/configs/tsp20.json. By the way, you can run test-20-50-100.ipynb to generate heat maps for TSP20 using trained models which are released on TSP-models-downloading-link. Heat map files would be stored in directory ./Att-GraphConvNet/results/heatmap/tsp20.
  • After generating heat maps, you can solve TSP instances with 20 nodes using MCTS with single GPU:
cd $download-dir 
cp -r $testset-dir ./MCTS/tsp-20-50-100
cp -r ./Att-GraphConvNet/results/heatmap/tsp20 ./MCTS/tsp-20-50-100/heatmap
cd ./MCTS/tsp-20-50-100
bash generate_lib.sh
bash solve-20.sh

Acknowledgements

Reference

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published