Skip to main content

A flexible implementation of the adaptive large neighbourhood search (ALNS) algorithm.

Project description

PyPI version ALNS Documentation Status codecov DOI

alns is a general, well-documented and tested implementation of the adaptive large neighbourhood search (ALNS) metaheuristic in Python. ALNS is an algorithm that can be used to solve difficult combinatorial optimisation problems. The algorithm begins with an initial solution. Then the algorithm iterates until a stopping criterion is met. In each iteration, a destroy and repair operator are selected, which transform the current solution into a candidate solution. This candidate solution is then evaluated by an acceptance criterion, and the operator selection scheme is updated based on the evaluation outcome.

Installing alns

The alns package depends on numpy and matplotlib. It may be installed in the usual way as

pip install alns

Additionally, to enable more advanced operator selection schemes using multi-armed bandit algorithms, alns may be installed with the optional MABWiser dependency:

pip install alns[mabwiser]

Getting started

The documentation is available here. If you are new to metaheuristics or ALNS, you might benefit from reading the introduction to ALNS page.

The alns library provides the ALNS algorithm and various acceptance criteria, operator selection schemes, and stopping criteria. To solve your own problem, you should provide the following:

  • A solution state for your problem that implements an objective() function.
  • An initial solution.
  • One or more destroy and repair operators tailored to your problem.

A "quickstart" code template is available here.

Examples

We provide several example notebooks showing how the ALNS library may be used. These include:

  • The travelling salesman problem (TSP), here. We solve an instance of 131 cities using very simple destroy and repair heuristics.
  • The capacitated vehicle routing problem (CVRP), here. We solve an instance with 241 customers using a combination of a greedy repair operator, and a slack-induced substring removal destroy operator.
  • The cutting-stock problem (CSP), here. We solve an instance with 180 beams over 165 distinct sizes in only a very limited number of iterations.
  • The resource-constrained project scheduling problem (RCPSP), here. We solve an instance with 90 jobs and 4 resources using a number of different operators and enhancement techniques from the literature.
  • The permutation flow shop problem (PFSP), here. We solve an instance with 50 jobs and 20 machines. Moreover, we demonstrate multiple advanced features of ALNS, including auto-fitting the acceptance criterion and adding local search to repair operators. We also demonstrate how one could tune ALNS parameters.

Finally, the features notebook gives an overview of various options available in the alns package. In the notebook we use these different options to solve a toy 0/1-knapsack problem. The notebook is a good starting point for when you want to use different schemes, acceptance or stopping criteria yourself. It is available here.

Contributing

We are very grateful for any contributions you are willing to make. Please have a look here to get started. If you aim to make a large change, it is helpful to discuss the change first in a new GitHub issue. Feel free to open one!

Getting help

If you are looking for help, please follow the instructions here.

How to cite alns

If you use alns in your research, please consider citing the following paper:

Wouda, N.A., and L. Lan (2023). ALNS: a Python implementation of the adaptive large neighbourhood search metaheuristic. Journal of Open Source Software, 8(81): 5028. https://doi.org/10.21105/joss.05028

Or, using the following BibTeX entry:

@article{Wouda_Lan_ALNS_2023, 
  doi = {10.21105/joss.05028}, 
  url = {https://doi.org/10.21105/joss.05028}, 
  year = {2023}, 
  publisher = {The Open Journal}, 
  volume = {8}, 
  number = {81}, 
  pages = {5028}, 
  author = {Niels A. Wouda and Leon Lan}, 
  title = {{ALNS}: a {P}ython implementation of the adaptive large neighbourhood search metaheuristic}, 
  journal = {Journal of Open Source Software} 
}

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

alns-5.3.1.tar.gz (41.4 kB view details)

Uploaded Source

Built Distribution

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

alns-5.3.1-py3-none-any.whl (63.7 kB view details)

Uploaded Python 3

File details

Details for the file alns-5.3.1.tar.gz.

File metadata

  • Download URL: alns-5.3.1.tar.gz
  • Upload date:
  • Size: 41.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.17 Linux/5.15.0-1042-azure

File hashes

Hashes for alns-5.3.1.tar.gz
Algorithm Hash digest
SHA256 c9dc73a5ed7b77c6498d646c6564a102842ac604dea573551d63dd980ab12f8a
MD5 e772130ee9527d4c260d63a4aa6cbb29
BLAKE2b-256 3777a51479f7259f0b2a0b7d435ad71c078b729a9b30166007a804d2647fb7c3

See more details on using hashes here.

File details

Details for the file alns-5.3.1-py3-none-any.whl.

File metadata

  • Download URL: alns-5.3.1-py3-none-any.whl
  • Upload date:
  • Size: 63.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.17 Linux/5.15.0-1042-azure

File hashes

Hashes for alns-5.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8b7c26e735428dbe82a7f14f4c200181725e1a0d0400d0393fbe9e3c0d608e8
MD5 98e3959a956a438885fa73b23e822e5d
BLAKE2b-256 64d5e9bc155e893fdaf13044e8748e016bea8875c67ada7d0b0d3589f9dd137e

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