Library


SpinGlassPEPS.SpinGlassEngine.empty_solutionFunction
empty_solution(::Type{T}) -> Solution
empty_solution(::Type{T}, n::Int64) -> Solution

Create an empty Solution object with a specified number of states.

This function creates an empty Solution object with the given number of states, initializing its fields with default values.

Arguments

  • n::Int: The number of states for which the Solution object is created.

Returns

An empty Solution object with default field values, ready to store search results for a specified number of states.

source
SpinGlassPEPS.SpinGlassEngine.gibbs_samplingFunction
gibbs_sampling(
    ctr::MpsContractor{T, R, S},
    sparams::SearchParameters;
    ...
) -> Solution
gibbs_sampling(
    ctr::MpsContractor{T, R, S},
    sparams::SearchParameters,
    merge_strategy;
    no_cache,
    show_progress
) -> Solution

Perform Gibbs sampling on a spin glass PEPS network.

This function performs Gibbs sampling on a spin glass PEPS (Projected Entangled Pair State) network using a branch-and-bound search algorithm. It takes as input a ctr object representing the PEPS network, sparams specifying search parameters, and merge_strategy for merging branches. Optionally, you can disable caching using the no_cache flag.

Arguments

  • ctr::AbstractContractor: The contractor object representing the PEPS network, which should be a subtype of AbstractContractor.
  • sparams::SearchParameters: Parameters for controlling the search, including the maximum number of states and a cutoff probability.
  • merge_strategy=no_merge: (Optional) Merge strategy for branches. Defaults to no_merge.
  • no_cache=false: (Optional) If true, disables caching. Defaults to false.
  • show_progress=true: (Optional) Display the preprocessing and search progress bars. Set to false when sampling concurrently, since interleaved bars are unreadable.

Returns

A Solution object representing the result of the Gibbs sampling.

source
SpinGlassPEPS.SpinGlassEngine.bound_solutionFunction
bound_solution(
    psol::Solution,
    max_states::Int64,
    δprob::Real
) -> Solution
bound_solution(
    psol::Solution,
    max_states::Int64,
    δprob::Real,
    merge_strategy
) -> Solution

Bound the solution to a specified number of states while discarding low-probability states.

This function takes a Solution object psol, bounds it to a specified number of states max_states, and discards low-probability states based on the probability threshold δprob. You can specify a merge_strategy for merging branches in the psol object.

Arguments

  • psol::Solution: A Solution object representing the solution to be bounded.
  • max_states::Int: The maximum number of states to retain in the bounded solution.
  • δprob::Real: The probability threshold for discarding low-probability states.
  • merge_strategy=no_merge: (Optional) Merge strategy for branches. Defaults to no_merge.

Returns

A Solution object representing the bounded solution with a maximum of max_states states.

source
SpinGlassPEPS.SpinGlassEngine.no_mergeFunction
no_merge(partial_sol::Solution) -> Solution

No-op merge function that returns the input partial_sol as is.

This function is a no-op merge function that takes a Solution object partial_sol as input and returns it unchanged. It is used as a merge strategy when you do not want to perform any merging of branches in a solution.

Arguments

  • partial_sol::Solution: A Solution object representing partial solutions.

Returns

The input partial_sol object, unchanged.

source
SpinGlassPEPS.SpinGlassEngine.branch_energyFunction
branch_energy(
    ctr::MpsContractor{T},
    eσ::Tuple{Real, AbstractVector{Int64}}
) -> Any

Calculates the energy contribution of a branch given a base energy and a spin configuration.

This function calculates the energy contribution of a branch in a SpinGlassPEPS calculation. It takes a MpsContractor object ctr and a tuple containing a base energy as the first element and a spin configuration represented as a vector of integers as the second element. The function calculates the branch energy by adding the base energy to the energy contribution of the given spin configuration obtained from the update_energy function.

Arguments

  • ctr::MpsContractor{T}: An instance of the MpsContractor type parameterized by the strategy type T.
  • eσ::Tuple{<:Real, Vector{Int}}: A tuple containing the base energy as the first element (a real number)

and the spin configuration as the second element (a vector of integers).

Returns

The branch energy, which is the sum of the base energy and the energy contribution of the spin configuration.

source

Core

SpinGlassPEPS.SpinGlassEngine.error_measureFunction
error_measure(probs) -> Any

Calculate an error measure based on the given probability distribution.

Arguments

  • probs: An array representing a probability distribution.

Description

The error_measure function calculates an error measure based on the provided probability distribution. The error measure is designed to capture discrepancies or irregularities in the distribution. The function checks for extreme cases, such as when the maximum probability less or equal zero, and returns a predefined value (2.0). If the minimum probability is negative, the error measure is calculated as the absolute value of the minimum probability divided by the maximum absolute value of the probabilities. If neither of these conditions is met, the error measure is set to 0.0. The error measure provides a quantitative assessment of the deviation from a well-behaved probability distribution, helping to identify potential issues or anomalies.

source
SpinGlassPEPS.SpinGlassEngine.conditional_probabilityFunction
conditional_probability(
    _::Type{T<:SquareSingleNode},
    ctr::MpsContractor{S},
    ∂v::Vector{Int64}
) -> Any

Calculates conditional probability for a SquareSingleNode Layout.

source
conditional_probability(
    _::Type{T<:SquareCrossDoubleNode},
    ctr::MpsContractor{S},
    ∂v::Vector{Int64}
) -> Any

Compute the conditional probability of states for a square cross double node tensor geometry.

Arguments

  • ::Type{T}: Type representing a square cross double node tensor network.
  • ctr::MpsContractor{S}: Tensor contractor for the tensor network.
  • ∂v::Vector{Int}: Vector of indices representing the contracted environment indices.

Returns

  • Vector{Float64}: Conditional probabilities for different states.

Description

The conditional_probability function computes the conditional probabilities of different states for a specified square cross double node tensor geometry. It takes into account the geometry of the tensor network, interaction energies, and precomputed values. The function supports both left and right environments, and the resulting probabilities are normalized. The function is specialized for the SquareCrossDoubleNode tensor network type and is parametrized by the layout type S of the contractor.

source
conditional_probability(
    ctr::MpsContractor{S},
    w::Vector{Int64}
) -> Any

Calculate the conditional probability of a given state within the context of an MPS (Matrix Product State) contractor.

Arguments

  • ctr::MpsContractor{S}: An MPS contractor representing the contracted state and associated parameters.
  • w::Vector{Int}: A vector representing the encoded state.

Returns

  • Vector{Float64}: The calculated conditional probabilities for each possible outcome.

Description

The conditional_probability function calculates the conditional probability distribution of a given state within the context of an MPS contractor. It delegates the calculation to the conditional_probability function with a specified tensor layout using the layout function. This function is a convenience wrapper that allows users to calculate conditional probabilities without explicitly specifying the tensor layout.

source
SpinGlassPEPS.SpinGlassEngine.update_energyFunction
update_energy(
    _::Type{T<:SquareCrossDoubleNode},
    ctr::MpsContractor{S},
    σ::AbstractVector{Int64}
) -> Any

Update the energy of a specific tensor node in a matrix product states (MPS).

Arguments

  • T::Type: Tensor network type, specialized for SquareCrossDoubleNode.
  • ctr::MpsContractor{S}: MPS tensor network contractor containing relevant information for contraction.
  • σ::Vector{Int}: State vector representing the current configuration of the tensor network.

Returns

  • Real: Updated energy value for the specified tensor node.

Description

The update_energy function calculates the energy contribution of a specific tensor node in a matrix product states (MPS). The energy is computed based on the local energy at the node and the interaction energies with its neighboring nodes, considering the provided state vector σ. The function is specialized for the SquareCrossDoubleNode tensor network type and is parametrized by the layout type S.

