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 withadaptation_rateto 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(¶ms);
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
impl ClassicalAdaptation
Sourcepub fn new(adaptation_rate: f64, quantum_noise_level: f64) -> Self
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).
Sourcepub fn adaptation_rate(&self) -> f64
pub fn adaptation_rate(&self) -> f64
Return the adaptation rate.
Sourcepub fn quantum_noise_level(&self) -> f64
pub fn quantum_noise_level(&self) -> f64
Return the quantum noise level.
Sourcepub fn adapt(&self, params: &Array1<f64>) -> Array1<f64>
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.
Sourcepub fn anneal(&self, energy: f64, temperature: f64) -> f64
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; returns0.0fortemperature ≤ 0.
§Returns
Acceptance probability in [0, 1].
Sourcepub fn decohere(
&self,
amplitudes: &Array1<f64>,
elapsed_time: f64,
) -> SpatialResult<Array1<f64>>
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.
Sourcepub fn smooth_landscape(
&self,
landscape: &Array1<f64>,
) -> SpatialResult<Array1<f64>>
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
impl Clone for ClassicalAdaptation
Source§fn clone(&self) -> ClassicalAdaptation
fn clone(&self) -> ClassicalAdaptation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ClassicalAdaptation
impl RefUnwindSafe for ClassicalAdaptation
impl Send for ClassicalAdaptation
impl Sync for ClassicalAdaptation
impl Unpin for ClassicalAdaptation
impl UnsafeUnpin for ClassicalAdaptation
impl UnwindSafe for ClassicalAdaptation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.