GithubHelp home page GithubHelp logo

trg1984 / tsp-solver Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 256 KB

TSP Solver for TSPlib files using 2-opt, nearest neighbour and double tree algorithm

License: MIT License

JavaScript 99.55% CSS 0.45%

tsp-solver's Introduction

Industrial Algorithms Exercise Project

This project is part of my participation on a course called Industrial Algorithms in University of Turku. It loads TSPLib's TSP and TOUR files, visualizes the data, and searches for an optimal solution for traveling salesman problem within the loaded data set. Contains implementations for some of the basic local search methods:

  • 2-opt ('2-opt')
  • Nearest neighbour ('nn')
  • Double tree algorithm ('doubletree')

As a byproduct of implementing these methods, the solver calculates the minimal spanning tree (MST) for the given complete graph.

Usage

Load one of the TSPLib TSP files to your local hard drive. The exercise project was required to work only with pcb442.tsp and fi10639.tsp, but any TSPLib file that uses EUC_2D, ATT or GEO metric should work (a big bunch of these were tested during the development).

Open index.html with your browser, and load the TSP file by clicking the "Browse.." button at the top of the page. Once the file is loaded a visualizer appears at the bottom of the page. Select the method used by the solver on the topmost box. Possible choices are '2-opt', 'nn' and 'doubletree'.

For 2-opt, there are are two additional boxes that allow the user to set the maximum amount of iterations as well as the maximum number of iterations that the search continues without improvement.

In order to visually check that the MST builder works as intended, the "Solve MST" button will solve and display the MST for the loaded data set. This takes may take a while, though. My old laptop ran the fi10639.tsp's MST for a little over four minutes. Smaller data sets (< 1000) are done in a blink of an eye.

If needed, a precreated tour can be loaded in TSPLib's TOUR format either to provide a starting point or a comparison / optimum for the data set, using the same "Browse.." dialog.

Live demo

Licence

Released under MIT licence. Do what you want with it. I did this for the ects and fun of it :)

TODO

  • The UI is not done. Finalize the look and feel of the program.
  • Add more local search methods.
  • WebWorker and Node support to allow parallel setups and to avoid UI hangs.
  • TSPLib export for both data sets and tours.
  • In-app point set creation.
  • MATRIX and CEIL_2D metrics.

tsp-solver's People

Stargazers

 avatar Abdullah Rafi avatar Seventh7th_Son avatar George Lima avatar

Watchers

James Cloos avatar Rolf Lindén avatar

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.