Giter VIP home page Giter VIP logo

tsp's Introduction

TSP

Traveling Sales Person (TSP) problem.

An effort to solve TSP using "graph theory" and "geometry" in "SDL2" C graphics library.

Call "./tspN.sh" from code directory in terminal to compile and run the code.

Some examples:

France_8:

France_8 France_8_solution

Random_50:

Random_50 Random_50_solution

Random_75:

Random_75 Random_75_solution

Random_200:

Random_200 Random_200_solution

Still there seems to be room for improvements.

tsp's People

Contributors

lazy-dude avatar

Watchers

 avatar

tsp's Issues

search and related issue

Explaining the search problem more , these are some states that are just repeated:

======
si is 0 , dist is 0.0 step is 0
0 : 5,2,1,-,-,-,-,-,-,-,
1 : 3,2,0,-,-,-,-,-,-,-,
2 : 4,1,0,-,-,-,-,-,-,-,
3 : 7,4,1,-,-,-,-,-,-,-,
4 : 7,3,2,-,-,-,-,-,-,-,
5 : 6,0,-,-,-,-,-,-,-,-,
6 : 7,5,-,-,-,-,-,-,-,-,
7 : 6,4,3,-,-,-,-,-,-,-,
......
0 - - - - - - - - 
======
si is 1 , dist is 303.0 step is 1
0 : -,2,1,-,-,-,-,-,-,-,
1 : 3,2,0,-,-,-,-,-,-,-,
2 : 4,1,0,-,-,-,-,-,-,-,
3 : 7,4,1,-,-,-,-,-,-,-,
4 : 7,3,2,-,-,-,-,-,-,-,
5 : 6,0,-,-,-,-,-,-,-,-,
6 : 7,-,-,-,-,-,-,-,-,-,
7 : 6,4,3,-,-,-,-,-,-,-,
......
0 5 - - - - - - - 
======
si is 2 , dist is 410.6 step is 2
0 : -,2,1,-,-,-,-,-,-,-,
1 : 3,2,0,-,-,-,-,-,-,-,
2 : 4,1,0,-,-,-,-,-,-,-,
3 : 7,4,1,-,-,-,-,-,-,-,
4 : 7,3,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : 7,-,-,-,-,-,-,-,-,-,
7 : -,4,3,-,-,-,-,-,-,-,
......
0 5 6 - - - - - - 
======
si is 3 , dist is 568.1 step is 3
0 : -,2,1,-,-,-,-,-,-,-,
1 : 3,2,0,-,-,-,-,-,-,-,
2 : 4,1,0,-,-,-,-,-,-,-,
3 : -,4,1,-,-,-,-,-,-,-,
4 : -,3,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,4,3,-,-,-,-,-,-,-,
......
0 5 6 7 - - - - - 
======
si is 4 , dist is 1131.9 step is 4
0 : -,2,1,-,-,-,-,-,-,-,
1 : 3,2,0,-,-,-,-,-,-,-,
2 : -,1,0,-,-,-,-,-,-,-,
3 : -,-,1,-,-,-,-,-,-,-,
4 : -,3,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,-,3,-,-,-,-,-,-,-,
......
0 5 6 7 4 - - - - 
======
si is 5 , dist is 1294.7 step is 5
0 : -,2,1,-,-,-,-,-,-,-,
1 : -,2,0,-,-,-,-,-,-,-,
2 : -,1,0,-,-,-,-,-,-,-,
3 : -,-,1,-,-,-,-,-,-,-,
4 : -,-,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,-,-,-,-,-,-,-,-,-,
......
0 5 6 7 4 3 - - - 
======
si is 5 , dist is 1294.7 step is 5
0 : -,2,1,-,-,-,-,-,-,-,
1 : -,2,0,-,-,-,-,-,-,-,
2 : -,1,0,-,-,-,-,-,-,-,
3 : -,-,1,-,-,-,-,-,-,-,
4 : -,-,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,-,-,-,-,-,-,-,-,-,
......
0 5 6 7 4 3 - - - 
 #$#$#$ 
======
si is 0 , dist is 1294.7 step is 5
0 : -,2,1,-,-,-,-,-,-,-,
1 : -,2,0,-,-,-,-,-,-,-,
2 : -,1,0,-,-,-,-,-,-,-,
3 : -,-,1,-,-,-,-,-,-,-,
4 : -,-,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,-,-,-,-,-,-,-,-,-,
......
0 5 6 7 4 3 - - - 
 #$#$#$ 
======
si is 0 , dist is 1294.7 step is 5
0 : -,2,1,-,-,-,-,-,-,-,
1 : -,2,0,-,-,-,-,-,-,-,
2 : -,1,0,-,-,-,-,-,-,-,
3 : -,-,1,-,-,-,-,-,-,-,
4 : -,-,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,-,-,-,-,-,-,-,-,-,
......
0 5 6 7 4 3 - - - 
======
si is 0 , dist is 1294.7 step is 5
0 : -,2,1,-,-,-,-,-,-,-,
1 : -,2,0,-,-,-,-,-,-,-,
2 : -,1,0,-,-,-,-,-,-,-,
3 : -,-,1,-,-,-,-,-,-,-,
4 : -,-,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,-,-,-,-,-,-,-,-,-,
......
0 5 6 7 4 3 - - - 
 #$#$#$ 
======
si is 0 , dist is 1294.7 step is 5
0 : -,2,1,-,-,-,-,-,-,-,
1 : -,2,0,-,-,-,-,-,-,-,
2 : -,1,0,-,-,-,-,-,-,-,
3 : -,-,1,-,-,-,-,-,-,-,
4 : -,-,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,-,-,-,-,-,-,-,-,-,
......
0 5 6 7 4 3 - - - 
///step_forward: ci is 3 cc is 1 i is 6
======
si is 50 , dist is 1294.7 step is 5
0 : -,2,-,-,-,-,-,-,-,-,
1 : -,2,0,-,-,-,-,-,-,-,
2 : -,-,0,-,-,-,-,-,-,-,
3 : -,-,-,-,-,-,-,-,-,-,
4 : -,-,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,-,-,-,-,-,-,-,-,-,
......
0 5 6 7 4 3 1 - - 
 #$#$#$ 
======
si is 0 , dist is 1631.0 step is 6
0 : -,2,-,-,-,-,-,-,-,-,
1 : -,2,0,-,-,-,-,-,-,-,
2 : -,-,0,-,-,-,-,-,-,-,
3 : -,-,-,-,-,-,-,-,-,-,
4 : -,-,2,-,-,-,-,-,-,-,
5 : -,0,-,-,-,-,-,-,-,-,
6 : -,-,-,-,-,-,-,-,-,-,
7 : -,-,-,-,-,-,-,-,-,-,
......
0 5 6 7 4 3 1 - - 
min_dist is 1974.7 max_i is 49
......

I suppose functions : step_backward() , step_forward() , search() do not properly traverse the graph. The problem might be in some of these functions.

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.