source
update_energy(
    ctr::MpsContractor{S},
    w::AbstractVector{Int64}
) -> Any

Update the energy associated with the current state within the context of an MPS (Matrix Product State) contractor.

Arguments

  • ctr::MpsContractor{S}: An MPS contractor representing the contracted state and associated parameters.
  • w::Vector{Int}: A vector representing the encoded state.

Description

The update_energy function updates the energy associated with the current state within the context of an MPS contractor. It delegates the calculation to the update_energy function with a specified tensor layout using the layout function. This function is a convenience wrapper that allows users to update the energy without explicitly specifying the tensor layout.

source
SpinGlassPEPS.SpinGlassEngine.boundaryFunction
boundary(
    _::Type{T<:SquareCrossDoubleNode},
    ctr::MpsContractor{S},
    node::NTuple{N, Int64} where N
) -> Any

Compute the boundary states for a specific node in a matrix product states (MPS).

Arguments

  • T::Type: Tensor network type, specialized for SquareCrossDoubleNode.
  • ctr::MpsContractor{S}: MPS tensor network contractor containing relevant information.
  • node::Node: Tuple representing the coordinates of the node in the tensor network.

Returns

  • Vector{Tuple{Tuple, Tuple}}: Vector of tuples representing the boundary states for the given node.

Each tuple contains pairs of indices representing connected sites in the tensor network.

Description

The boundary function computes the boundary states for a specific node in a matrix product states (MPS). The boundary states are determined by analyzing the connections between the current node and its neighboring nodes, considering different physical indices. The function is specialized for the SquareCrossDoubleNode tensor network type and is parametrized by the layout type S.

source
SpinGlassPEPS.SpinGlassEngine.boundary_indicesFunction
boundary_indices(
    ctr::MpsContractor{T},
    nodes::Union{NTuple{4, S}, Tuple{S, Tuple{S, S}, S, Tuple{S, S}}},
    states::AbstractVector{<:AbstractVector{Int64}}
) -> Any

boundary index formed from outer product of two projectors

source

Contractor

SpinGlassPEPS.SpinGlassEngine.ContractionCacheType

Contractor-owned cache replacing the process-global Memoization dictionaries: boundary MPS/MPO per row, dressed MPS, left/right environments keyed by the boundary configuration, and per-node precomputed conditionals. Owning the cache makes eviction explicit (empty_row_caches!, clear_memoize_cache(ctr, row)), keeps GPU memory attributable to a contractor, and removes the thread-unsafe global state that blocked parallel sweeps.

source
SpinGlassPEPS.SpinGlassEngine.MpoLayersType

A struct representing different layers of a Matrix Product Operator (MPO) used in contraction algorithms.

Fields

  • main::Dict{Site, Sites}: A dictionary mapping sites to the main layers of the MPO.
  • dress::Dict{Site, Sites}: A dictionary mapping sites to the dress layers of the MPO.
  • right::Dict{Site, Sites}: A dictionary mapping sites to the right layers of the MPO.

The MpoLayers struct distinguishes the various layers of an MPO, which is often used in tensor network contraction algorithms. MPOs are commonly employed in quantum many-body physics and condensed matter physics to represent operators acting on quantum states in a factorized form.

source
SpinGlassPEPS.SpinGlassEngine.layoutFunction
layout(net::PEPSNetwork{T, S}) -> Any

A function that provides the layout used to construct the PEPS (Projected Entangled Pair States) network.

Arguments

  • net::PEPSNetwork{T, S}: The PEPS network for which the layout is provided.

Returns

  • The layout type T used to construct the PEPS network.

The layout function returns the layout type used in the construction of a PEPS network. This layout type specifies the geometric arrangement and sparsity pattern of the tensors in the PEPS network.

source
SpinGlassPEPS.SpinGlassEngine.sparsityFunction
sparsity(net::PEPSNetwork{T, S}) -> Any

A function that provides the sparsity used to construct the PEPS (Projected Entangled Pair States) network.

Arguments

  • net::PEPSNetwork{T, S}: The PEPS network for which the sparsity is provided.

Returns

  • The sparsity type S used to construct the PEPS network.

The sparsity function returns the sparsity type used in the construction of a PEPS network. This sparsity type specifies the pattern of zero elements in the tensors of the PEPS network, which can affect the computational efficiency and properties of the network.

source
SpinGlassPEPS.SpinGlassEngine.strategyFunction
strategy(_::MpsContractor{T}) -> Any

Get the strategy used to contract the PEPS network.

Arguments

  • ::MpsContractor{T}: The MpsContractor object representing the PEPS network contraction.

Returns

  • T: The strategy used for network contraction.
source
SpinGlassPEPS.SpinGlassEngine.mpoFunction
mpo(
    ctr::MpsContractor{T<:SpinGlassPEPS.SpinGlassEngine.AbstractStrategy, R, S},
    layers::Dict{Union{Rational{Int64}, Int64}, NTuple{N, Union{Rational{Int64}, Int64}} where N},
    r::Int64
) -> QMpo{S} where S

Construct and memoize a Matrix Product Operator (MPO) for a given set of layers.

Arguments

  • ctr::MpsContractor{T}: The MpsContractor object representing the PEPS network contraction.
  • layers::Dict{Site, Sites}: A dictionary mapping sites to their corresponding layers.
  • r::Int: The current row index.

Returns

  • QMpo: The constructed MPO for the specified layers.

This function constructs an MPO by iterating through the specified layers and assembling the corresponding tensors. The resulting MPO is memoized for efficient reuse.

source
SpinGlassPEPS.SpinGlassEngine.mps_topFunction
mps_top(
    ctr::MpsContractor{SVDTruncate, R, S},
    i::Int64
) -> QMps{S} where S

Construct and memoize the top Matrix Product State (MPS) using Singular Value Decomposition (SVD) for a given row.

Arguments

  • ctr::MpsContractor{SVDTruncate}: The MpsContractor object representing the PEPS network contraction with SVD truncation.
  • i::Int: The current row index.

Returns

  • QMps: The constructed top MPS for the specified row.

This function constructs the top MPS using SVD for a given row in the PEPS network contraction. It recursively builds the MPS row by row, performing canonicalization, truncation, and compression steps as needed based on the specified parameters in ctr.params. The resulting MPS is memoized for efficient reuse.

source
mps_top(
    ctr::MpsContractor{Zipper, R, S},
    i::Int64
) -> QMps{S} where S

Construct and memoize the top Matrix Product State (MPS) using the Zipper (truncated Singular Value Decomposition) method for a given row.

Arguments

  • ctr::MpsContractor{Zipper}: The MpsContractor object representing the PEPS network contraction with the Zipper method.
  • i::Int: The current row index.

Returns

  • QMps: The constructed top MPS using the Zipper method for the specified row.

This function constructs the top Matrix Product State (MPS) using the Zipper (truncated Singular Value Decomposition) method for a given row in the PEPS network contraction. It recursively builds the MPS row by row, performing canonicalization, and truncation steps based on the specified parameters in ctr.params. The resulting MPS is memoized for efficient reuse.

source
SpinGlassPEPS.SpinGlassEngine.mpsFunction
mps(ctr::MpsContractor{SVDTruncate, R, S}, i::Int64) -> Any

Construct and memoize the (bottom) Matrix Product State (MPS) using Singular Value Decomposition (SVD) for a given row.

Arguments

  • ctr::MpsContractor{SVDTruncate}: The MpsContractor object representing the PEPS network contraction with SVD truncation.
  • i::Int: The current row index.

Returns

  • QMps: The constructed (bottom) MPS for the specified row.

This function constructs the (bottom) MPS using SVD for a given row in the PEPS network contraction. It recursively builds the MPS row by row, performing canonicalization, truncation, and compression steps as needed based on the specified parameters in ctr.params. The resulting MPS is memoized for efficient reuse.

