Code Monkey home page Code Monkey logo

chaitjo / graph-convnet-tsp Goto Github PK

View Code? Open in Web Editor NEW
280.0 5.0 62.0 1.67 MB

Code for the paper 'An Efficient Graph Convolutional Network Technique for the Travelling Salesman Problem' (INFORMS Annual Meeting Session 2019)

Home Page: https://arxiv.org/abs/1906.01227

License: MIT License

Python 54.75% Jupyter Notebook 45.25%
deep-learning combinatorial-optimization travelling-salesman-problem pytorch geometric-deep-learning graph-neural-networks

graph-convnet-tsp's People

Contributors

chaitjo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

graph-convnet-tsp's Issues

Train for 500 nodes

I tried to train for 500 nodes. GPU is running out of memory (CUDA out of memory). Did you try with 500 nodes ? If yes, did you do anything to solve this ?

a question about data format in google_tsp_reader

hi,i have a question about data format, grateful for answer
in utils/google_tsp_reader.py at line: 83

tour_nodes = [int(node) - 1 for node in line[line.index('output') + 1:-1]][:-1]

if raw data is ['1', '9', '3', '2', '8', '7', '6', '4', '5', '10']
then we got [0, 8, 2, 1, 7, 6, 5, 3, 4],

i notice that comment "Don't add final connection for tour/cycle"

so do you mean that don't connect for '10' to '1' for the example?

why we drop the node '10'?

I can not install concorde solver on my system.

i use ubount18.04, according to your method ,the erro is :

