altbacken.external.neighbourhood.numeric

Classes

ArrayNeighbourhood(epsilon, float] = 0.1, ...)

Represents a neighborhood for array-based solutions in optimization algorithms.

IntegerVectorNeighbourhood(epsilon, ...)

Represents a neighborhood function for integer vectors, used in simulated annealing to generate neighboring solutions.

SupportsArrayOps(*args, **kwargs)

VectorNeighbourhood(epsilon, float] = 0.1, ...)

Defines a class for generating a neighborhood of vectors.

altbacken.external.neighbourhood.numeric.builtin_random()

random() -> x in the interval [0, 1).

class altbacken.external.neighbourhood.numeric.VectorNeighbourhood(epsilon: float | ~altbacken.internal.neighbourhood.adaptive.Epsilon[~collections.abc.Sequence[float], float] = 0.1, random: RandomNumberGenerator = <built-in method random of Random object>, vector_type: ~collections.abc.Callable[[~collections.abc.Iterable[float]], ~collections.abc.Sequence[float]] = <class 'tuple'>, temperature_scaling: TemperatureScaling = <function no_temperature_scaling>)[source]

Bases: object

Defines a class for generating a neighborhood of vectors.

The VectorNeighbourhood class generates new vectors by applying a small random perturbation to each component of an input vector.

epsilon

Magnitude of the perturbation applied to the input vector during neighborhood generation.

Type:

float

random

Random number generator used for creating perturbations.

Type:

RandomNumberGenerator

vector_type

Function used to define the type or structure of the output vector.

Type:

Callable[[Iterable[float]], Sequence[float]]

__init__(epsilon: float | ~altbacken.internal.neighbourhood.adaptive.Epsilon[~collections.abc.Sequence[float], float] = 0.1, random: RandomNumberGenerator = <built-in method random of Random object>, vector_type: ~collections.abc.Callable[[~collections.abc.Iterable[float]], ~collections.abc.Sequence[float]] = <class 'tuple'>, temperature_scaling: TemperatureScaling = <function no_temperature_scaling>)[source]
__call__(vector: AnnealingState[Sequence[float]]) Sequence[float][source]

Call self as a function.

class altbacken.external.neighbourhood.numeric.IntegerVectorNeighbourhood(epsilon: int | ~altbacken.internal.neighbourhood.adaptive.Epsilon[~collections.abc.Sequence[int], int] = 1, random: RandomNumberGenerator = <built-in method random of Random object>, vector_type: ~collections.abc.Callable[[~collections.abc.Iterable[int]], ~collections.abc.Sequence[int]] = <class 'tuple'>, temperature_scaling: TemperatureScaling = <function no_temperature_scaling>)[source]

Bases: object

Represents a neighborhood function for integer vectors, used in simulated annealing to generate neighboring solutions.

This class is designed to provide a way to generate new candidate solutions by perturbing an integer vector. The perturbation is controlled by parameters like epsilon, randomness, and temperature scaling.

epsilon

The magnitude of the perturbations. If an integer is provided, a constant epsilon is used. Otherwise, a custom Epsilon instance can be specified.

Type:

int | Epsilon[Sequence[int], int]

random

A random number generator used for creating perturbations.

Type:

RandomNumberGenerator

vector_type

A callable that determines the type of vector to be returned, such as tuple or list.

Type:

Callable[[Iterable[int]], Sequence[int]]

temperature_scaling

A function or callable used to scale perturbations based on the current temperature during the annealing process.

Type:

TemperatureScaling

__init__(epsilon: int | ~altbacken.internal.neighbourhood.adaptive.Epsilon[~collections.abc.Sequence[int], int] = 1, random: RandomNumberGenerator = <built-in method random of Random object>, vector_type: ~collections.abc.Callable[[~collections.abc.Iterable[int]], ~collections.abc.Sequence[int]] = <class 'tuple'>, temperature_scaling: TemperatureScaling = <function no_temperature_scaling>)[source]
__call__(vector: AnnealingState[Sequence[int]]) Sequence[int][source]

Call self as a function.

class altbacken.external.neighbourhood.numeric.SupportsArrayOps(*args, **kwargs)[source]

Bases: Protocol

shape: tuple[int, ...]
__init__(*args, **kwargs)
class altbacken.external.neighbourhood.numeric.ArrayNeighbourhood(epsilon: float | ~altbacken.internal.neighbourhood.adaptive.Epsilon[A, float] = 0.1, seed: int = 0, temperature_scaling: TemperatureScaling = <function no_temperature_scaling>)[source]

Bases: Generic

Represents a neighborhood for array-based solutions in optimization algorithms.

This class is designed to generate neighboring solutions in an array-based optimization context, such as simulated annealing. It utilizes a specified epsilon value for scaling the neighborhood bounds and applies temperature scaling where applicable. The class is parameterized to work with data types that support array operations.

epsilon

Scaling factor for determining the range of the neighborhood bounds. Can either be a constant float or a custom epsilon function.

Type:

float | Epsilon[A, float]

seed

Seed for the random number generator to ensure reproducibility of the generated neighbors.

Type:

int

temperature_scaling

A function or object used for scaling the neighborhood size based on the current temperature.

Type:

TemperatureScaling

__init__(epsilon: float | ~altbacken.internal.neighbourhood.adaptive.Epsilon[A, float] = 0.1, seed: int = 0, temperature_scaling: TemperatureScaling = <function no_temperature_scaling>)[source]
__call__(state: AnnealingState) A[source]

Call self as a function.