pub struct TCI2Options {Show 13 fields
pub tolerance: f64,
pub max_iter: usize,
pub max_bond_dim: usize,
pub pivot_search: PivotSearchStrategy,
pub normalize_error: bool,
pub verbosity: usize,
pub max_nglobal_pivot: usize,
pub nsearch: usize,
pub sweep_strategy: Sweep2Strategy,
pub ncheck_history: usize,
pub strictly_nested: bool,
pub tol_margin_global_search: f64,
pub seed: Option<u64>,
}Expand description
Configuration for the TCI2 algorithm (crossinterpolate2).
Controls convergence criteria, bond dimension limits, pivot search strategy, and global pivot search parameters.
§Recommended starting point
For most problems the defaults work well. The fields you will most commonly adjust are:
| Field | Typical range | Purpose |
|---|---|---|
tolerance | 1e-6 – 1e-12 | Relative convergence threshold |
max_bond_dim | 50 – 500 | Hard cap on bond dimension |
max_iter | 20 – 100 | Maximum number of half-sweeps |
seed | Some(42) | Fix seed for reproducibility |
§Convergence criterion
The algorithm stops when all of the following hold for
ncheck_history consecutive iterations:
- The normalized bond error is below
tolerance. - No global pivots were added.
- The rank is stable.
Alternatively, it stops when the rank reaches max_bond_dim.
§Examples
use tensor4all_tensorci::TCI2Options;
// Default options
let opts = TCI2Options::default();
assert!((opts.tolerance - 1e-8).abs() < 1e-15);
assert_eq!(opts.max_iter, 20);
assert_eq!(opts.max_bond_dim, usize::MAX);
assert_eq!(opts.verbosity, 0);
// Custom options via struct update syntax
let custom = TCI2Options {
tolerance: 1e-12,
max_bond_dim: 100,
seed: Some(42),
..TCI2Options::default()
};
assert!((custom.tolerance - 1e-12).abs() < 1e-20);
assert_eq!(custom.max_bond_dim, 100);
assert_eq!(custom.seed, Some(42));Fields§
§tolerance: f64Convergence tolerance (default: 1e-8).
When normalize_error is enabled (the default), this is the
relative threshold: the bond error is divided by the maximum
absolute function value seen so far. Typical choices are 1e-8 for
moderate accuracy and 1e-12 for high accuracy.
max_iter: usizeMaximum number of half-sweep iterations (default: 20).
Each iteration performs one forward or backward two-site sweep followed by a global pivot search. Increase if the function is difficult to converge.
max_bond_dim: usizeHard upper bound on bond dimension (default: usize::MAX, i.e. no limit).
The algorithm stops early once the rank reaches this value. For
expensive functions, setting this to 50–500 avoids runaway
computation.
pivot_search: PivotSearchStrategyPivot search strategy (default: PivotSearchStrategy::Full).
Full materializes the entire candidate matrix and finds the best
pivot exactly. Rook uses lazy block-rook search and is faster for
very large local dimensions but may miss some pivots.
normalize_error: boolWhether to normalize the bond error by the maximum observed sample
value (default: true).
When enabled, tolerance acts as a relative threshold. Disable
to use tolerance as an absolute threshold.
verbosity: usizeVerbosity level (default: 0 = silent).
1 prints per-iteration summaries, 2 adds per-bond details.
max_nglobal_pivot: usizeMaximum number of global pivots to add per iteration (default: 5).
nsearch: usizeNumber of random starting points for global pivot search (default: 5).
Each starting point undergoes local optimization to find regions of high interpolation error.
sweep_strategy: Sweep2StrategySweep strategy for 2-site sweeps (default: Sweep2Strategy::BackAndForth).
ncheck_history: usizeNumber of recent iterations checked for convergence (default: 3).
The algorithm requires ncheck_history consecutive converged
iterations before declaring convergence.
strictly_nested: boolWhether to use strictly nested index sets (default: false).
When false, the algorithm keeps a history of previous index sets
and merges them during sweeps, which generally improves convergence.
tol_margin_global_search: f64Tolerance margin for global pivot search (default: 10.0).
Global pivots are accepted when their error exceeds
abs_tolerance * tol_margin_global_search.
seed: Option<u64>Random seed for reproducibility (default: None = OS entropy).
Set to Some(seed) for deterministic results.
Trait Implementations§
Source§impl Clone for TCI2Options
impl Clone for TCI2Options
Source§fn clone(&self) -> TCI2Options
fn clone(&self) -> TCI2Options
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TCI2Options
impl Debug for TCI2Options
Auto Trait Implementations§
impl Freeze for TCI2Options
impl RefUnwindSafe for TCI2Options
impl Send for TCI2Options
impl Sync for TCI2Options
impl Unpin for TCI2Options
impl UnsafeUnpin for TCI2Options
impl UnwindSafe for TCI2Options
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
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