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.1.tar.gz (14.5 kB view details)

Uploaded Source

Built Distributions

tspgrasp-0.1.1-cp312-cp312-win_amd64.whl (520.5 kB view details)

Uploaded CPython 3.12Windows x86-64

tspgrasp-0.1.1-cp312-cp312-macosx_10_9_universal2.whl (1.1 MB view details)

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

tspgrasp-0.1.1-cp311-cp311-win_amd64.whl (517.0 kB view details)

Uploaded CPython 3.11Windows x86-64

tspgrasp-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tspgrasp-0.1.1-cp311-cp311-macosx_10_9_universal2.whl (1.1 MB view details)

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

tspgrasp-0.1.1-cp310-cp310-win_amd64.whl (516.5 kB view details)

Uploaded CPython 3.10Windows x86-64

tspgrasp-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tspgrasp-0.1.1-cp310-cp310-macosx_11_0_x86_64.whl (584.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

tspgrasp-0.1.1-cp39-cp39-win_amd64.whl (605.1 kB view details)

Uploaded CPython 3.9Windows x86-64

tspgrasp-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

tspgrasp-0.1.1-cp39-cp39-macosx_11_0_x86_64.whl (590.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

tspgrasp-0.1.1-cp38-cp38-win_amd64.whl (610.4 kB view details)

Uploaded CPython 3.8Windows x86-64

tspgrasp-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

tspgrasp-0.1.1-cp38-cp38-macosx_11_0_x86_64.whl (587.9 kB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

tspgrasp-0.1.1-cp37-cp37m-win_amd64.whl (601.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

tspgrasp-0.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

tspgrasp-0.1.1-cp37-cp37m-macosx_11_0_x86_64.whl (591.6 kB view details)

Uploaded CPython 3.7mmacOS 11.0+ x86-64

File details

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

File metadata

  • Download URL: tspgrasp-0.1.1.tar.gz
  • Upload date:
  • Size: 14.5 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.1.tar.gz
Algorithm Hash digest
SHA256 509d3225ada9f593317637420a0a9c8d82d64289190e718c52e1cb2153e02822
MD5 c0fa6c17842028fb02574edd830be295
BLAKE2b-256 11376312b2005f94bb791ae0ed1ac8c416989af2cedd885e7e1e0c8229293167

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tspgrasp-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 520.5 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ed310570b0c8d87b47ab2514982f2099e3378a50fd6f29e8d158e96e063e0fa1
MD5 d17883028ae9a1e6b6b7cf5aea180ea3
BLAKE2b-256 9c3aab1d3b65c3f78b8a5fc19485e344f78f4dfd96c796a2e23f15e77e0b98a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp312-cp312-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 ce99a15a67b8294a5f333e1381a1e5cceee906aa40cbf3a68a2cc049587d4426
MD5 06940515c7dbb383946698078e41f210
BLAKE2b-256 accdbf04ebc6598761d37dec90d3ccb69090a28f15b41283df134ba3d25ce98a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tspgrasp-0.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 517.0 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1a80505f9fd3d9208515ebf10a449ea6a231a6a2ce3a155f18ca0b4588e0dc84
MD5 f7c2ae66825d222e736a335e124d36b6
BLAKE2b-256 592abab471eb4713d3559bc1e8c4d9e21437c05b685e0bf95d022ebd93062642

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4b72cd37775bc2c75f75902cce62bbb39623b8cef18c0a70121dc5a51bdd69a6
MD5 8cd273348f666dc29f792cad9fa1bff6
BLAKE2b-256 93d5f01d4953ac0807eaa5d40ce16ea276f2d8645d57df5e055c27198ca1f811

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 517f1b86a0ca3a7460c4d1d8975769c2d3fd3bdd86228327bb76aa3ba98e3ba7
MD5 b4203a31c8ee0e33e2165d15efcb030c
BLAKE2b-256 40494bc4c6df6bbaa4d1e5621366ed7f1de2a5f9d277cf03301a9a7faee93bd9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tspgrasp-0.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 516.5 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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8deb10cd2035a188be2bbb1fb1fa735dc72ceda45bd1974620891aa28f6be556
MD5 2179e47672490866fdc06b29d9deb34f
BLAKE2b-256 dcb3467fc24ce8849dab218a47c5cdc99ee6eb8b2f08136aa02d600d4e0d9b94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2915d5079414c1e97c94ca16adf632c78ce7be4291c7e9d585e2ec070a5ccecd
MD5 355bf35c253f813a343060a7202c8d1b
BLAKE2b-256 04098f5c671f15db3ea002afc7b03a3be60b1068689772ffe2aed7bb45c10f92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 671868834d4f33cd8c7fb141240bb7debfc5fc6c02b2586a9f56241c2502c3aa
MD5 8d0eb3686bafa0baa3479c79f430cde7
BLAKE2b-256 3656f83c7a6e9d04d6c9df0bcc85f5823dbe2c9cb8113972406ee600fff9cb55

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tspgrasp-0.1.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 605.1 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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f61033355f86050097e59bc2439c3204cbb34697a0a2c279743097e23d136c6c
MD5 549f65452652fcb0da34850cc40670f4
BLAKE2b-256 98fd60423ee64c63bcc62b75baf6e99e2794f6ca16ad844f09638ace428a23f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 640096e0a46fb297eb9a02592e53e15ee1685a414a7320317e3d02b4363b2871
MD5 3bd55dbb29ef1a008ab6866b48546e2c
BLAKE2b-256 c73576271c9ee0a26072a5ca60d9502ca4e7c17701f8300406269d7a474bb619

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 5a1e6d4ea901f9e326e44e21e1e1bec943fc4750f053df26c5a30cc1c8d4a6a7
MD5 b622bd9370abedd79e02e1fd2cfa5c91
BLAKE2b-256 913b4fb66f6e4e6bc904afaf1f5da0eeeb0c99db67e9aa46080c101dc46e1939

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tspgrasp-0.1.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 610.4 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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 fbc58b77b95d07d38268645c1e95671535baf742c0630e25b778d8a610072dd4
MD5 f5791b0dc61f4d689cd626f69ee3ddba
BLAKE2b-256 c6e9d2fa9205ff019b3ecb73be38fa5e67faf412b50d7017b31b5b8ef1043be2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7dd14d822e4d051729398892f3d6b33bf180d566a7634524c4c7122554ab34e
MD5 709029f75f4903c4916d32b341959581
BLAKE2b-256 138a00b05486bd3cf38ee9798fa555cc7a80838cad531dda25b60fb0d18d47aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 14c3c19c62c69d95f89aed2d4a50a9a1bae3833905515898804b0a35e56e4409
MD5 10ad3a72f108d25a8bab57960c2b4064
BLAKE2b-256 aa09162b17ada60b30b8dd61047845ef2175d95330d6e3f899452eee923d2588

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tspgrasp-0.1.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 601.7 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.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 96e73ff53e0afc9bd4697918d487c8cec858f30ec4fed6e2bcd214a679a1e29b
MD5 8cb55296695290e41b0380ad21f840c9
BLAKE2b-256 1a85a6d1e7071d838188a68cdad81d1622620b0cdff55f0adc1152ef266d070e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a24212bf2924975ec30422d6d42acc927cc142dc69f741b47564f0861c3ef89c
MD5 6146b550742925b3a006a4e06b4b224b
BLAKE2b-256 ede896db27f0b15b597e8857f8a87f6023343222eb41cea1962a698d158ef15e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tspgrasp-0.1.1-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 194dd4faf7056a1c382bd2a1efb3f63673710aa2d6349152ab31a5bed2cb6429
MD5 32db9a09a14b069ff6e1d4922be9e477
BLAKE2b-256 7ed2ab857c2e113e6d5fd520bcf923a83049ede7721ffc35626a4766acbec65a

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