Obtaining a TSP solver

From Evil Mad Scientist Wiki
Jump to: navigation, search

<<< Introduction (TSP Art) || Obtaining a TSP solver || Producing a stippled image with GImp >>>


To generate TSP art, a TSP solver is needed. However, generating TSP solutions with a TSP solver takes a lot of computer time. An image stippled to a thousand points may take several hours to solve the Travelling Salesman Problem for. Consequently, it is preferred to use a fast, approximate TSP solver instead. The Concorde TSP solver package includes both a TSP solver as well as some fast, approximate solvers. Of chief interest is the "linkern" solver which can produce satisfactory solutions in under a minute.

Binaries for linkern for Red Hat Linux 8.0, Solaris SPARC, and Windows (with Cygwin installed) are available at

Concorde TSP downloads

Concorde TSP on Windows[edit]

For Windows, Concorde TSP requires a minimal Cygwin install. Cygwin is a collection of packages for Windows which provide elements of Unix. In this case, Concorde TSP needs some (dynamic) libraries in order to run correctly on Windows. To acquire a minimal Cygwin install, go to the Cygwin home page,

Cygwin home page

and download the latest Cygwin setup.exe. Launch setup.exe and do not select or de-select any additional packages: the minimal set is selected upon startup of setup.exe. Allow the program to run which will download, install, and configure the Cygwin environment.

After the Cygwin install has completed, you should be able to open up a command window (DOS window) and manually run the linkern.exe executable you downloaded from the Concorde TSP downloads site. To open a command window on Windows XP, select the "Run..." item from the "Start" menu,


In the pop-up window, type "cmd.exe" and then click the "OK" button,


You should then see a command window appear. In that window, enter the full directory path to the linkern executable and press return. The executable should run and display its command line options. In the following figure, it is assumed that the executable is in the top-level directory of the C: drive,


Concorde TSP on Macs[edit]

Concorde TSP is not available pre-built for Macs. However, if you are familiar with obtaining and building sources on your Mac, then building a copy of Concorde TSP is relatively straightforward. You will need a C compiler and other build tools. Apple's Xcode Developer Toolkit for OS X provides everything you will need. That toolkit is available for download from Apple. For on-line download, a registration is required and you will want the Xcode for "Mac Dev Center", not the "IOS Dev Center". The Xcode toolkit is often also included with your OS X distribution DVD as an extra package which you can manually install.

To build Concorde TSP, first obtain the sources from the Concorde TSP downloads page cited in the Introduction above. You will also want the QSopt Linear Programming (LP) solver library and header file (qsopt.a and qsopt.h) from

QSopt LP downloads

When obtaining the QSopt libraries, use the library files labelled as "OS X 10.5" for 32bit builds; the OS X 10.6 files are 64bit libraries. To configure Concorde TSP for building, use the following commands (assuming the Bash shell)

% cd <directory with concorde sources>
% export QSOPTDIR=<full, absolute directory path to the directory with qsopt.a and qsopt.h>
% CFLAGS="-g -O3 -m32" ./configure --with-qsopt=$QSOPTDIR --host=darwin

You must specify a complete, absolute directory path for the directory containing the QSopt files as failure to do so will result in a build failure. Also, ignore the "checking host system warning" generated by the configuration script: you have to specify the --host switch, but there's no acceptable value on a Mac for the script. Once the script finishes running, build the package with the "make" command. There is no install target for the makefile. The Concorde TSP solver will be the file ./TSP/concorde. The linkern executable, ./LINKERN/linkern

A shell script for obtaining, building, and installing the sources is available at the Eggbot code site,


As the script builds in the /usr/local/ directory tree, it needs to be run with root privileges. To build and install Concorde TSP elsewhere, edit the script changing the SRCDIR and BINDIR variables.

Concorde TSP on Linux[edit]

Not much to worry about here: just obtain the binaries as per the Introduction above. If you wish to build the binaries yourself, the OS X shell script cited in the Mac section should be a good starting point. You'll want to omit the -m32 compiler switch and consider specifying a recognized value for the --host switch.

<<< Introduction (TSP Art) || Obtaining a TSP solver || Producing a stippled image with GImp >>>