Skip to main content

RestructureOptions

Struct RestructureOptions 

Source
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:

  • SplitOptions controls exact splitting plus any optional final sweep inside the split primitive.
  • SwapOptions controls bond truncation during site-index transport.
  • TruncationOptions can 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: SplitOptions

Options 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: SwapOptions

Options 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

Source

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());
Source

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);
Source

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));
Source

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

Source§

fn clone(&self) -> RestructureOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RestructureOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RestructureOptions

Source§

fn default() -> RestructureOptions

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts 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 more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

impl<T> MaybeSend for T

§

impl<T> MaybeSendSync for T

§

impl<T> MaybeSync for T