ALNS: a Python implementation of the adaptive large neighbourhood search metaheuristic

metaheuristic

Despite the existence of these software libraries, it remains common in the operations research community to re-implement heuristics (Swan et al., 2022).Such implementations are relatively limited, are typically tied tightly to one particular problem domain, and often implement just a single acceptance criterion and operator selection scheme.The survey of Windras Mara et al. ( 2022) corroborates these claims: 205 out of the 251 papers they survey only consider a simulated annealing acceptance criterion, and only one paper uses an operator selection scheme that is not based on the roulette wheel mechanism of Røpke & Pisinger (2006).This inhibits experimentation with different aspects of the algorithm, and makes re-use by others or in other problem domains difficult.Our alns package, by contrast, offers a clear and problem-agnostic API for using the ALNS algorithm, and provides many acceptance criteria and operator selection schemes.Additionally, we provide diagnostic statistics, plotting methods, logging, and the ability to register custom callbacks at various points of the search.These allow researchers and practitioners to rapidly develop state-of-the-art metaheuristics in a wide range of problem domains.

Features
At its core, ALNS is an iterative ruin-and-recreate algorithm that runs until some stopping criterion is met.The algorithm starts with some initial solution.In each iteration, the current solution is transformed into a new candidate solution using problem-specific destroy and repair operators, which are selected via an operator selection scheme.The candidate solution is then evaluated by an acceptance criterion, and possibly replaces the current solution.Based on the outcome of that evaluation, the operator selection scheme updates the likelihood that the applied operators are selected again in the next iteration.
The alns Python package offers: • A complete ALNS implementation, supported by an extensive test suite.This implementation supports user-defined callbacks whenever a new solution is found, including when that new solution is a new global best, which could be used to support additional intensification methods.Furthermore, it can be supplied with arbitrary user-defined destroy and repair operators that are tailored to the user's problem domain.• Multiple acceptance criteria in alns.accept.These include standard ones like hillclimbing and simulated annealing, and several variants of record-to-record travel and the great deluge criteria (Dueck, 1993).• Several operator selection schemes in alns.select.These include the original (segmented) roulette wheel mechanism of Røpke & Pisinger (2006), and an upper confidence bound bandit algorithm adapted from Hendel (2022).• Various stopping criteria in alns.stopbased on maximum run-times or iterations.This includes a criterion that stops after a fixed number of iterations without improvement, which could be used to restart the search.• Diagnostic statistics collection and plotting methods that can be accessed after solving.
The package can easily be installed through pip, and our detailed documentation is available here.To get started using alns, a user must provide: • A solution state for their problem that implements an objective() function.
• An initial solution using this solution state.
• One or more destroy and repair operators tailored to the problem.
We provide a quickstart template in our documentation, where these elements are listed as 'TODO'.The documentation also provides several complete implementations of ALNS metaheuristics solving instances of the travelling salesman problem, capacitated vehicle routing problem, cutting stock problem, permutation flow shop problem, and the resource-constrained project scheduling problem.These implementations will help users quickly get started solving their own problems using alns.