Skip to main content

GRASP for TSP

Project description

tsp-grasp

Welcome to tsp-grasp! A Python package with Heuristics for solving the Traveling Salesman Problem (TSP).

Documentation

Install

The package tspgrasp is available on PyPI, so you can install it via pip by running the following command line:

pip install tspgrasp

To install the package in development versions, clone it from github using:

git clone https://github.com/bruscalia/tsp-grasp.git

And run one of the two following commands:

pip install .
python setup.py install

Make sure Cython and numpy are also available in your python environment.

Alternatively, you can directly run:

pip install git+https://github.com/bruscalia/tsp-grasp.git

Here is a minimum working example in which a symmetric distance matrix is produced from 2-dimensional coordinates.

Use

# Imports
import numpy as np
from scipy.spatial.distance import pdist, squareform
from tspgrasp import Grasp
# Create distance matrix
X = np.random.random((100, 2))
D = squareform(pdist(X))

# Instantiate algorithm and solve problem
grasp = Grasp(seed=12)
sol = grasp(D, time_limit=10, max_iter=100)

# Display cost and tour
print(f"Cost: {sol.cost}")
print(f"Tour: {sol.tour}")

Theory

Greedy Randomized Adaptive Search Procedures (GRASP) are metaheuristics constituted by a hybridization of a semi-greedy procedure with a local search method. For more details please refer to Resende & Ribeiro (2016).

Local search moves implemented were based on the work of Vidal (2022).

Contact

You can reach out to me at bruscalia12@gmail.com

References

Resende, M. G., & Ribeiro, C. C. (2016). Optimization by GRASP. Springer Science+ Business Media New York. https://doi.org/10.1007/978-1-4939-6530-4

Vidal, T. (2022). Hybrid genetic search for the CVRP: Open-source implementation and SWAP* neighborhood. Computers & Operations Research, 140, 105643. https://doi.org/10.1016/j.cor.2021.105643

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

tspgrasp-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distributions

tspgrasp-0.1.0-cp312-cp312-win_amd64.whl (483.4 kB view details)

Uploaded CPython 3.12Windows x86-64

tspgrasp-0.1.0-cp312-cp312-macosx_10_9_universal2.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 10.9+ universal2 (ARM64, x86-64)

tspgrasp-0.1.0-cp311-cp311-win_amd64.whl (479.5 kB view details)

Uploaded CPython 3.11Windows x86-64

tspgrasp-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tspgrasp-0.1.0-cp311-cp311-macosx_10_9_universal2.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

tspgrasp-0.1.0-cp310-cp310-win_amd64.whl (479.1 kB view details)

Uploaded CPython 3.10Windows x86-64

