Stopping criteria

The alns.stop module contains the various stopping criteria the alns package ships with. These can be used to stop the ALNS search whenever some criterion is met: for example, when some maximum number of iterations or run-time is exceeded.

All stopping criteria implement StoppingCriterion.

class alns.stop.StoppingCriterion.StoppingCriterion(*args, **kwargs)

Protocol describing a stopping criterion.

Methods

__call__(rnd, best, current)

Determines whether to stop.

class alns.stop.MaxIterations.MaxIterations(max_iterations: int)

Criterion that stops after a maximum number of iterations.

Attributes
max_iterations

Methods

__call__(rnd, best, current)

Call self as a function.

class alns.stop.MaxRuntime.MaxRuntime(max_runtime: float)

Criterion that stops after a specified maximum runtime.

Attributes
max_runtime

Methods

__call__(rnd, best, current)

Call self as a function.

class alns.stop.NoImprovement.NoImprovement(max_iterations: int)

Criterion that stops if the best solution has not been improved after a number of iterations.

Parameters
max_iterations

The maximum number of non-improving iterations.

Attributes
max_iterations

Methods

__call__(rnd, best, current)

Call self as a function.