pub struct AdditiveSurrogate { /* private fields */ }Expand description
A separable rank-1 Chebyshev energy model c + sum_j g_j(x_j).
Implementations§
Source§impl AdditiveSurrogate
impl AdditiveSurrogate
Sourcepub fn fit(
x: ArrayView2<'_, f64>,
y: ArrayView1<'_, f64>,
bounds: Bounds<f64>,
degree: usize,
) -> Self
pub fn fit( x: ArrayView2<'_, f64>, y: ArrayView1<'_, f64>, bounds: Bounds<f64>, degree: usize, ) -> Self
Fit the surrogate to pilot points x (n x d) and values y (n) with
a default of 12 backfitting passes.
Sourcepub fn fit_backfit(
x: ArrayView2<'_, f64>,
y: ArrayView1<'_, f64>,
bounds: Bounds<f64>,
degree: usize,
n_passes: usize,
) -> Self
pub fn fit_backfit( x: ArrayView2<'_, f64>, y: ArrayView1<'_, f64>, bounds: Bounds<f64>, degree: usize, n_passes: usize, ) -> Self
Fit by backfitting (Gauss-Seidel over coordinates).
The intercept is the pilot mean. Each coordinate’s Chebyshev coefficients
are refit in turn against the partial residual y - intercept - sum_{l != j} g_l, on a mean-centred design so the fit is consistent
under uniform sampling. Sweeping all coordinates n_passes times removes
the finite-sample cross-coordinate contamination that an independent
per-coordinate fit leaves behind, converging to the joint least-squares
additive model while staying O(n_passes d (n degree + degree^3)) –
linear in d, unlike the joint solve. Each coordinate’s Gram factor is
cached, so a pass costs only one triangular solve per coordinate.
Panics when shapes disagree or degree == 0.
Sourcepub fn value(&self, x: ArrayView1<'_, f64>) -> f64
pub fn value(&self, x: ArrayView1<'_, f64>) -> f64
Surrogate value at full point x.
Sourcepub fn gradient(&self, x: ArrayView1<'_, f64>) -> Array1<f64>
pub fn gradient(&self, x: ArrayView1<'_, f64>) -> Array1<f64>
Analytic gradient of the separable surrogate at x.
Sourcepub fn sample<R: Rng + ?Sized>(
&self,
n: usize,
temperature: f64,
grid_m: usize,
rng: &mut R,
) -> Array2<f64>
pub fn sample<R: Rng + ?Sized>( &self, n: usize, temperature: f64, grid_m: usize, rng: &mut R, ) -> Array2<f64>
Draw n independence proposals from the tempered surrogate density
exp(-(f - f_min)/T) by per-coordinate inverse-CDF sampling on an
grid_m-point grid. Each coordinate is sampled independently (the
separable factorisation), with a uniform within-cell jitter for
continuity. Returns an n x d array of points inside the box.
Trait Implementations§
Source§impl DifferentiableObjective<f64> for AdditiveSurrogate
impl DifferentiableObjective<f64> for AdditiveSurrogate
Source§fn value_and_gradient(&self, x: ArrayView1<'_, T>) -> (T, Array1<T>)
fn value_and_gradient(&self, x: ArrayView1<'_, T>) -> (T, Array1<T>)
(f(x), ∇f(x)). Default calls the two methods separately;
analytic implementations should override for efficiency.Source§impl Gradient<f64> for AdditiveSurrogate
impl Gradient<f64> for AdditiveSurrogate
Source§impl Objective<f64> for AdditiveSurrogate
impl Objective<f64> for AdditiveSurrogate
Source§fn eval_batch(&self, x: ArrayView2<'_, T>) -> Array1<T>
fn eval_batch(&self, x: ArrayView2<'_, T>) -> Array1<T>
x). Read moreSource§fn global_min(&self) -> Option<&FPair<T>>
fn global_min(&self) -> Option<&FPair<T>>
None.Auto Trait Implementations§
impl Forget for AdditiveSurrogate
impl Freeze for AdditiveSurrogate
impl RefUnwindSafe for AdditiveSurrogate
impl Send for AdditiveSurrogate
impl Sync for AdditiveSurrogate
impl Unpin for AdditiveSurrogate
impl UnsafeUnpin for AdditiveSurrogate
impl UnwindSafe for AdditiveSurrogate
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> 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 more