source
mps(ctr::MpsContractor{Zipper, R, S}, i::Int64) -> Any

Construct and memoize the (bottom) Matrix Product State (MPS) using the Zipper (truncated Singular Value Decomposition) method for a given row.

Arguments

  • ctr::MpsContractor{Zipper}: The MpsContractor object representing the PEPS network contraction with the Zipper method.
  • i::Int: The current row index.

Returns

  • QMps: The constructed (bottom) MPS using the Zipper method for the specified row.

This function constructs the (bottom) Matrix Product State (MPS) using the Zipper (truncated Singular Value Decomposition) method for a given row in the PEPS network contraction. It recursively builds the MPS row by row, performing canonicalization, and truncation steps based on the specified parameters in ctr.params. The resulting MPS is memoized for efficient reuse.

source
SpinGlassPEPS.SpinGlassEngine.mps_approxFunction
mps_approx(
    ctr::MpsContractor{SVDTruncate, R, S},
    i::Int64
) -> QMps{S} where S

Construct and memoize the (bottom) Matrix Product State (MPS) approximation using Singular Value Decomposition (SVD) for a given row.

Arguments

  • ctr::MpsContractor{SVDTruncate}: The MpsContractor object representing the PEPS network contraction with SVD truncation.
  • i::Int: The current row index.

Returns

  • QMps: The constructed (bottom) MPS approximation for the specified row.

This function constructs the (bottom) MPS approximation using SVD for a given row in the PEPS network contraction. It recursively builds the MPS row by row, performing canonicalization, and truncation steps based on the specified parameters in ctr.params. The resulting MPS approximation is memoized for efficient reuse.

source
SpinGlassPEPS.SpinGlassEngine.dressed_mpsFunction
dressed_mps(
    ctr::MpsContractor{T<:SpinGlassPEPS.SpinGlassEngine.AbstractStrategy},
    i::Int64
) -> QMps

Construct (and memoize) dressed Matrix Product State (MPS) for a given row and strategy.

Arguments

  • ctr::MpsContractor{T}: The MpsContractor object representing the PEPS network contraction.
  • i::Int: The current row index.

Returns

  • QMps: The constructed dressed MPS for the specified row and strategy.

This function constructs the dressed Matrix Product State (MPS) for a given row in the PEPS network contraction using the specified strategy and memoizes the result for future use. It internally calls other functions such as mps and mpo to construct the dressed MPS. Additionally, it normalizes the MPS tensors to ensure numerical stability.

Note: The memoization ensures that the dressed MPS is only constructed once for each combination of arguments and is reused when needed.

source
SpinGlassPEPS.SpinGlassEngine.right_envFunction
right_env(
    ctr::MpsContractor{T<:SpinGlassPEPS.SpinGlassEngine.AbstractStrategy, R, S},
    i::Int64,
    ∂v::Vector{Int64}
) -> Any

Construct (and memoize) the right environment tensor for a given node in the PEPS network contraction.

Arguments

  • ctr::MpsContractor{T}: The MpsContractor object representing the PEPS network contraction.
  • i::Int: The current row index.
  • ∂v::Vector{Int}: A vector representing the partial environment configuration.

Returns

  • Array{S,2}: The constructed right environment tensor for the specified node.

This function constructs the right environment tensor for a given node in the PEPS network contraction using the specified strategy and memoizes the result for future use. It internally calls other functions such as dressed_mps and mpo to construct the right environment tensor. Additionally, it normalizes the right environment tensor to ensure numerical stability.

Note: The memoization ensures that the right environment tensor is only constructed once for each combination of arguments and is reused when needed.

source
SpinGlassPEPS.SpinGlassEngine.left_envFunction
left_env(
    ctr::MpsContractor{T, R, S},
    i::Int64,
    ∂v::Vector{Int64}
) -> Any

Construct (and memoize) the left environment tensor for a given node in the PEPS network contraction.

Arguments

  • ctr::MpsContractor{T}: The MpsContractor object representing the PEPS network contraction.
  • i::Int: The current row index.
  • ∂v::Vector{Int}: A vector representing the partial environment configuration.

Returns

  • Array{S,2}: The constructed left environment tensor for the specified node.

This function constructs the left environment tensor for a given node in the PEPS network contraction using the specified strategy and memoizes the result for future use. It internally calls other functions such as dressed_mps to construct the left environment tensor. Additionally, it normalizes the left environment tensor to ensure numerical stability.

Note: The memoization ensures that the left environment tensor is only constructed once for each combination of arguments and is reused when needed.

source
SpinGlassPEPS.SpinGlassEngine.clear_memoize_cacheFunction
clear_memoize_cache()

Clear all memoization caches used by the PEPS network contraction.

This function clears all memoization caches that store previously computed results for various operations and environments in the PEPS network contraction. Memoization is used to optimize the contraction process by avoiding redundant computations. Calling this function removes all cached results, which can be useful when you want to free up memory or ensure that the caches are refreshed with updated data.

source
clear_memoize_cache(
    ctr::MpsContractor{T, S},
    row::Union{Rational{Int64}, Int64}
)

Clear memoization cache for specific operations for a given row and index beta.

This function clears the memoization cache for specific operations used in the PEPS network contraction for a given row. The cleared operations include mps_top, mps, mpo, dressed_mps, and related operations. Memoization is used to optimize the contraction process by avoiding redundant computations. Calling this function allows you to clear the cache for these specific operations for a particular row and index beta, which can be useful when you want to free up memory or ensure that the cache is refreshed with updated data for a specific computation.

Arguments

  • ctr::MpsContractor{T, S}: The PEPS network contractor object.
  • row::Site: The row for which the cache should be cleared.
source
SpinGlassPEPS.SpinGlassEngine.clear_memoize_cache_after_rowFunction
clear_memoize_cache_after_row()

Clear memoization caches for specific operations after processing a row. This function clears the memoization caches for specific operations used in the PEPS network contraction after processing a row. The cleared operations include left_env, right_env, mpo, and dressed_mps. Memoization is used to optimize the contraction process by avoiding redundant computations. Calling this function allows you to clear the caches for these specific operations, which can be useful when you want to free up memory or ensure that the caches are refreshed with updated data after processing a row in the contraction.

source

Operations

SpinGlassPEPS.SpinGlassEngine.vertex_mapFunction
vertex_map(
    trans::LatticeTransformation,
    m::Int64,
    n::Int64
) -> SpinGlassPEPS.SpinGlassEngine.VertexMap

Create a vertex map function based on a given lattice transformation.

This function generates a vertex map function that can be used to transform lattice vertex coordinates according to a specified lattice transformation. The trans argument should be a LatticeTransformation object, and m and n specify the dimensions of the lattice.

Arguments

  • trans::LatticeTransformation: The lattice transformation to apply.
  • m::Int: The number of rows in the lattice.
  • n::Int: The number of columns in the lattice.

Returns

A vertex map function that takes vertex coordinates and returns the transformed coordinates.

source
SpinGlassPEPS.SpinGlassEngine.check_boundsFunction
check_bounds(
    m,
    n
) -> SpinGlassPEPS.SpinGlassEngine.var"#_check#check_bounds##0"

Create a bounds-checking function for a lattice of size (m, n).

Arguments

  • m::Int: The number of rows in the lattice.
  • n::Int: The number of columns in the lattice.

Returns

A bounds-checking function that can be used to ensure that lattice points are within the specified bounds.

source
SpinGlassPEPS.SpinGlassEngine.LatticeTransformationType

A struct representing a lattice transformation.

Fields

  • permutation::NTuple{4, Int}: A tuple defining a permutation of the vertex labels.
  • flips_dimensions::Bool: A boolean indicating whether dimension flips are applied.

