Skip to main content

ALNS logo

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

Feel free to open an issue or a new discussion thread here on GitHub. Please do not e-mail us with questions, modelling issues, or code examples. Those are much easier to discuss via GitHub than over e-mail. When writing your issue or discussion, 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} 
}

Metadata

Release files for alns 7.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alns 7.0.0
File Size Uploaded Provenance Actions
alns-7.0.0.tar.gz 41.5 kB Without provenance Details for alns-7.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for alns 7.0.0
File Interpreter ABI Platform Actions
alns-7.0.0-py3-none-any.whl Python 3 none any Details for alns-7.0.0-py3-none-any.whl

Total release size: 105.3 kB

Release files / alns-7.0.0.tar.gz

Download URL alns-7.0.0.tar.gz
Size 41.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2ac2030537d6e76689b7330e7f399f3b3c9730302465e434cca8b2d44061757e
BLAKE2b-256 checksum
How to use checksums
50994f0d39e25f0265f404e2506d2b0bc009b16ce8fa02549b2ba5d7398a49f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.11.10 Linux/6.5.0-1025-azure

Release files / alns-7.0.0-py3-none-any.whl

Download URL alns-7.0.0-py3-none-any.whl
Size 63.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7d019e0aff8f78c7734da29162a148926530d9b52e243e8641af853c12a0c1c
BLAKE2b-256 checksum
How to use checksums
fe5a32b22e1a74547754b90c40213c79650826ac714173e02cd973eba0703552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.11.10 Linux/6.5.0-1025-azure

Security for alns 7.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

7.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page