An open API service indexing awesome lists of open source software.

https://github.com/rodrigo-arenas/tspme

Python metaheuristics for Traveling Salesman Problem (TSP)
https://github.com/rodrigo-arenas/tspme

Last synced: 7 months ago
JSON representation

Python metaheuristics for Traveling Salesman Problem (TSP)

Awesome Lists containing this project

README

          

# tspme
Python metaheuristics for Traveling Salesman Problem (TSP)

## Example

```python
import matplotlib.pyplot as plt
from tspme.utils.routes_generator import RandomRouteGenerator
from tspme.utils.plot_routes import plot_routes, plot_history
from tspme.metaheuristics import SimulatedAnnealing

SIZE = 50
route_generator = RandomRouteGenerator(size=SIZE)
routes = route_generator.generate()

sa = SimulatedAnnealing()
sa.set_distance_matrix(routes)
solution = sa.fit(return_cost_hist=True)
print(solution)
plot_routes(cities=routes, solution=solution)
plot_history(solution=solution)
plt.show()
```