The LatticeTransformation struct defines a transformation that can be applied to the vertices of a lattice. It specifies a permutation of vertex labels, allowing for rotations and reflections, as well as an option to flip dimensions.

source

Droplets

SpinGlassPEPS.SpinGlassEngine.FlipType

A data structure representing a set of flips or changes in states for nodes in the SpinGlassPEPS package.

A Flip object contains information about the support, state changes, and spinxor values for a set of node flips in the SpinGlassPEPS system.

Fields

  • support::Vector{Int}: An array of integers representing the indices of nodes where flips occur.
  • state::Vector{Int}: An array of integers representing the new states for the nodes in the support.
  • spinxor::Vector{Int}: An array of integers representing the spin-xor values for the nodes in the support.

Constructors

  • Flip(support::Vector{Int}, state::Vector{Int}, spinxor::Vector{Int}):

Creates a new Flip object with the specified support, state changes, and spinxor values.

source
SpinGlassPEPS.SpinGlassEngine.DropletType

A data structure representing a droplet in the context of the SpinGlassPEPS package. A Droplet represents an excitation in the SpinGlassPEPS system. It contains information about the excitation energy, the site where the droplet starts, the site where it ends, the states of nodes flipped by the droplet, and any sub-droplets on top of the current droplet.

Fields

  • denergy::Real: The excitation energy of the droplet, typically a real number.
  • first::Int: The site index where the droplet starts.
  • last::Int: The site index where the droplet ends.
  • flip::Flip: The states of nodes flipped by the droplet, often represented using a Flip type.
  • droplets::Union{NoDroplets, Vector{Droplet}}: A field that can be either NoDroplets() if there are no sub-droplets

on top of the current droplet or a vector of Droplet objects representing sub-droplets. This field may be used to build a hierarchy of droplets in more complex excitations.

source
SpinGlassPEPS.SpinGlassEngine.NoDropletsType

This is a method used to calculate excitation information for the NoDroplets strategy in the context of a SpinGlassPEPS contractor. The NoDroplets strategy represents a scenario in which no droplets are present in the system, and therefore, no excitation information is calculated.

Arguments

  • method::NoDroplets: An instance of the NoDroplets strategy.
  • ctr::MpsContractor{T}: A SpinGlassPEPS contractor of type T representing the system.
  • best_idx::Int: The index of the best state.
  • energies::Vector{<:Real}: A vector of energies associated with different states.
  • states::Vector{Vector{Int}}: A vector of states represented as arrays of integers.
  • droplets::Vector{Droplets}: A vector of droplets in the system.
  • spins::Vector{Vector{Int}}: A vector of spin configurations associated with states.

Returns

  • NoDroplets(): An instance of the NoDroplets strategy indicating that no excitation information is calculated in this scenario.
source
SpinGlassPEPS.SpinGlassEngine.hamming_distanceFunction
hamming_distance(flip::Flip, s::Symbol) -> Int64

Calculate the Hamming distance for a 'Flip' object.

Arguments

  • flip::Flip: The 'Flip' object for which the Hamming distance will be calculated.

Returns

  • d::Int: The computed Hamming distance.
source
hamming_distance(state1, state2, s::Symbol) -> Int64

Calculate the Hamming distance between two vectors of states.

Arguments

  • state1::Vector{Int}: The first vector.
  • state2::Vector{Int}: The second vector.

Returns

  • d::Int: The computed Hamming distance.
source
hamming_distance(
    flip1::Flip,
    flip2::Flip,
    s::Symbol
) -> Int64

Calculate the Hamming distance between two Flip objects representing states with support and flip information.

Arguments

  • flip1::Flip: The first Flip object, containing support, state, and spinxor information.
  • flip2::Flip: The second Flip object, with support, state, and spinxor information.

Returns

  • hd::Int: The computed Hamming distance between the two Flip objects.
source
SpinGlassPEPS.SpinGlassEngine.unpack_dropletsFunction
unpack_droplets(sol, β) -> Solution

Unpack droplets in a solution structure to create a new solution with individual excitations.

Arguments

  • sol: The input solution containing droplets to be unpacked.
  • β::Real: The inverse temperature parameter used for probability adjustments.

Returns

  • new_sol: A new solution where droplets are unpacked into individual excitations.
source
SpinGlassPEPS.SpinGlassEngine.perm_dropletFunction
perm_droplet(
    drop::NoDroplets,
    perm::Vector{Int64}
) -> NoDroplets

Apply a permutation to a 'NoDroplets' object, resulting in an unchanged 'NoDroplets'.

Arguments

  • drop::NoDroplets: The 'NoDroplets' object that remains unchanged.
  • perm::Vector{Int}: A permutation vector that is applied to indices.

Returns

  • result::NoDroplets: The 'NoDroplets' object, which remains the same.
source
perm_droplet(
    drops::Vector{Droplet},
    perm::Vector{Int64}
) -> Vector{Droplet}

Apply a permutation to a collection of 'Droplet' objects.

Arguments

  • drops::Vector{Droplet}: A vector of 'Droplet' objects to which the permutation is applied.
  • perm::Vector{Int}: A permutation vector that is applied to indices.

Returns

  • result::Vector{Droplet}: A vector of 'Droplet' objects after applying the permutation.
source
perm_droplet(drop::Droplet, perm::Vector{Int64}) -> Droplet

Apply a permutation to a 'Droplet' object.

Arguments

  • drop::Droplet: A 'Droplet' object to which the permutation is applied.
  • perm::Vector{Int}: A permutation vector that is applied to indices.

Returns

  • result::Droplet: A 'Droplet' object after applying the permutation.
source
SpinGlassPEPS.SpinGlassEngine.filter_dropletsFunction
filter_droplets(
    all_droplets::Vector{Droplet},
    method::SingleLayerDroplets
) -> Vector{Droplet}

Filter a vector of droplets based on specified criteria and strategy parameters.

Arguments

  • all_droplets::Vector{Droplet}: A vector of Droplet objects representing the droplets to be filtered.
  • method::SingleLayerDroplets: An instance of the SingleLayerDroplets strategy used to determine filtering criteria.

Returns

  • filtered_droplets::Vector{Droplet}: A filtered vector of Droplet objects based on the specified criteria and strategy parameters.
source
SpinGlassPEPS.SpinGlassEngine.my_push!Function
my_push!(
    ndroplets::Union{NoDroplets, Vector{Droplet}},
    droplet::Droplet,
    method
) -> Union{NoDroplets, Vector{Droplet}}

Push a 'Droplet' object into a vector of droplets ('Droplets') while considering the strategy parameters.

Arguments

  • ndroplets::Droplets: A vector of 'Droplet' objects to which the new 'Droplet' object will be added.
  • droplet::Droplet: The 'Droplet' object to be added to the vector.
  • method: The strategy parameter that determines whether or not the 'Droplet' object is added based on the defined criteria.

Returns

  • ndroplets::Droplets: The updated vector of 'Droplet' objects after the addition of the new 'Droplet' object.
source
SpinGlassPEPS.SpinGlassEngine.diversity_metricFunction
diversity_metric(
    drop1::Droplet,
    drop2::Droplet,
    metric::Symbol,
    mode::Symbol
) -> Union{Float64, Int64}

Calculate the diversity metric between two 'Droplet' objects based on the specified metric.

Arguments

  • drop1::Droplet: The first 'Droplet' object for comparison.
  • drop2::Droplet: The second 'Droplet' object for comparison.
  • metric::Symbol: A symbol specifying the metric to be used for the diversity calculation. Currently, only the "hamming" metric is supported.

Returns

  • d::Real: The calculated diversity metric value between the two 'Droplet' objects.
