Project

alns

0.0
The project is in a healthy, maintained state
Adaptive Large Neighbourhood Search
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

ALNS in Ruby

This is a partial port/adaptation of the Python library N-Wouda/ALNS to the ruby programming language.

The original implementation can be found here: N-Wouda/ALNS.

Overview

  • Implements core components of the ALNS metaheuristic: destroy operators, repair operators, acceptance criteria, and the operator selection mechanism.
  • Can be used to solve complex combinatorial optimization problems such as TSP, VRP, and others, similar to the Python version.

Install

gem install alns

Exmaple

solver = ALNS::Solver.new

init_sol = make_initial_solution(solver.rnd)

solver.on_outcome do |outcome, cand|
  # do something; for example, you could log it
end

solver.add_destroy_operator do |state, rnd|
  # clone the state and destroy it
end

solver.add_repair_operator do |state, rnd|
  # fix destroyed state
end

select = ALNS::Select::NewRouletteWheel.new([3, 2, 1, 0.5], 0.8, 2, 2)
accept = ALNS::Accept::HillClimbing.new
stop = ALNS::Stop::MaxIterations.new(100_000)

result = solver.iterate(init_sol, select, accept, stop)
# do something with the result