Skip to main content

A library to solve TSP (Travelling Salesman Problem) using Exact Algorithms, Heuristics, Metaheuristics and Reinforcement Learning

Project description

pyCombinatorial

New to Python or prefer a graphical interface? The pyCombinatorial Web App lets you run your analysis in clicks, not lines of code.

import pyCombinatorial

# Start the web service using:
pyCombinatorial.web_app()

# Terminate the web service using:
pyCombinatorial.web_stop()

Lab

This Google Colab Demo is intended for quick demos only. For the best experience, run the Web UI locally or open it directly in a full browser.

Introduction

pyCombinatorial is a Python-based library designed to tackle the classic Traveling Salesman Problem (TSP) through a diverse set of Exact Algorithms, Heuristics, Metaheuristics, and Reinforcement Learning. It brings together well-established and cutting-edge methodologies, offering end users a flexible toolkit to generate high-quality solutions for TSP instances of varying sizes and complexities.

Techniques: 2-opt; 2.5-opt; 3-opt; 4-opt; 5-opt; Or-opt; 2-opt Stochastic; 2.5-opt Stochastic; 3-opt Stochastic; 4-opt Stochastic; 5-opt Stochastic; Ant Colony Optimization; Adaptive Large Neighborhood Search; Bellman-Held-Karp Exact Algorithm; Bitonic Tour; Branch & Bound; BRKGA (Biased Random Key Genetic Algorithm); Brute Force; Cheapest Insertion; Christofides Algorithm; Clarke & Wright (Savings Heuristic); Concave Hull Algorithm; Convex Hull Algorithm; Elastic Net; Extremal Optimization; Farthest Insertion; FRNN (Fixed Radius Near Neighbor); Genetic Algorithm; GA-EAX (Genetic Algorithm with Edge Assembly Crossover); GRASP (Greedy Randomized Adaptive Search Procedure); Greedy Karp-Steele Patching; Guided Search; Hopfield Network; HGS (Hybrid Genetic Search); Iterated Search; Karp-Steele Patching; Large Neighborhood Search; LKH (Lin-Kernighan-Helsgaun); Multifragment Heuristic; Nearest Insertion; Nearest Neighbour; POPMUSIC (Partial OPtimization Metaheuristic Under Special Intensification Conditions); Random Insertion; Random Tour; Randomized Spectral Seriation; RL Q-Learning; RL Double Q-Learning; RL S.A.R.S.A (State Action Reward State Action); Ruin & Recreate; Scatter Search; Simulated Annealing; SOM (Self Organizing Maps); Space Filling Curve (Hilbert); Space Filling Curve (Morton); Space Filling Curve (Sierpinski); Spectral Seriation Initializer; Stochastic Hill Climbing; Sweep; Tabu Search; Truncated Branch & Bound; Twice-Around the Tree Algorithm (Double Tree Algorithm); Variable Neighborhood Search; Zero Suffix Method.

Usage

  1. Install
pip install pycombinatorial
  1. Import
# Required Libraries
import pandas as pd

# GA
from pyCombinatorial.algorithm import genetic_algorithm
from pyCombinatorial.utils import graphs, util

# Loading Coordinates # Berlin 52 (Minimum Distance = 7544.3659)
coordinates = pd.read_csv('https://bit.ly/3Oyn3hN', sep = '\t') 
coordinates = coordinates.values

# Obtaining the Distance Matrix
distance_matrix = util.build_distance_matrix(coordinates)

# GA - Parameters
parameters = {
            'population_size': 15,
            'elite': 1,
            'mutation_rate': 0.1,
            'mutation_search': 8,
            'generations': 1000,
            'verbose': True
             }

# GA - Algorithm
route, distance = genetic_algorithm(distance_matrix, **parameters)

# Plot Locations and Tour
graphs.plot_tour(coordinates, city_tour = route, view = 'browser', size = 10)
print('Total Distance: ', round(distance, 2))
  1. Try it in Colab

3.1 Lat Long Datasets

3.2 Algorithms

Single Objective Optimization

For Single Objective Optimization, try pyMetaheuristic

Multiobjective Optimization or Many Objectives Optimization

For Multiobjective Optimization or Many Objectives Optimization, try pyMultiobjective

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

pycombinatorial-2.2.7.tar.gz (185.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycombinatorial-2.2.7-py3-none-any.whl (285.1 kB view details)

Uploaded Python 3

File details

Details for the file pycombinatorial-2.2.7.tar.gz.

File metadata

  • Download URL: pycombinatorial-2.2.7.tar.gz
  • Upload date:
  • Size: 185.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for pycombinatorial-2.2.7.tar.gz
Algorithm Hash digest
SHA256 2ab07aa25afffac5bd8fb5e3a0743e2f6ce7326e820abc171e4ecda1f89bcf7e
MD5 d6bc624d4263fe1a0f003620321107e1
BLAKE2b-256 e0e793ce979da020a6912337849b4eeb7d2da70fe43d9b9a05afa5cff61abea9

See more details on using hashes here.

File details

Details for the file pycombinatorial-2.2.7-py3-none-any.whl.

File metadata

File hashes

Hashes for pycombinatorial-2.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 93ea79f97b3fe9439c6b58a5698ad72954af2edae38fc3c4e351a1923bae8b3b
MD5 18f1b47348bc7aac1cf2178f716d2971
BLAKE2b-256 89d5396586a35ce680f254fe59fdb3943ac1be8d7c947d1b1bb7972e2f9d3a77

See more details on using hashes here.

Supported by

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