Skip to main content

Easy to use python package for rapid experimentation on the classic travelling salesman problem.

Project description


Easy to use package for rapid experimentation on the classic travelling salesman problem. Contains implementations of various optimization algorithms, cool visualizers and a plug-in architecture.

Build Status Say Thanks! MIT license


> pip install pytspsolver


This package is designed to provide an intutive pythonic interface; allowing you to conduct experiments with minimal code and maximum flexibility. 😅

Here's how you can kick-start a travelling salesman problem experiment:

from pytspsolver.entities import TSProblem
from pytspsolver.experiments import Experiment
from pytspsolver.solvers import *
from pytspsolver.utilities import create_random_problem, get_tsp_lib_problem, Visualizer
import matplotlib.pyplot as plt

# Create a few tsp problems (represented as an adjacency matrix)
problems = [create_random_problem("UniqueProblemName"+str(i), i) for i in range(3,12)]

# Pass in the location of TSPLIB95 dataset file
tsp_prob = get_tsp_lib_problem("gr17.tsp")

# Create a new Experiment
experiment = Experiment()

# Add the problems to the experiment (single or list of problems)

# Add solvers to use in the experiment

# Run the experiment desired number of times
results = 

# Set up Visualizer with experiment results
visualizer = Visualizer(results)

# Show visualizations - automatically averages the results from different epochs

# Note: the visualizer has various plots available, they can be called in a similar fashion.

It comes with a plug in architecture, therefore it is very customizable.

Additional Examples

A few examples have been implemented using jupyter notebooks; found in the examples folder. These notebooks can be accessed by launching jupyter notebook from your current conda environment.

> jupyter notebook

👉 Make sure you are in the right environment when launching jupyter notebook, otherwise, jupyter notebook kernel will be pointing to a different python version which won't have pytspsolver package installed.


Contributions and pull requests are encouraged! 👏

If you spot any issues or would like to add a new feature, please discuss it in the GitHub issues section prior to writing code and submitting a pull request.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytspsolver-0.0.1.tar.gz (12.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page