altbacken.external.neighbourhood.numeric
Classes
|
Represents a neighborhood for array-based solutions in optimization algorithms. |
|
Represents a neighborhood function for integer vectors, used in simulated annealing to generate neighboring solutions. |
|
|
|
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:
objectDefines 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:
- random
Random number generator used for creating perturbations.
- Type:
RandomNumberGenerator
- vector_type
Function used to define the type or structure of the output vector.
- __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]
- 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:
objectRepresents 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.
- 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.
- 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]
- class altbacken.external.neighbourhood.numeric.SupportsArrayOps(*args, **kwargs)[source]
Bases:
Protocol- __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:
GenericRepresents 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.
- seed
Seed for the random number generator to ensure reproducibility of the generated neighbors.
- Type:
- 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.