ERROR: Command errored out with exit status 1:
command: /home/xiong/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/graph-convnet-tsp/data/pyconcorde/setup.py'"'"'; file='"'"'/home/graph-convnet-tsp/data/pyconcorde/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' develop --no-deps
cwd: /home/graph-convnet-tsp/data/pyconcorde/
Complete output (242 lines):
running develop
running egg_info
writing pyconcorde.egg-info/PKG-INFO
writing dependency_links to pyconcorde.egg-info/dependency_links.txt
writing requirements to pyconcorde.egg-info/requires.txt
writing top-level names to pyconcorde.egg-info/top_level.txt
reading manifest file 'pyconcorde.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pyconcorde.egg-info/SOURCES.txt'
running build_ext
./concorde/
./concorde/Makefile.in
./concorde/configure.in
./concorde/configure
./concorde/aclocal.m4
./concorde/config.guess
./concorde/config.sub
./concorde/install-sh
./concorde/BIGGUY/
./concorde/BIGGUY/bg_test.c
./concorde/BIGGUY/bigguy.c
./concorde/BIGGUY/bigguy.tst
./concorde/BIGGUY/Makefile.in
./concorde/COMBS/
./concorde/COMBS/block.c
./concorde/COMBS/co_main.c
./concorde/COMBS/dngreedy.c
./concorde/COMBS/Makefile.in
./concorde/CUT/
./concorde/CUT/connect.c
./concorde/CUT/cut_st.c
./concorde/CUT/gomoryhu.c
./concorde/CUT/lin_all.c
./concorde/CUT/mc_main.c
./concorde/CUT/mincut.c
./concorde/CUT/segments.c
./concorde/CUT/shrink.c
./concorde/CUT/Makefile.in
./concorde/EDGEGEN/
./concorde/EDGEGEN/delaunay.c
./concorde/EDGEGEN/edgegen.c
./concorde/EDGEGEN/eg_main.c
./concorde/EDGEGEN/mlinkern.c
./concorde/EDGEGEN/xnear.c
./concorde/EDGEGEN/Makefile.in
./concorde/FMATCH/
./concorde/FMATCH/fmatch.c
./concorde/FMATCH/fm_main.c
./concorde/FMATCH/Makefile.in
./concorde/HELDKARP/
./concorde/HELDKARP/heldkarp.c
./concorde/HELDKARP/hk_main.c
./concorde/HELDKARP/Makefile.in
./concorde/INCLUDE/
./concorde/INCLUDE/bigguy.h
./concorde/INCLUDE/combs.h
./concorde/INCLUDE/consec1.h
./concorde/INCLUDE/cut.h
./concorde/INCLUDE/cuttree.h
./concorde/INCLUDE/delaunay.h
./concorde/INCLUDE/edgegen.h
./concorde/INCLUDE/fmatch.h
./concorde/INCLUDE/heldkarp.h
./concorde/INCLUDE/kdtree.h
./concorde/INCLUDE/linkern.h
./concorde/INCLUDE/localcut.h
./concorde/INCLUDE/lp.h
./concorde/INCLUDE/machdefs.h
./concorde/INCLUDE/macrorus.h
./concorde/INCLUDE/mlinkern.h
./concorde/INCLUDE/necklace.h
./concorde/INCLUDE/pq.h
./concorde/INCLUDE/pqsets.h
./concorde/INCLUDE/tinytsp.h
./concorde/INCLUDE/tsp.h
./concorde/INCLUDE/util.h
./concorde/INCLUDE/verify.h
./concorde/INCLUDE/Makefile.common.in
./concorde/INCLUDE/config.h.in
./concorde/KDTREE/
./concorde/KDTREE/kdbuild.c
./concorde/KDTREE/kd_main.c
./concorde/KDTREE/kdnear.c
./concorde/KDTREE/kdspan.c
./concorde/KDTREE/kdtwoopt.c
./concorde/KDTREE/Makefile.in
./concorde/LINKERN/
./concorde/LINKERN/flip_two.c
./concorde/LINKERN/linkern.c
./concorde/LINKERN/linkern_fixed.c
./concorde/LINKERN/linkern_path.c
./concorde/LINKERN/lk_main.c
./concorde/LINKERN/testpath.c
./concorde/LINKERN/Makefile.in
./concorde/LOCALCUT/
./concorde/LOCALCUT/checker.c
./concorde/LOCALCUT/chunks.c
./concorde/LOCALCUT/first.c
./concorde/LOCALCUT/first_main.c
./concorde/LOCALCUT/intmat.c
./concorde/LOCALCUT/lift.c
./concorde/LOCALCUT/localcut.c
./concorde/LOCALCUT/loc_main.c
./concorde/LOCALCUT/peeler2.c
./concorde/LOCALCUT/peeler.c
./concorde/LOCALCUT/separate.c
./concorde/LOCALCUT/tsporacl.c
./concorde/LOCALCUT/Makefile.in
./concorde/LP/
./concorde/LP/lpcplex4.c
./concorde/LP/lpcplex5.c
./concorde/LP/lpcplex6.c
./concorde/LP/lpcplex8.c
./concorde/LP/lpnone.c
./concorde/LP/lpqsopt.c
./concorde/LP/Makefile.in
./concorde/PQ/
./concorde/PQ/consec1.c
./concorde/PQ/cuttree.c
./concorde/PQ/necklace.c
./concorde/PQ/pq.c
./concorde/PQ/pqtest.c
./concorde/PQ/Makefile.in
./concorde/TINY/
./concorde/TINY/bnbmsp.c
./concorde/TINY/tinytsp.c
./concorde/TINY/tt_main.c
./concorde/TINY/randtsp.awk
./concorde/TINY/Makefile.in
./concorde/TOOLS/
./concorde/TOOLS/edg2len.c
./concorde/TOOLS/edgunion.c
./concorde/TOOLS/fconvert.c
./concorde/TOOLS/junk.c
./concorde/TOOLS/killgrun.c
./concorde/TOOLS/lkhalone.c
./concorde/TOOLS/lkhboss.c
./concorde/TOOLS/lkhgrunt.c
./concorde/TOOLS/prob2tsp.c
./concorde/TOOLS/showres.c
./concorde/TOOLS/subby.c
./concorde/TOOLS/tdivide.c
./concorde/TOOLS/tour2edg.c
./concorde/TOOLS/tourchk.c
./concorde/TOOLS/tourlen.c
./concorde/TOOLS/ttour.c
./concorde/TOOLS/Makefile.in
./concorde/TSP/
./concorde/TSP/bcontrol.c
./concorde/TSP/blkcomb.c
./concorde/TSP/blossom.c
./concorde/TSP/bosstell.c
./concorde/TSP/branch.c
./concorde/TSP/cliqhash.c
./concorde/TSP/cliqwork.c
./concorde/TSP/combcliq.c
./concorde/TSP/concorde.c
./concorde/TSP/control.c
./concorde/TSP/cutcall.c
./concorde/TSP/cutpool.c
./concorde/TSP/cutserv.c
./concorde/TSP/ddecker.c
./concorde/TSP/domboss.c
./concorde/TSP/domgrunt.c
./concorde/TSP/domtest.c
./concorde/TSP/ex_price.c
./concorde/TSP/generate.c
./concorde/TSP/growcomb.c
./concorde/TSP/poolcat.c
./concorde/TSP/prclique.c
./concorde/TSP/prob_io.c
./concorde/TSP/probserv.c
./concorde/TSP/qsparse.c
./concorde/TSP/skeleton.c
./concorde/TSP/subboss.c
./concorde/TSP/subgate.c
./concorde/TSP/subgrunt.c
./concorde/TSP/teething.c
./concorde/TSP/test_tsp.c
./concorde/TSP/tighten.c
./concorde/TSP/tsp_call.c
./concorde/TSP/tsp_lp.c
./concorde/TSP/xtour.c
./concorde/TSP/Makefile.in
./concorde/UTIL/
./concorde/UTIL/allocrus.c
./concorde/UTIL/bgetopt.c
./concorde/UTIL/dheaps_i.c
./concorde/UTIL/edgelen.c
./concorde/UTIL/edgemap.c
./concorde/UTIL/edgeutil.c
./concorde/UTIL/eunion.c
./concorde/UTIL/fastread.c
./concorde/UTIL/genhash.c
./concorde/UTIL/getdata.c
./concorde/UTIL/priority.c
./concorde/UTIL/safe_io.c
./concorde/UTIL/signal.c
./concorde/UTIL/sortrus.c
./concorde/UTIL/subdiv.c
./concorde/UTIL/urandom.c
./concorde/UTIL/util.c
./concorde/UTIL/zeit.c
./concorde/UTIL/Makefile.in
./concorde/VERIFY/
./concorde/VERIFY/verify.c
./concorde/VERIFY/ver_main.c
./concorde/VERIFY/verlist.tst
./concorde/VERIFY/Makefile.in
./concorde/README
loading cache ./config.cache
checking host system type... configure: error: can not guess host type; you must specify one
Traceback (most recent call last):
File "", line 1, in
File "/home/graph-convnet-tsp/data/pyconcorde/setup.py", line 174, in
'build_ext': build_ext,
File "/home/xiong/anaconda3/lib/python3.6/site-packages/setuptools/init.py", line 144, in setup
return distutils.core.setup(**attrs)
File "/home/xiong/anaconda3/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/xiong/anaconda3/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/xiong/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/xiong/anaconda3/lib/python3.6/site-packages/setuptools/command/develop.py", line 38, in run
self.install_for_development()
File "/home/xiong/anaconda3/lib/python3.6/site-packages/setuptools/command/develop.py", line 140, in install_for_development
self.run_command('build_ext')
File "/home/xiong/anaconda3/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/xiong/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/graph-convnet-tsp/data/pyconcorde/setup.py", line 115, in run
build_concorde()
File "/home/graph-convnet-tsp/data/pyconcorde/setup.py", line 99, in build_concorde
_run(cwd, "build/concorde")
File "/home/graph-convnet-tsp/data/pyconcorde/setup.py", line 76, in _run
subprocess.check_call(cmd, shell=True, cwd=cwd)
File "/home/xiong/anaconda3/lib/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'CFLAGS="-fPIC -O2 -g" ./configure --prefix /home/graph-convnet-tsp/data/pyconcorde/data --with-qsopt=/home/graph-convnet-tsp/data/pyconcorde/data ' returned non-zero exit status 1.
building concorde
----------------------------------------
ERROR: Command errored out with exit status 1: /home/xiong/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/graph-convnet-tsp/data/pyconcorde/setup.py'"'"'; file='"'"'/home/graph-convnet-tsp/data/pyconcorde/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

