piotrdurniat / tsp-held-karp

Implementation of the Held-Karp algorithm for solving the Travelling Salesman Problem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Held-Karp Algorithm for Solving the Travelling Salesman Problem

This project is a C++ implementation of the Held-Karp algorithm for solving the Travelling Salesman Problem (TSP). The TSP is an optimization problem of finding the minimum Hamiltonian cycle in a complete weighted graph.

Build the project

Run:

make

Define the algorithm settings:

  • To change the algorithm settings, edit the settings.ini file.
  • The settings file defines basic parameters of the algorithm as well as the instances which will be used by the algorithm.
  • Example instance files are located in the instances directory
  • Instance files define the graphs on which the algorithm will be called. They can have two extensions:
    • .tsp for undirected graphs (e.g. gr17.tsp)
    • .atsp for directed graphs (e.g. m6.atsp)

Run the algorithm:

Run:

./bin/main

The results will be saved as .csv files in the directory specified in the settings.ini file.

Filtering out 'outliers' from the results

You can remove outlying results by running the rm_outlier.py script. (files from which outliers should be removed are wonderfully hard-coded in the script)

python3 rm_outliers

Measure RAM usage over time:

valgrind --tool=massif ./bin/main

Get max RAM usage

Read "Maximum resident set size (kbytes)" value from:

/usr/bin/time -v ./bin/main

About

Implementation of the Held-Karp algorithm for solving the Travelling Salesman Problem

License:MIT License


Languages

Language:C++ 84.9%Language:C 13.9%Language:Python 1.0%Language:Makefile 0.2%