aimacode / aima-python

Python implementation of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"
MIT License
7.92k stars 3.71k forks source link

Traveling Salesman Problem #687

Closed sagarvijaygupta closed 6 years ago

sagarvijaygupta commented 6 years ago

@MrDupin There is no visualization anywhere for simulated annealing and genetic algorithms which can be demonstrated on Traveling Salesman Problem. I would like to work on it.

antmarakis commented 6 years ago

Sure, nice idea!

sagarvijaygupta commented 6 years ago

@MrDupin I implemented visualization of simulated annealing and it is working fine. Iteratively running simulated annealing, provided with the last found best path as start state, is giving good visual demonstration but to show two_opt neighbors I will have to create a copy of the simulated_annealing part as the present code just provides with the final output state, which will result in repetition of code.

antmarakis commented 6 years ago

Hmmm, if you want to add a revised simulated_annealing code to the notebook (essentially replacing the search.py code), you can definitely do so (as long as it is only for the notebook).

Maybe you can change the name a bit to show the differentiation. I believe you want the function to return not only the final state, but also the states in between? If so, you could name the new function something like simulated_annealing_full.

sagarvijaygupta commented 6 years ago

@MrDupin yeah I wanted different states in between so I just created simulated_annealing2 in the file TSP.pywithout changing search.py in my last pull request. Should I change it the way you mentioned?

antmarakis commented 6 years ago

I think having it simulated_annealing_full is a better name, since it gives a little bit more information. With just numbering people might forget which function is which, but with 'full' I doubt they will have the same problem.

Also, why do you create a separate file? You can simply write the function in a notebook cell, to keep things clean.

sagarvijaygupta commented 6 years ago

@MrDupin I will add the visualization to the search.ipynb with the changed name. I initially added the file into the GUI folder.

antmarakis commented 6 years ago

The gui folder is only for tkinter applications. If you use tkinter for TSP, you can add it there, no problem. But if you want the visualization to go only on the notebook, the file is not needed. It depends on what you want to do:

sagarvijaygupta commented 6 years ago

@MrDupin I will try to implement both. It would be a nice experience on GUI with python. But firstly I will implement it on notebook.

antmarakis commented 6 years ago

Awesome, thanks!

sagarvijaygupta commented 6 years ago

@MrDupin Should I close this issue? As what was planned has been implemented in the last commit.

antmarakis commented 6 years ago

@sagarvijaygupta Yes. It's better to keep the Issues clean.

sagarvijaygupta commented 6 years ago

Thanks!