Error in beamsearch.py

Hi,

I am getting the following error on line 96 in file Utils/beamsearch.py
On this line
self.mask = self.mask.gather(1, perm_mask)

Error is

gather_out_gpu(): expected dtype int64 for index

The issue is that perm_mask is having float values but torch.gather expects integer in the index argument

Could you please help me on this.

I used the same libraries with the version numbers recommended in the readme.

I am running for tsp10.

Node and edge feature aggreation w.r.t connectivity

Hi Chaitanya,

Recently I have been studying your paper ''An Efficient Graph Convolutional Network Technique for the Travelling Salesman Problem'', and tried to understand your proposed GCN model. However I have some questions to discuss with you.

In gcn_layers.py function NodeFeatures and EdgeFeatures, I found that the features of nodes and edges are aggregated as in a fully connected graph, i.e., for every node, any other nodes are all its neighbours. I think this is because in TSP context, you set the state as a fully connected graph. Am I correct?

Further more, if in other domains, such as chemistry, where graph is not fully connected, is there any model for aggregation based on connectivity been implemented, i.e. only neighburs of V will be aggregated together?

runerror

image
when I try to run this code, but it makes errors like this, how to fix it? I just want to train it in my mac and then test the model. thanks. So how should I change the code for support it run in my macbook

Question: Testing the model on TSPLIB example

Hi,

Thanks for sharing your code. I was wondering how can I test the trained model on a single example from TSPLIB dataset (file with an extension .tsp rather than .txt).

Thanks

-Sara

A code issue

hi, thanks for your open-source code. I met a bug when I run the beam search code in utilis/beamsearch.py line96:
self.mask = self.mask.gather(1, perm_mask)
where 'perm_mask' should be a LongTensor type, but here its type is FloatTensor. It makes severl beam search-based functions fail to use.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.