Skip to main content

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

Project description

pyCombinatorial

Introduction

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

Techniques: 2-opt; 2.5-opt; 3-opt; 4-opt; 5-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; GRASP (Greedy Randomized Adaptive Search Procedure); Greedy Karp-Steele Patching; Guided Search; Hopfield Network; Iterated Search; Karp-Steele Patching; Large Neighborhood Search; Multifragment Heuristic; Nearest Insertion; Nearest Neighbour; Random Insertion; Random Tour; 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); 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.1.0.tar.gz (51.9 kB view details)

Uploaded Source

Built Distribution

pycombinatorial-2.1.0-py3-none-any.whl (100.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pycombinatorial-2.1.0.tar.gz
Algorithm Hash digest
SHA256 fa96598878c77dfbb6842ad4511734289b66bc9eed98660a8f121104475b9374
MD5 8bfbe73ec8b96402c0ff7b34bd8f7541
BLAKE2b-256 f5be8d70f7bb7ede3f9a0e708bb2e510d369ffee50d12b5a7dc5e82de0fd5f6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycombinatorial-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb751735ab81604764a9af13806d9fa515a54bcae70e510acc52ffa1b2b4a81f
MD5 88c7bd8f2d8210ff891cb59c07ab2859
BLAKE2b-256 17d3c7ee2f426a21c2e99668ac66c57efe27030d39eccde3b3c00195c9243d56

See more details on using hashes here.

Supported by

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