source
SpinGlassPEPS.SpinGlassEngine.merge_dropletsFunction
merge_droplets(
    method::SingleLayerDroplets,
    droplet::Droplet,
    subdroplet::Droplet
) -> Droplet

Merge two Droplets according to the specified SingleLayerDroplets method.

Arguments

  • method::SingleLayerDroplets: The method used to determine whether and how to merge the droplets.
  • droplet::Droplet: The main droplet to be merged.
  • subdroplet::Droplet: The subdroplet to be merged with the main droplet.

Returns

  • merged_droplet::Droplet: The merged droplet created based on the merging method.
source
SpinGlassPEPS.SpinGlassEngine.flip_stateFunction
flip_state(state::AbstractVector{Int64}, flip::Flip) -> Any

Apply a flip operation to a state.

Arguments

  • state::Vector{Int}: The original state vector.
  • flip::Flip: The flip operation to be applied to the state.

Returns

  • new_state::Vector{Int}: The modified state after applying the flip operation.
source

PEPS

SpinGlassPEPS.SpinGlassEngine.normalize_probabilityFunction
normalize_probability(probs::Vector{<:Real}) -> Any

Normalize a probability distribution.

Arguments

  • probs::Vector{<:Real}: A vector representing a probability distribution.

Returns

  • Vector{Float64}: Normalized probability distribution.
source
SpinGlassPEPS.SpinGlassEngine.initialize_gauges!Function
initialize_gauges!(
    net::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T, R}
)
initialize_gauges!(
    net::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T, R},
    type::Symbol
)

Initialize gauge tensors in a Gibbs network.

Arguments

  • net::AbstractGibbsNetwork{S, T}: Gibbs network to initialize.
  • type::Symbol=:id: Type of initialization, either :id for identity or :rand for random values.

Description

This function initializes gauge tensors in a Gibbs network according to the specified type. Each gauge tensor is associated with two positions in the network and a type. The positions are determined by the gauge's positions field, and the type is specified by the gauge's type field. The initialization type can be either :id for identity tensors or :rand for random tensors.

source
SpinGlassPEPS.SpinGlassEngine.decode_stateFunction
decode_state(
    peps::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T},
    σ::AbstractVector{Int64}
) -> Any
decode_state(
    peps::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T},
    σ::AbstractVector{Int64},
    potts_h_order::Bool
) -> Any

Decode a state vector into a dictionary representation.

Arguments

  • peps::AbstractGibbsNetwork{S, T}: The Gibbs network.
  • σ::Vector{Int}: State vector to be decoded.
  • potts_h_order::Bool=false: If true, use the order of nodes in the Potts Hamiltonian.

Returns

  • Dict{Symbol, Int}: A dictionary mapping node symbols to corresponding values in the state vector.
source
SpinGlassPEPS.SpinGlassEngine.spectrumFunction
spectrum(
    network::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T},
    vertex
) -> Spectrum{T, S} where {S<:AbstractArray, T<:Real}

Retrieve the spectrum associated with a specific vertex in the Gibbs network.

Arguments

  • network::AbstractGibbsNetwork{S, T}: Gibbs network containing the Potts Hamiltonian.
  • vertex::S: Vertex for which the spectrum is to be retrieved.

Returns

  • Spectrum associated with the specified vertex.
source
SpinGlassPEPS.SpinGlassEngine.is_compatibleFunction
is_compatible(
    potts_hamiltonian::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    network_graph::LabelledGraphs.LabelledGraph
) -> Union{Missing, Bool}

Check if a Potts Hamiltonian is compatible with a given network graph.

Arguments

  • potts_hamiltonian::LabelledGraph: Graph representing the Potts Hamiltonian.
  • network_graph::LabelledGraph: Graph representing the network.

Returns

  • compatibility::Bool: true if the Potts Hamiltonian is compatible with the network graph, false otherwise.
source
SpinGlassPEPS.SpinGlassEngine.ones_likeFunction
ones_like(x::Number) -> Any

Create an identity with the same type as the input number x.

Arguments

  • x: A numeric value.

Returns

  • a multiplicative identity with the same type as x.
source
ones_like(x::AbstractArray) -> Any

Create an array of ones with the same element type and size as the input array x.

Arguments

  • x::AbstractArray: An array serving as a template.

Returns

  • result::Array: An array of ones with the same element type and size as x.
source
SpinGlassPEPS.SpinGlassEngine.tensor_mapFunction
tensor_map(
    _::Type{SquareSingleNode{T<:Union{EnergyGauges, GaugesEnergy}}},
    _::Type{S<:SpinGlassPEPS.SpinGlassEngine.AbstractSparsity},
    nrows::Int64,
    ncols::Int64
) -> Dict{SpinGlassPEPS.SpinGlassEngine.PEPSNode, Symbol}

Assigns type of tensor to a PEPS node coordinates for a given Layout and Sparsity.

source
tensor_map(
    _::Type{SquareSingleNode{T<:EngGaugesEng}},
    _::Type{S<:SpinGlassPEPS.SpinGlassEngine.AbstractSparsity},
    nrows::Int64,
    ncols::Int64
) -> Dict{SpinGlassPEPS.SpinGlassEngine.PEPSNode, Symbol}

Assigns type of tensor to a PEPS node coordinates for a given Layout and Sparsity.

source
tensor_map(
    _::Type{SquareCrossDoubleNode{T<:Union{EnergyGauges, GaugesEnergy}}},
    _::Type{S<:SpinGlassPEPS.SpinGlassEngine.AbstractSparsity},
    nrows::Int64,
    ncols::Int64
) -> Dict{SpinGlassPEPS.SpinGlassEngine.PEPSNode, Symbol}

Create a mapping of tensor network nodes for a square cross double node geometry.

Arguments

  • ::Type{SquareCrossDoubleNode{T}}: Type representing a square cross double node geometry.
  • ::Type{S}: Type representing sparsity in the tensor network.
  • nrows::Int: Number of rows in the tensor network.
  • ncols::Int: Number of columns in the tensor network.

Returns

  • Dict{PEPSNode, Symbol}: A dictionary mapping PEPS nodes to symbols representing their corresponding tensor network nodes.

Description

The tensor_map function generates a mapping of tensor network nodes for a square cross double node geometry. The mapping includes different types of nodes, such as site double nodes, virtual double nodes, central vertical double nodes, and central diagonal double nodes.

source
Base.sizeFunction
size(
    net::PEPSNetwork{SquareCrossDoubleNode{T<:SpinGlassPEPS.SpinGlassEngine.AbstractTensorsLayout}, S<:SpinGlassPEPS.SpinGlassEngine.AbstractSparsity},
    node::SpinGlassPEPS.SpinGlassEngine.PEPSNode,
    _::Val{:central_d_double_node}
) -> Tuple{Any, Any}

Determine the size of the tensor corresponding to a central double node in a projected entangled pair states (PEPS) tensor network.

Arguments

  • net::PEPSNetwork{SquareCrossDoubleNode{T}, S}: PEPS tensor network with square cross double nodes.
  • node::PEPSNode: Node representing the position of the central double node.
  • ::Val{:central_d_double_node}: symbol to indicate the central double node.

Returns

  • Tuple{Int, Int}: Tuple representing the size of the tensor for the central double node.

Description

The Base.size function is used to determine the size of the tensor corresponding to a central double node in a PEPS tensor network. It calculates the size by considering the sizes of the two central tensors associated with neighboring positions. The function is parametrized by the abstract tensors layout type T and the abstract sparsity type S.

source
size(
    net::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{NTuple{N, Int64} where N, SpinGlassPEPS.SpinGlassEngine.PEPSNode},
    node::SpinGlassPEPS.SpinGlassEngine.PEPSNode,
    _::Union{Val{:virtual_double_node}, Val{:sparse_virtual_double_node}}
) -> NTuple{4, Any}

