GithubHelp home page GithubHelp logo

travelling-salesman-problem's Introduction

Travelling Salesman Problem TSP

This project implements one way to solve the TSP for 32 cities without coming back to the start (Hamiltonian Path), which is an old problem about computing the shortest path for visiting all cities in a list without repeating any city.

The difficulty of the problem remains in the time of execution of this NP-Hard problem which is O(n!) and it gets not feasible with a brute force attack already for 20 cities.

There are solutions for best paths like:

Dynamic Programing O(n^2 * 2^n)

Branch and Bound (solves problems with 40 to 60 cities)

In this project the problem has been solved not with an exact solution, but with a faster computation based on the closest point to each city. This implementation in general returns a path 25% longer than the shortest path.

In this project are applied SOLID principles.

To add to this project remains: Exact solution with Branch and Bound Acceptance test which gives feedback about solve.php script with the real data.

Requirements

PHP 7.0

Composer

How to install

git clone https://github.com/befern/travelling-salesman-problem
composer install

Build Status

Build Status

Run solver

In the project root:

php solve.php

Run tests

In the project root:

vendor/bin/phpunit

References

travelling-salesman-problem's People

Watchers

James Cloos avatar

travelling-salesman-problem's Issues

Very bad results

Hello.
Tested your implementation of TCP algorithm.
It gives very bad results.
For example when we have usa map good result is 2578.
Your result is - 9086

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.