aarongarrett / inspyred

Python library for bio-inspired computational intelligence
MIT License
187 stars 58 forks source link

Inconsistency result for traveling salesman problem #15

Closed andreaschandra closed 8 months ago

andreaschandra commented 5 years ago

Description

I tried a sample code for the traveling salesman problem as given in the documentation. It runs successfully. But when I run it again, the route and distance are changing every time I run the code. Why does this happen? why the algorithm does not find the best solution ?

What I Did

I just copy, paste and run in my own laptop. http://aarongarrett.github.io/inspyred/examples.html#the-traveling-salesman-problem

first result:

Best Solution: [6, 2, 7, 5, 4, 1, 0, 8, 9, 3]: 1566.1363051360365

second result:

Best Solution: [9, 8, 0, 1, 4, 2, 6, 5, 7, 3]: 1552.9612081934351
aarongarrett commented 5 years ago

The TSP is an NP-complete problem. No known algorithm exists to solve it exactly in the general case. This is an approximation. ECs find "nearly" optimal solutions, where "nearly" is relative to the amount of time/effort you allow the EC. In this example, there are a total of 5000 paths evaluated. That is 0.1% of all possible routes for this 10-city problem.

On Wed, Dec 12, 2018 at 11:09 PM Andreas Chandra notifications@github.com wrote:

  • inspyred version: 1.0
  • Python version: 3.6.3
  • Operating System: Ubuntu 17.10

Description

I tried a sample code for the traveling salesman problem as given in the documentation. It runs successfully. But when I run it again, the route and distance are changing every time I run the code. Why does this happen? why the algorithm does not find the best solution ? What I Did

I just copy, paste and run in my own laptop.

http://aarongarrett.github.io/inspyred/examples.html#the-traveling-salesman-problem

first result:

Best Solution: [6, 2, 7, 5, 4, 1, 0, 8, 9, 3]: 1566.1363051360365

second result:

Best Solution: [9, 8, 0, 1, 4, 2, 6, 5, 7, 3]: 1552.9612081934351

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aarongarrett/inspyred/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/ABcX3VdORSQ5TW238eT4PYq0CmwtkAj1ks5u4dLwgaJpZM4ZQ5Hv .

-- Aaron Garrett, Ph.D. Assistant Professor Computer Science Wofford College 429 North Church Street Spartanburg, SC 29303 garrettal@wofford.edu (864) 597-4529