Determine the size of the virtual tensor associated with a virtual double node in a tensor network.

Arguments

  • net::AbstractGibbsNetwork{Node, PEPSNode}: Abstract Gibbs PEPS tensor network with nodes and virtual tensors.
  • node::PEPSNode: PEPS node representing the position of the virtual double node.
  • ::Union{Val{:virtual_double_node}, Val{:sparse_virtual_double_node}}: Tag indicating whether the virtual tensor is dense or sparse.

Returns

  • Tuple (s1, s2, s3, s4): Size information for the virtual tensor.

Description

The size function determines the size of the virtual tensor associated with a virtual double node in an Abstract Gibbs PEPS tensor network. The size is specified by the dimensions along the left, top, right, and bottom directions. The function is parametrized by the types of nodes (Node and PEPSNode) and the tag indicating whether the virtual tensor is dense or sparse.

source
SpinGlassPEPS.SpinGlassEngine.exact_spectrumFunction
exact_spectrum(
    potts_hamiltonian::SpinGlassPEPS.SpinGlassNetworks.PottsLike
) -> Tuple{Any, Any}

Calculate the exact spectrum and corresponding eigenstates for a Potts Hamiltonian using memoization.

Arguments

  • potts_hamiltonian::LabelledGraph{S, T}: A Potts Hamiltonian represented as a labelled graph.

Returns

  • Tuple (energies, states): A tuple containing the calculated energies and corresponding eigenstates.

Description

The exact_spectrum function calculates the exact spectrum and corresponding eigenstates for a Potts Hamiltonian using memoization. The function utilizes memoization to efficiently store and retrieve previously computed results for different inputs, reducing redundant calculations. The Hamiltonian is represented as a labelled graph (LabelledGraph) with vertices corresponding to clusters and edges representing interactions between clusters.

source
SpinGlassPEPS.SpinGlassEngine.discard_probabilities!Function
discard_probabilities!(
    psol::Solution,
    cutoff_prob::Real
) -> Solution

Discards low-probability states from the given solution.

Arguments

  • psol::Solution: The input solution containing states and their probabilities.
  • cutoff_prob::Real: The cutoff probability below which states will be discarded.

Returns

  • Solution: A new solution with low-probability states discarded.

Description

This function removes states from the solution psol whose probabilities are below the specified cutoff_prob. It calculates a cutoff probability (pcut) based on the maximum probability in psol and the provided cutoff_prob. States with probabilities lower than pcut are considered discarded. The largest discarded probability (ldp) in the resulting solution is updated based on the maximum discarded probability among the removed states and the existing ldp in psol.

source
SpinGlassPEPS.SpinGlassEngine.mod_wo_zeroFunction
mod_wo_zero(k, m) -> Any

Calculate the modulo operation of k with respect to m, ensuring the result is not zero.

Arguments

  • k: The dividend.
  • m: The divisor.

Returns

  • result::Int: The result of k % m, ensuring it is not zero.
source
SpinGlassPEPS.SpinGlassEngine.exact_marginal_probabilityFunction
exact_marginal_probability(
    ctr::MpsContractor{T},
    σ::AbstractVector{Int64}
) -> Any

Calculate the exact marginal probability of a target state within the context of an MPS (Matrix Product State) contractor.

Arguments

  • ctr::MpsContractor{T}: An MPS contractor representing the contracted state and associated parameters.
  • σ::Vector{Int}: A vector representing the encoded state.

Returns

  • Float64: The calculated exact marginal probability of the target state.

Description

The exact_marginal_probability function calculates the exact marginal probability of a target state within the context of an MPS contractor. It decodes the provided state vector σ using the decode_state function, obtains the exact spectrum and states from the Potts Hamiltonian of the associated PEPS, and computes the marginal probability of the target state using the Boltzmann distribution. The function utilizes the exact_spectrum function to obtain the energies and states of the Potts Hamiltonian, exponentiates the negative energies multiplied by the inverse temperature (ctr.beta), normalizes the probabilities, and calculates the marginal probability of the target state.

source
SpinGlassPEPS.SpinGlassEngine._normalizeFunction
_normalize(probs::Vector{<:Real}) -> Any

Normalize a probability distribution.

Arguments

  • probs::Vector{<:Real}: A vector representing a probability distribution.

Returns

  • Vector{Float64}: Normalized probability distribution.
source
SpinGlassPEPS.SpinGlassEngine.projectors_site_tensorFunction
projectors_site_tensor(
    net::PEPSNetwork{T<:SquareCrossDoubleNode, S},
    vertex::NTuple{N, Int64} where N
) -> NTuple{4, Any}

Construct the set of projectors associated with a site tensor in a projected entangled pair states (PEPS) tensor network.

Arguments

  • net::PEPSNetwork{T, S}: PEPS tensor network with nodes of type T and tensors of sparsity type S.
  • vertex::Node: Node representing the position of the site tensor.

Returns

  • (plf, pt, prf, pb): Tuple of projectors associated with the site tensor, corresponding to the left (plf), top (pt), right (prf), and bottom (pb) directions.

Description

The projectors_site_tensor function constructs the set of projectors associated with a site tensor at the specified position in a PEPS tensor network. The projectors are created based on the neighboring tensors and directions in the network. The function is parametrized by the abstract node type T and the abstract sparsity type S.

source
SpinGlassPEPS.SpinGlassEngine.branch_probabilityFunction
branch_probability(
    ctr::MpsContractor{T},
    pσ::Tuple{Real, Vector{Int64}}
) -> Any

Calculates the branch probability for a given state.

Arguments

  • ctr::MpsContractor{T}: The MPS contractor object.
  • pσ::Tuple{<:Real, Vector{Int}}: Tuple containing the energy and state configuration.

Returns

  • Real: The calculated branch probability.

Description

This function calculates the branch probability for a specific state configuration using the conditional probability provided by the MPS contractor. The branch probability is computed as the logarithm of the conditional probability of the given state. The conditional probability is obtained from the MPS contractor.

source
SpinGlassPEPS.SpinGlassEngine.exact_conditional_probabilityFunction
exact_conditional_probability(
    ctr::MpsContractor{T},
    σ::Vector{Int64}
) -> Any

Calculate the exact conditional probability of a target state within the context of an MPS (Matrix Product State) contractor.

Arguments

  • ctr::MpsContractor{T}: An MPS contractor representing the contracted state and associated parameters.
  • σ::Vector{Int}: A vector representing the encoded state.

Returns

  • Vector{Float64}: The calculated exact conditional probabilities for each possible outcome.

Description

The exact_conditional_probability function calculates the exact conditional probability distribution of a target state within the context of an MPS contractor. It uses the exact_marginal_probability function for different branch states generated by branch_states and normalizes the probabilities.

source
SpinGlassPEPS.SpinGlassEngine.branch_solutionFunction
branch_solution(
    psol::Solution,
    ctr::SpinGlassPEPS.SpinGlassEngine.AbstractContractor
) -> Solution

Generate a new solution by branching the given partial solution in a contracting Gibbs network.

Arguments

  • psol::Solution: The partial solution.
  • ctr::T: The contractor representing the contracting Gibbs network.

Returns

  • Solution: A new solution obtained by branching the partial solution in the contracting network.

Description

This function generates a new solution by branching the given partial solution in a contracting Gibbs network. It computes the energies, states, probabilities, degeneracies, discarded probabilities, droplets, and spins for the resulting solution. The branching process involves considering the current node in the contractor and updating the solution accordingly.

source
SpinGlassPEPS.SpinGlassEngine.gauges_listFunction
gauges_list(
    _::Type{SquareSingleNode{T<:GaugesEnergy}},
    nrows::Int64,
    ncols::Int64
) -> Vector{SpinGlassPEPS.SpinGlassEngine.GaugeInfo}

