Skip to main content

ClassicalAdaptation

Struct ClassicalAdaptation 

Source
pub struct ClassicalAdaptation { /* private fields */ }
Expand description

Quantum-Inspired Classical Adaptation Engine

Provides quantum-inspired enhancements to classical optimisation algorithms by injecting controlled randomness (coherent noise), modelling quantum annealing acceptance criteria, and simulating decoherence effects.

§Fields

  • adaptation_rate — scales the amplitude of coherent noise injected into parameter vectors (analogous to the magnitude of quantum fluctuations).
  • quantum_noise_level — baseline noise variance; combined with adaptation_rate to determine the actual noise standard deviation.

§Example

use scirs2_core::ndarray::Array1;
use scirs2_spatial::quantum_inspired::classical_adaptation::ClassicalAdaptation;

let adapter = ClassicalAdaptation::new(0.05, 0.01);

// Add quantum-inspired noise to a parameter vector
let params = Array1::from_vec(vec![1.0, 2.0, 3.0]);
let noisy = adapter.adapt(&params);
assert_eq!(noisy.len(), params.len());

// Quantum annealing acceptance for an uphill move
let accept_prob = adapter.anneal(1.5, 2.0);
assert!(accept_prob >= 0.0 && accept_prob <= 1.0);

Implementations§

Source§

impl ClassicalAdaptation

Source

pub fn new(adaptation_rate: f64, quantum_noise_level: f64) -> Self

Construct a new ClassicalAdaptation engine.

§Arguments
  • adaptation_rate — Amplitude scale for coherent noise (> 0 recommended).
  • quantum_noise_level — Baseline quantum noise variance (≥ 0).
Source

pub fn adaptation_rate(&self) -> f64

Return the adaptation rate.

Source

pub fn quantum_noise_level(&self) -> f64

Return the quantum noise level.

Source

pub fn adapt(&self, params: &Array1<f64>) -> Array1<f64>

Inject quantum-inspired coherent noise into a parameter vector.

Each component pᵢ is perturbed as:

p̃ᵢ = pᵢ + σ · ηᵢ,   ηᵢ ~ N(0, 1)

where σ = adaptation_rate · √(1 + quantum_noise_level).

The resulting perturbations model quantum fluctuations around the current parameter values and can help classical optimisers escape local minima.

§Arguments
  • params — Parameter vector to perturb.
§Returns

A new Array1<f64> with the perturbed parameters.

Source

pub fn anneal(&self, energy: f64, temperature: f64) -> f64

Compute a quantum annealing acceptance probability for an energy transition.

This models the probability that the quantum annealer accepts a move from the current state to a new state with the given energy at the given temperature. The formula is:

P(accept) = exp(-energy / (temperature · (1 + Γ)))

where Γ = quantum_noise_level represents the transverse field strength. Compared with classical Metropolis, the denominator is larger (because Γ > 0), giving a higher acceptance probability — this models quantum tunnelling that can traverse energy barriers classical Metropolis cannot.

§Arguments
  • energy — Current energy (or energy difference) of the proposed state. Positive values correspond to uphill moves.
  • temperature — Current annealing temperature. Must be > 0 for non-trivial acceptance; returns 0.0 for temperature ≤ 0.
§Returns

Acceptance probability in [0, 1].

Source

pub fn decohere( &self, amplitudes: &Array1<f64>, elapsed_time: f64, ) -> SpatialResult<Array1<f64>>

Simulate decoherence on a quantum-state amplitude vector.

Applies an exponential T₂ decay to each amplitude element:

ψ̃ᵢ = ψᵢ · exp(-t / T₂)

where T₂ = 1 / (adaptation_rate · quantum_noise_level + ε) and t is the elapsed (normalised) time.

§Arguments
  • amplitudes — Quantum-state amplitude vector.
  • elapsed_time — Normalised elapsed time in [0, ∞).
§Returns

Decayed amplitude vector. Returns amplitudes unchanged if both adaptation_rate and quantum_noise_level are zero.

§Errors

Returns SpatialError::InvalidInput if elapsed_time < 0.

Source

pub fn smooth_landscape( &self, landscape: &Array1<f64>, ) -> SpatialResult<Array1<f64>>

Smooth a 1-D energy landscape using a Gaussian kernel.

Convolves the energy array with a Gaussian of standard deviation sigma_smooth = adaptation_rate * (landscape.len() as f64).sqrt(), using a finite-support approximation (kernel half-width = 3σ). This emulates the quantum superposition effect: the effective energy at each point is averaged over nearby states weighted by the quantum probability of tunnelling to them.

§Arguments
  • landscape — 1-D energy landscape to smooth.
§Returns

Smoothed energy array of the same length.

§Errors

Returns SpatialError::InvalidInput if the landscape is empty.

Trait Implementations§

Source§

impl Clone for ClassicalAdaptation

Source§

fn clone(&self) -> ClassicalAdaptation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClassicalAdaptation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V