mod sketchmap¶
- module sketchmap¶
Sketch-map style nonlinear embedding for collective variables.
Adapted from the sketch-map dimensionality reduction of Ceriotti, Tribello & Parrinello (JCTC 2011 / cosmo-epfl/sketchmap): high-D and low-D distances are transformed by sigmoid switch functions so that only intermediate length scales contribute to the stress, preserving local neighborhoods while discarding uninformative long-range metric noise. We implement a landmark fit to 2-D and a cheap out-of-sample projection for MetaD CVs and TPS basin geometry — not a full MD trajectory analysis stack.
High-D switch (default):
F(r) = 1 - (1 + (2^{a/b}-1)(r/σ)^a )^{-b/a}. Low-D switchGuses the same form with(a', b', σ'). Stress: Σ_{i<j} w_{ij} (F(D_ij) - G(d_ij))^2 over landmark pairs. Out-of-sample: place a new point by minimizing stress vs landmarks with the high-D distances fixed.Variables
- const DEFAULT_A: f64¶
Default high-D sigmoid exponents (sketch-map literature defaults).
- const DEFAULT_A_LOW: f64¶
Default low-D sigmoid a.
- const DEFAULT_B: f64¶
Default high-D sigmoid b.
- const DEFAULT_B_LOW: f64¶
Default low-D sigmoid b.
Functions
- fn farthest_point_landmarks(xs: &[Array1<f64>], max_landmarks: usize) -> Vec<usize>¶
Select up to
max_landmarksdiverse archive points (farthest-point).
- fn median_pairwise(d: ArrayView2<f64>) -> f64¶
Median pairwise distance (for automatic σ).
- fn pairwise_l2(x: ArrayView2<f64>) -> Array2<f64>¶
Pairwise high-D distance matrix (n × n).
- fn row_l2(a: ArrayView1<f64>, b: ArrayView1<f64>) -> f64¶
Euclidean distance between two rows.
- fn sigmoid_switch(r: f64, sigma: f64, a: f64, b: f64) -> f64¶
Sigmoid switch
1 - (1 + (2^{a/b}-1)(r/sigma)^a )^{-b/a}.
Structs and Unions
- struct SketchMap2d¶
Fitted 2-D sketch-map over landmarks.
- landmarks: Array2<f64>¶
Landmark configurations in ambient space, shape (n, dim).
- embedded: Array2<f64>¶
Embedded coordinates, shape (n, 2).
- sigma_high: f64¶
High-D switch scale.
- sigma_low: f64¶
Low-D switch scale.
- a_high: f64¶
High-D sigmoid exponent
a.
- b_high: f64¶
High-D sigmoid exponent
b.
- a_low: f64¶
Low-D sigmoid exponent
a.
- b_low: f64¶
Low-D sigmoid exponent
b.
Implementations
- impl SketchMap2d¶
Functions
- fn fit(points: ArrayView2<f64>, n_iters: usize, lr: f64) -> Option<Self>¶
Fit a 2-D sketch-map to
points(n × dim) by gradient descent on the sketch-map stress, initialized from classical MDS on the high-D switched dissimilarities.
- fn linearize_projector(&self, eps: f64) -> (Array2<f64>, Array1<f64>, [f64; 2], [f64; 2])¶
Build a linear projector approximating the sketch-map near the landmark mean (Jacobian via finite differences) for use with
crate::bias::WellTemperedBias.Returns
(projector dim×2, mu, cv_low, cv_high).
- fn project(&self, x: ArrayView1<f64>, n_iters: usize) -> Array1<f64>¶
Out-of-sample projection of
xinto the 2-D map by minimizing sketch-map stress against landmarks (few GD steps from nearest landmark).