Assigns gauges and corresponding information to GaugeInfo structure for a given Layout.

source
gauges_list(
    _::Type{SquareSingleNode{T<:EnergyGauges}},
    nrows::Int64,
    ncols::Int64
) -> Vector{SpinGlassPEPS.SpinGlassEngine.GaugeInfo}

Assigns gauges and corresponding information to GaugeInfo structure for a given Layout.

source
gauges_list(
    _::Type{SquareSingleNode{T<:EngGaugesEng}},
    nrows::Int64,
    ncols::Int64
) -> Vector{SpinGlassPEPS.SpinGlassEngine.GaugeInfo}

Assigns gauges and corresponding information to GaugeInfo structure for a given Layout.

source
gauges_list(
    _::Type{SquareDoubleNode{T<:GaugesEnergy}},
    nrows::Int64,
    ncols::Int64
) -> Vector{SpinGlassPEPS.SpinGlassEngine.GaugeInfo}

Assigns gauges and corresponding information to GaugeInfo structure for a given Layout.

source
gauges_list(
    _::Type{SquareDoubleNode{T<:EnergyGauges}},
    nrows::Int64,
    ncols::Int64
) -> Vector{SpinGlassPEPS.SpinGlassEngine.GaugeInfo}

Assigns gauges and corresponding information to GaugeInfo structure for a given Layout.

source
gauges_list(
    _::Type{SquareCrossDoubleNode{T<:GaugesEnergy}},
    nrows::Int64,
    ncols::Int64
) -> Vector{SpinGlassPEPS.SpinGlassEngine.GaugeInfo}

Create a list of gauge information for a square cross double node geometry and GaugesEnergy Layout.

Arguments

  • ::Type{SquareCrossDoubleNode{T}}: Type representing a square cross double node geometry.
  • nrows::Int: Number of rows in the tensor network.
  • ncols::Int: Number of columns in the tensor network.

Returns

  • Vector{GaugeInfo}: A vector of GaugeInfo objects representing gauge information for the specified geometry.

Description

The gauges_list function generates a list of GaugeInfo objects for a square cross double node geometry. Each GaugeInfo object contains information about the positions of gauge links, the position of the attached tensor, the leg index, and the type of gauge.

source
gauges_list(
    _::Type{SquareCrossDoubleNode{T<:EnergyGauges}},
    nrows::Int64,
    ncols::Int64
) -> Vector{SpinGlassPEPS.SpinGlassEngine.GaugeInfo}

Create a list of gauge information for a square cross double node geometry and EnergyGauges Layout.

Arguments

  • ::Type{SquareCrossDoubleNode{T}}: Type representing a square cross double node geometry.
  • nrows::Int: Number of rows in the tensor network.
  • ncols::Int: Number of columns in the tensor network.

Returns

  • Vector{GaugeInfo}: A vector of GaugeInfo objects representing gauge information for the specified geometry.

Description

The gauges_list function generates a list of GaugeInfo objects for a square cross double node geometry. Each GaugeInfo object contains information about the positions of gauge links, the position of the attached tensor, the leg index, and the type of gauge.

source
SpinGlassPEPS.SpinGlassEngine.branch_energiesFunction
branch_energies(
    ctr::MpsContractor{T},
    psol::Solution
) -> Any

Compute and branch the energies from different branches in a solution.

Arguments

  • ctr::MpsContractor{T}: The MPS contractor.
  • psol::Solution: The partial solution.

Returns

  • Vector{<:Real}: A vector containing the energies of individual branches.

Description

This function computes the energies of branches in a solution by applying the branch_energy function to each pair of energy and state in the given partial solution. The result is a vector of energies corresponding to the branches.

source
SpinGlassPEPS.SpinGlassEngine._equalizeFunction
_equalize(probs::Vector{<:Real}) -> Any

Equalize a probability distribution.

Arguments

  • probs::Vector{<:Real}: A vector representing a probability distribution.

Returns

  • Vector{Float64}: Equalized probability distribution.
source
SpinGlassPEPS.SpinGlassEngine.nodes_search_order_MpsFunction
nodes_search_order_Mps(
    peps::PEPSNetwork{T<:SquareCrossDoubleNode, S}
) -> Tuple{Vector, Tuple{Int64, Int64, Int64}}

Generate the search order of nodes for a matrix product states (MPS).

Arguments

  • peps::PEPSNetwork{T, S}: PEPS tensor network with a specific tensor layout.

Returns

  • Tuple{Vector{Tuple{Int, Int, Int}}, Tuple{Int, Int, Int}}: Tuple containing the list of node coordinates and the size of the tensor network.

Description

The nodes_search_order_Mps function generates the search order of nodes for a matrix product states (MPS). It creates a list of node coordinates (i, j, k) representing rows, columns, and index of group of spins, respectively. The resulting order is suitable for traversing the nodes in the tensor network during contraction. The function is specialized for the SquareCrossDoubleNode tensor network type and is parametrized by the layout type S.

source
SpinGlassPEPS.SpinGlassEngine.samplingFunction
sampling(
    psol::Solution,
    max_states::Int64,
    δprob::Real
) -> Solution
sampling(
    psol::Solution,
    max_states::Int64,
    δprob::Real,
    merge_strategy
) -> Solution

Generate a new solution by sampling states based on their probabilities.

Arguments

  • psol::Solution: The partial solution from which to sample states.
  • max_states::Int: The maximum number of states to sample.
  • δprob::Real: The probability threshold for discarding states.
  • merge_strategy=no_merge: The merging strategy, defaults to no_merge.

Returns

  • Solution: A new solution obtained by sampling states.

Description

This function generates a new solution by sampling states from the given partial solution. The sampling is performed based on the probabilities associated with each state. The number of sampled states is determined by the max_states argument. Additionally, states with probabilities below the threshold δprob are discarded. The optional argument merge_strategy specifies the merging strategy to be used during the sampling process. It defaults to no_merge, indicating no merging.

source
SpinGlassPEPS.SpinGlassEngine.VirtualDoubleNodeFunction
VirtualDoubleNode(_::Type{Dense}) -> Symbol

Create a symbol representing a virtual double node for a dense tensor layout.

Arguments

  • ::Type{Dense}: The Dense tensor layout type.

Returns

  • Symbol: A symbol representing the virtual double node.

Description

The VirtualDoubleNode function generates a symbol (:virtual_double_node) that represents a virtual double node in the context of a dense tensor layout. This symbol is often used to indicate the presence of a virtual double node when working with certain tensors.

source
VirtualDoubleNode(_::Type{Sparse}) -> Symbol

Create a symbol representing a virtual double node for a sparse tensor layout.

Arguments

  • ::Type{Sparse}: The Sparse tensor layout type.

Returns

  • Symbol: A symbol representing the virtual double node.

Description

The VirtualDoubleNode function generates a symbol (:virtual_double_node) that represents a virtual double node in the context of a sparse tensor layout. This symbol is often used to indicate the presence of a virtual double node when working with certain tensors.

source
SpinGlassPEPS.SpinGlassEngine.fuse_projectorsFunction
fuse_projectors(
    projectors::NTuple{N, K}
) -> Tuple{Any, Tuple}

Fuse a tuple of projector matrices into a single projector matrix using rank-revealing techniques.

Arguments

  • projectors::NTuple{N, K}: Tuple of projector matrices to be fused.

Returns

  • fused::Matrix{Float64}: Fused projector matrix.
  • transitions::NTuple{N, Vector{Int}}: Tuple of transition vectors indicating the indices of the non-zero rows in each original projector.
source
SpinGlassPEPS.SpinGlassEngine.local_spinsFunction
local_spins(
    network::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T},
    vertex
) -> Vector{Int64}