tspgrasp-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tspgrasp-0.1.0-cp310-cp310-macosx_11_0_x86_64.whl (534.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

tspgrasp-0.1.0-cp39-cp39-win_amd64.whl (563.4 kB view details)

Uploaded CPython 3.9Windows x86-64

tspgrasp-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

tspgrasp-0.1.0-cp39-cp39-macosx_11_0_x86_64.whl (539.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

tspgrasp-0.1.0-cp38-cp38-win_amd64.whl (568.3 kB view details)

Uploaded CPython 3.8Windows x86-64

tspgrasp-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

tspgrasp-0.1.0-cp38-cp38-macosx_11_0_x86_64.whl (536.9 kB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

tspgrasp-0.1.0-cp37-cp37m-win_amd64.whl (559.9 kB view details)

Uploaded CPython 3.7mWindows x86-64

tspgrasp-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

tspgrasp-0.1.0-cp37-cp37m-macosx_11_0_x86_64.whl (540.7 kB view details)

Uploaded CPython 3.7mmacOS 11.0+ x86-64

File details

Details for the file tspgrasp-0.1.0.tar.gz.

File metadata

  • Download URL: tspgrasp-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for tspgrasp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2b62984a61dea4c236aa95816fa812452557ae6d46f7a9e8f38597a55fec5a16
MD5 a2c202eff07c7b06b1afddfc713d21c4
BLAKE2b-256 7970b6be9a4b0c815cbbd80e7cf9d983ccafd7ff732afe52f67ce0a6094be50a

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: tspgrasp-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 483.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for tspgrasp-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b4d00e839d3a221da962ebc74c7ab2c1ca32e4a40cecd07e1a0b9eeda624a949
MD5 d9ef4492b3438e15fc8cacc4e3589710
BLAKE2b-256 777070732a8960786266ddb1e7a4b66b87d7eb8c3072980fce60cbe87bd2b739

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp312-cp312-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp312-cp312-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 1674d14f23d81da7c2272f2716690122030c63d6e3ba89ccb393e7d1d91f4512
MD5 07c774dbe9e28fe57300bfbd3e6021df
BLAKE2b-256 f032461335399054e589b587297cf60a36c5189b88f8810e6c9093320251dcc7

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: tspgrasp-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 479.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for tspgrasp-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 10b92ae5001e463f353f8a8ca40f81036170e67d744870e69a420a8e9b18f4ca
MD5 6407fe994390f954dee0c2decd906f04
BLAKE2b-256 05d9caaf89d505755373f167b2784c4379f9977941bf181a07816d40dcb578d5

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b628efa76133de3caf1ac052badbb2ba10d024ce35ef47e16bad2022c5d01c65
MD5 91ce019189d5774367f665387c6cdec1
BLAKE2b-256 1e954a8e021c33d8a1eaf626db8d5592f96de335bbe8b03b839ab5931913826b

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 7b91a7c343abe291cd2aa66d23dfbde8e82f53e20120071cb73e76481da699ba
MD5 6010f3a2915a98cc356217d868be804b
BLAKE2b-256 e1a1c65f35dfae94666b4332701de92bc1ec34b574444042f1f6c8951f3803b8

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: tspgrasp-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 479.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for tspgrasp-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ef15fbb60633fef738a837a1e8c9bb58a6a599f1d5d09b4cf9223d2026e84526
MD5 d90eb2c4412bfd4fc8bace580108ccae
BLAKE2b-256 5adda4288e98eeb579386a31be52b054c3750f802f3531cfd300ea0268527b41

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a2a7cef9960bf5bf3aeaa477e8348b3f73ef0ee1c07e4e2761685993aeea8fc
MD5 1283cdc9f482d3b7f3ca30cc1046eb41
BLAKE2b-256 d912724d46a9a8a5cfa347da1642db30ba990690e448b71748fb157be41d2592

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a25fd6a21fc004a658c9e73461e175462c40c9f0b788f0f16d392bcf6d2038ac
MD5 b727aaf35cb1fbd3fd4d590467a2c974
BLAKE2b-256 615a55ca31eefbe6a3006314b26c8bb9fbd707e92db7b66d60cee3097b82b7ee

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: tspgrasp-0.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 563.4 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for tspgrasp-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 97fbe9f8b7fbfcfc6a555158430feb9fffc0ec775458cc66834651bbfcdd69b1
MD5 a1c18aff496eac10bce7fd4e0842ae42
BLAKE2b-256 8cb2dab372f5c12f4ed09f5ff6708ac86524d45f18e116cc793030e34737ebd9

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52e597b55229e57adce00dac71ede07f006a6f7c94b4ff1aa503563ba7ebd77a
MD5 b4f84e270c4a7a946f5faec6db2a9059
BLAKE2b-256 bb3e51d114adda1d96652b5436daaade78cbf1f4431956a1bdfb2656d8d9904a

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 2b0c5d347802769c027b75c1b6f18aaa131e6b7aa93594eb1a9255e44067c799
MD5 1080d54e50a85f9304d2b0bb99abf32f
BLAKE2b-256 f3d02a29e08c2c74b7487c887cfd9ff5db63ff648adb8c56d3ac76917a4a87c8

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: tspgrasp-0.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 568.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for tspgrasp-0.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 2b46972301ecec6edd31616f841dd3880d77666bdfc6959ad70ede8cf7d9b0b5
MD5 89a94a62c97a7154a6f89463b09ac20d
BLAKE2b-256 45f23136d7b73571b6b4fda247169cf9b54fc49f08908c92f85ca8482cab9351

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bc2156dfc30d6e846dc52ae92a98deeab690ad2b2e3ca740e8000564e8c0f21a
MD5 5468255a0e03ee9262473880ef2c57fc
BLAKE2b-256 441eed803f4011c68b56a5b2685fd9f66fedd1833a09c6ef1e09359ab01c5eeb

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 fdb1462b390e18c88a229655281be4f4e5ba6eadb4a6c3e313b43aafffb7a608
MD5 89cef4c898d33aedc002b16e118d1efc
BLAKE2b-256 bbd3f6e4d73f82e2fdeb723c6de713df7e45cdf7b8a0e338ccdf11e88984873c

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: tspgrasp-0.1.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 559.9 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for tspgrasp-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 834112eedb5f0cf51ecce97b3a38ef83a0a4cc6c7b36e7b9a309974d545aec09
MD5 b9f82f2bcdcaeb618594fcf15b1881f4
BLAKE2b-256 0856612629bd0956de022fbc8c5bd37190be9aa30b15abdecc6a69aab19c065e

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 72cdf14951470827e5aa3b195fb85d14fd83c1018ced5084ed284ab2614fd34b
MD5 59901384e74ae9a1eef8df2e9fc1f70c
BLAKE2b-256 01fbb7db5939b8bcbea489064101e0369e09f51a7a84128158b1ebef33b469eb

See more details on using hashes here.

File details

Details for the file tspgrasp-0.1.0-cp37-cp37m-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for tspgrasp-0.1.0-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 854892b18ae86daec4b3795ad5c44cca1c1ec3274a3210f4b0b7ec3ac6cfe85a
MD5 f0baef8f95fc000cecbb4ec17c2d5a28
BLAKE2b-256 5902fce816a235e9acd1fc41e4c71b1f2f5b9f9e7205c34da8c310d2ceddf239

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