pub struct RestructureOptions {
pub split: SplitOptions,
pub swap: SwapOptions,
pub final_truncation: Option<TruncationOptions>,
}Expand description
Options for TreeTN::restructure_to multi-phase restructures.
RestructureOptions combines the three phases in the approved B2a design:
a split/refinement phase, a site-transport phase, and an optional final
truncation sweep after the target structure has been assembled.
Related types:
SplitOptionscontrols exact splitting plus any optional final sweep inside the split primitive.SwapOptionscontrols bond truncation during site-index transport.TruncationOptionscan be applied once at the end of the full restructure to clean up bond dimensions on the final topology.
When in doubt, start with RestructureOptions::default(): exact splitting,
exact transport, and no extra final truncation sweep.
§Examples
use tensor4all_treetn::{
RestructureOptions, SplitOptions, SwapOptions, TruncationOptions,
};
use tensor4all_core::SvdTruncationPolicy;
let options = RestructureOptions::new()
.with_split(SplitOptions::new().with_max_rank(32))
.with_swap(SwapOptions {
max_rank: Some(16),
rtol: Some(1e-10),
})
.with_final_truncation(
TruncationOptions::new().with_svd_policy(SvdTruncationPolicy::new(1e-12)),
);
assert_eq!(options.split.max_rank(), Some(32));
assert!(!options.split.final_sweep);
assert_eq!(options.swap.max_rank, Some(16));
assert_eq!(options.swap.rtol, Some(1e-10));
assert_eq!(
options
.final_truncation
.as_ref()
.and_then(TruncationOptions::svd_policy),
Some(SvdTruncationPolicy::new(1e-12))
);Fields§
§split: SplitOptionsOptions for the split/refinement phase.
These settings matter when a current node must be factored into multiple
fragments before any fragment movement can happen. Higher max_rank,
stricter svd_policy, and smaller qr_rtol preserve more fidelity but
can increase intermediate bond dimensions. final_sweep should usually
remain false here unless a split-only workflow is being optimized in
isolation.
swap: SwapOptionsOptions for the site-transport / swap phase.
This phase only moves already planned fragments across existing edges.
Leaving both fields unset keeps swaps exact. Setting max_rank or
rtol can control intermediate rank growth, but may introduce
approximation earlier than the optional final truncation sweep.
final_truncation: Option<TruncationOptions>Optional final truncation sweep on the fully restructured network.
Use this when the split and swap phases should remain as exact as
possible, and compression should happen only after the target topology
and grouping have been reached. None disables this cleanup pass.
Implementations§
Source§impl RestructureOptions
impl RestructureOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Create options with exact split/swap phases and no final cleanup sweep.
§Returns
A RestructureOptions value equivalent to Default::default.
§Examples
use tensor4all_treetn::RestructureOptions;
let options = RestructureOptions::new();
assert!(!options.split.final_sweep);
assert_eq!(options.swap.max_rank, None);
assert_eq!(options.swap.rtol, None);
assert!(options.final_truncation.is_none());Sourcepub fn with_split(self, split: SplitOptions) -> Self
pub fn with_split(self, split: SplitOptions) -> Self
Replace the split-phase options.
§Arguments
split- Split/refinement settings used before fragment transport.
§Returns
Updated restructure options using the provided split settings.
§Examples
use tensor4all_treetn::{RestructureOptions, SplitOptions};
let options = RestructureOptions::new()
.with_split(SplitOptions::new().with_max_rank(24).with_final_sweep(true));
assert_eq!(options.split.max_rank(), Some(24));
assert!(options.split.final_sweep);Sourcepub fn with_swap(self, swap: SwapOptions) -> Self
pub fn with_swap(self, swap: SwapOptions) -> Self
Replace the swap/transport options.
§Arguments
swap- Truncation settings applied during fragment movement.
§Returns
Updated restructure options using the provided swap settings.
§Examples
use tensor4all_treetn::{RestructureOptions, SwapOptions};
let options = RestructureOptions::new().with_swap(SwapOptions {
max_rank: Some(12),
rtol: Some(1e-8),
});
assert_eq!(options.swap.max_rank, Some(12));
assert_eq!(options.swap.rtol, Some(1e-8));Sourcepub fn with_final_truncation(self, final_truncation: TruncationOptions) -> Self
pub fn with_final_truncation(self, final_truncation: TruncationOptions) -> Self
Set the optional final truncation sweep.
§Arguments
final_truncation- Final cleanup sweep to run on the target topology.
§Returns
Updated restructure options using the provided final sweep settings.
§Examples
use tensor4all_treetn::{RestructureOptions, TruncationOptions};
use tensor4all_core::SvdTruncationPolicy;
let options = RestructureOptions::new()
.with_final_truncation(
TruncationOptions::new()
.with_max_rank(10)
.with_svd_policy(SvdTruncationPolicy::new(1e-10)),
);
assert_eq!(
options
.final_truncation
.as_ref()
.and_then(TruncationOptions::max_rank),
Some(10)
);Trait Implementations§
Source§impl Clone for RestructureOptions
impl Clone for RestructureOptions
Source§fn clone(&self) -> RestructureOptions
fn clone(&self) -> RestructureOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RestructureOptions
impl Debug for RestructureOptions
Source§impl Default for RestructureOptions
impl Default for RestructureOptions
Source§fn default() -> RestructureOptions
fn default() -> RestructureOptions
Auto Trait Implementations§
impl Freeze for RestructureOptions
impl RefUnwindSafe for RestructureOptions
impl Send for RestructureOptions
impl Sync for RestructureOptions
impl Unpin for RestructureOptions
impl UnsafeUnpin for RestructureOptions
impl UnwindSafe for RestructureOptions
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>,
§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