Retrieve the local spin configurations associated with a vertex in the Gibbs network.

Arguments

  • network::AbstractGibbsNetwork{S, T}: The Gibbs network.
  • vertex::S: The vertex for which local spins are requested.

Returns

  • Vector{Int}: An array representing the local spin configurations.

Description

This function retrieves the local spin configurations associated with a given vertex in the Gibbs network. The local spins are extracted from the spectrum of the Potts Hamiltonian associated with the vertex.

source
SpinGlassPEPS.SpinGlassEngine.tensorFunction
tensor(
    net::PEPSNetwork{T<:SpinGlassPEPS.SpinGlassEngine.AbstractGeometry, Sparse},
    node::SpinGlassPEPS.SpinGlassEngine.PEPSNode,
    β::Real,
    _::Val{:central_d_double_node}
) -> SpinGlassPEPS.SpinGlassTensors.DiagonalTensor{_A, 2} where _A<:Real

Generate the tensor for a central double node in a projected entangled pair states (PEPS) tensor network.

Arguments

  • net::PEPSNetwork{T, Sparse}: PEPS tensor network.
  • node::PEPSNode: Node representing the position of the central double node.
  • β::Real: Inverse temperature parameter.
  • ::Val{:central_d_double_node}: symbol to indicate the central double node.

Returns

  • DiagonalTensor: Tensor representing the central double node.

Description

The tensor function generates the tensor for a central double node in a PEPS tensor network. It uses the inverse temperature parameter β to construct the central tensor based on the geometry of the tensor network. The function is specialized for PEPS tensor networks with sparse tensors (Sparse) and is parametrized by the abstract geometry type T.

source
tensor(
    net::PEPSNetwork{SquareCrossDoubleNode{T<:SpinGlassPEPS.SpinGlassEngine.AbstractTensorsLayout}, S<:Union{Dense, Sparse}},
    node::SpinGlassPEPS.SpinGlassEngine.PEPSNode,
    β::Real,
    _::Val{:sparse_virtual_double_node}
) -> SpinGlassPEPS.SpinGlassTensors.VirtualTensor{_A, 4} where _A<:Real

Create a sparse virtual double node tensor in a projected entangled pair states (PEPS) tensor network.

Arguments

  • net::PEPSNetwork{SquareCrossDoubleNode{T}, S}: PEPS tensor network with square cross double nodes.
  • node::PEPSNode: Node representing the position of the virtual double node.
  • β::Real: Inverse temperature parameter.
  • ::Val{:sparse_virtual_double_node}: symbol to indicate the creation of a sparse virtual double node tensor.

Returns

  • VirtualTensor{T, S}: Sparse virtual double node tensor.

Description

The tensor function is used to create a sparse virtual double node tensor in a PEPS tensor network. It constructs the tensor by incorporating information about the central tensor and surrounding projectors associated with the specified position. The function is parametrized by the abstract tensors layout type T, and the abstract sparsity type S, which can be either Sparse or Dense.

source
tensor(
    net::PEPSNetwork{T<:SpinGlassPEPS.SpinGlassEngine.AbstractGeometry, Dense},
    node::SpinGlassPEPS.SpinGlassEngine.PEPSNode,
    β::Real,
    _::Val{:virtual_double_node}
) -> Any

Create a dense virtual double node tensor in a projected entangled pair states (PEPS) tensor network.

Arguments

  • net::PEPSNetwork{T, Dense}: PEPS tensor network with nodes of type T and dense tensors.
  • node::PEPSNode: Node representing the position of the virtual double node.
  • β::Real: Inverse temperature parameter.
  • ::Val{:virtual_double_node}: symbol to indicate the creation of a dense virtual double node tensor.

Returns

  • Tensor{T}: Dense virtual double node tensor.

Description

The tensor function is used to create a dense virtual double node tensor in a PEPS tensor network. It constructs the tensor by combining information from the sparse virtual double node tensor, including projectors and the dense central tensor associated with the specified position. The function is parametrized by the abstract geometry type T.

source
SpinGlassPEPS.SpinGlassEngine.branch_statesFunction
branch_states(
    local_basis::Vector{Int64},
    vec_states::AbstractVector{<:AbstractVector{Int64}}
) -> Vector{Vector{Int64}}

Constructs branch states based on a local basis and vectorized states.

Arguments

  • local_basis::Vector{Int}: The local basis states.
  • vec_states::Vector{Vector{Int}}: Vectorized states for each branch.

Returns

  • Vector{Vector{Int}}: A vector containing the constructed branch states.

Description

This function constructs branch states by combining a local basis with vectorized states. The local basis provides the unique states for each branch, and the vectorized states represent the state configuration for each branch. The resulting vector contains the constructed branch states.

source
SpinGlassPEPS.SpinGlassEngine.precompute_conditionalFunction
precompute_conditional(
    _::Type{T<:SquareCrossDoubleNode},
    ctr::MpsContractor{S},
    current_node
) -> Any

Precompute conditional probabilities and energies for a square cross double node tensor contraction.

Arguments

  • ::Type{T}: Type representing a square cross double node tensor network.
  • ctr::MpsContractor{S}: Tensor contractor for the tensor network.
  • current_node: Current node position in the tensor network.

Returns

  • Tuple: A tuple containing precomputed conditional probabilities and energies.

Description

The precompute_conditional function computes and returns precomputed conditional probabilities and energies for the specified square cross double node tensor contraction. It takes into account the geometry of the tensor network, interaction energies, and projectors. The precomputed values are used during the tensor contraction process to speed up the computation. The function is specialized for the SquareCrossDoubleNode tensor network type and is parametrized by the layout type S of the contractor.

source
SpinGlassPEPS.SpinGlassEngine.take_guess!Function
take_guess!(
    ctr::MpsContractor{T, R, S},
    i::Int64,
    W::QMpo{S}
) -> Any

Claim the warm-start guess for the bottom boundary MPS of row i, if one is available and usable.

Returns a left-normalized QMps on the contractor's device, ready to be handed to variational_compress! as the bra, or nothing when there is no guess or it does not fit the current network. Guesses are consumed: a row is warm-started at most once per β step, so a rejected or used guess never lingers.

Only the bottom boundary (mps) is warm-started, not mps_top. That is the sequence the preprocessing phase builds row by row and the search then consumes, so it is where the cost sits; keying guesses by row alone is then unambiguous.

Compatibility is checked against the physical dimensions the compressed MPS must have. W contracts its :down legs with the ket (the row below), leaving its :up legs as the physical legs of the result — so :up is the side a guess has to match, not :down. Those dimensions depend on the network's geometry and clustering, not on β, so a guess carried over from a neighbouring inverse temperature normally fits; the check exists so that a mismatch degrades to a cold build rather than throwing from inside the environment contraction.

source
SpinGlassPEPS.SpinGlassEngine.branch_states_viewFunction
branch_states_view(
    local_basis::Vector{Int64},
    vec_states::AbstractVector{<:AbstractVector{Int64}}
) -> Vector{SubArray{Int64, 1, Matrix{Int64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}

Expansion used on the search's hot path: the same configurations branch_states produces, but backed by one matrix and returned as column views instead of independent vectors.

This is the largest single source of host-allocated bytes in a solve, previously one heap object per branched state and so tens of thousands per call. The byte count is dominated by the payload either way, but garbage-collection cost scales with the number of objects, so consolidating the expansion into one matrix cuts the live object count sharply for a modest change in bytes.

branch_states itself keeps returning Vector{Vector{Int}}, since it is part of the published API and callers may rely on that element type.

Ordering is load-bearing: callers pair the result index-for-index with branch_energies and branch_probability, so the local basis must vary fastest within each parent configuration.

source