Skip to main content

pytspsolver

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

Installation

> pip install pytspsolver

Usage

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)
experiment.add_problem(tsp_prob)
experiment.add_problems(problems)

# Add solvers to use in the experiment
experiment.add_solver(ExhaustiveSearch(time_limit=50))
experiment.add_solver(GreedySearch(time_limit=100))

# Run the experiment desired number of times
results = experiment.run(epoch=10) 

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

# Show visualizations - automatically averages the results from different epochs
visualizer.plot_n_vs_time_all(plt)

# 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

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.

Contributors

Metadata

Release files for pytspsolver 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytspsolver 0.0.1
File Size Uploaded Provenance
pytspsolver-0.0.1.tar.gz 12.5 kB Without provenance Details

Release files / pytspsolver-0.0.1.tar.gz

Download URL pytspsolver-0.0.1.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e99587f565bae988efe072a1dda67e06d9b899fef4b886d2c2a358674bfbeee0
BLAKE2b-256 checksum
How to use checksums
855501137020738c43d9a6c703a75fa2dd79d2e471d88917beba65536738ccfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

Security for pytspsolver 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page