Library

Ising Graphs

SpinGlassPEPS.SpinGlassNetworks.inter_cluster_edgesFunction
inter_cluster_edges(
    ig::LabelledGraphs.LabelledGraph{MetaGraphs.MetaGraph{Int64, T}},
    cl1::LabelledGraphs.LabelledGraph{MetaGraphs.MetaGraph{Int64, T}},
    cl2::LabelledGraphs.LabelledGraph{MetaGraphs.MetaGraph{Int64, T}}
) -> Tuple{Vector, Any}

Return the dense adjacency matrix between clusters of vertices in an Ising graph.

This function computes and returns the dense adjacency matrix J between clusters of vertices represented by two Ising graphs, cl1 and cl2, within the context of the larger Ising graph ig. The adjacency matrix represents the interaction strengths between clusters of vertices, where each element (i, j) corresponds to the interaction strength between cluster i in cl1 and cluster j in cl2.

Arguments:

  • ig::IsingGraph{T}: The Ising graph representing a system of spins with associated interaction strengths.
  • cl1::IsingGraph{T}: The first Ising graph representing one cluster of vertices.
  • cl2::IsingGraph{T}: The second Ising graph representing another cluster of vertices.

Returns:

  • outer_edges::Vector{LabelledEdge}: A vector of labeled edges representing the interactions between clusters.
  • J::Matrix{T}: A dense adjacency matrix representing interaction strengths between clusters.

The function first identifies the outer edges that connect vertices between the two clusters in the context of the larger Ising graph ig. It then computes the interaction strengths associated with these outer edges and populates the dense adjacency matrix J accordingly.

source
SpinGlassPEPS.SpinGlassNetworks.pruneFunction
prune(
    ig::LabelledGraphs.LabelledGraph{MetaGraphs.MetaGraph{Int64, T}} where T;
    atol
) -> LabelledGraphs.LabelledGraph

Used only in MPSsearch, would be obsolete if MPSsearch uses QMps. Remove non-existing spins from an Ising graph.

This function removes non-existing spins from the given Ising graph ig. Non-existing spins are those that have zero degree (no connections to other spins) and also have an external magnetic field (h) that is not approximately equal to zero within the specified tolerance atol.

Arguments:

  • ig::IsingGraph: The Ising graph to be pruned.
  • atol::Real: The tolerance for considering the external magnetic field as zero. The default value is 1e-14.

Returns:

  • pruned_graph::IsingGraph: A new Ising graph with non-existing spins removed.

The function returns a pruned version of the input Ising graph, where non-existing spins and their associated properties are removed.

source
SpinGlassPEPS.SpinGlassNetworks.couplingsFunction
couplings(
    ig::LabelledGraphs.LabelledGraph{MetaGraphs.MetaGraph{Int64, T}}
) -> Any

Return the coupling strengths between vertices of an Ising graph.

This function computes and returns the coupling strengths (interaction energies) between pairs of vertices in an Ising graph ig. The coupling strengths are represented as a matrix, where each element (i, j) corresponds to the interaction energy between vertex i and vertex j.

Arguments:

  • ig::IsingGraph{T}: The Ising graph representing a system of spins with associated interaction strengths.

Returns:

  • J::Matrix{T}: A matrix of coupling strengths between vertices of the Ising graph.

The function iterates over the edges of the Ising graph and extracts the interaction strengths associated with each edge, populating the J matrix accordingly.

source

Potts Hamiltonian

SpinGlassPEPS.SpinGlassNetworks.split_into_clustersFunction
split_into_clusters(
    ig::LabelledGraphs.LabelledGraph{G, L},
    assignment_rule
) -> Dict

Group spins into clusters based on an assignment rule, mapping Potts Hamiltonian coordinates to groups of spins in the Ising graph. Dict(Potts Hamiltonian coordinates -> group of spins in Ising graph)

Arguments:

  • ig::LabelledGraph{G, L}: The Ising graph represented as a labeled graph.
  • assignment_rule: A mapping that assigns Ising graph vertices to clusters based on Potts Hamiltonian coordinates.

Returns:

  • clusters::Dict{L, Vertex}: A dictionary mapping cluster identifiers to representative vertices in the Ising graph.

This function groups spins in the Ising graph into clusters based on an assignment rule. The assignment rule defines how Potts Hamiltonian coordinates correspond to clusters of spins in the Ising graph. Each cluster is represented by a vertex from the Ising graph.

The split_into_clusters function is useful for organizing and analyzing spins in complex spin systems, particularly in the context of Potts Hamiltonian.

source
SpinGlassPEPS.SpinGlassTensors.rank_revealFunction
rank_reveal(energy) -> Tuple{Any, Any}
rank_reveal(energy, order) -> Tuple{Any, Any}

Reveal ranks and energies in a specified order.

This function calculates and reveals the ranks and energies of a set of states in either the 'PE' (Projector Energy) or 'EP' (Energy Projector) order.

Arguments:

  • energy: The energy values of states.
  • order::Symbol: The order in which to reveal the ranks and energies.

It can be either :PE for 'Projector Energy)' order (default) or :EP for 'Energy Projector' order.

Returns:

  • If order is :PE, the function returns a tuple (P, E) where:
    • P: A permutation matrix representing projectors.
    • E: An array of energy values.
  • If order is :EP, the function returns a tuple (E, P) where:
    • E: An array of energy values.
    • P: A permutation matrix representing projectors.
source
SpinGlassPEPS.SpinGlassNetworks.energyFunction
energy(state_code, graph)
  • state_code: state code for which the energy.
  • graph: graph of the ising model.

Returns the state energy.

source
energy(σ::Vector, ig::IsingGraph)

Calculates the energy of a state in an Ising graph.

This function calculates the energy of a given state in the context of an Ising graph. The energy is computed based on the interactions between spins and their associated biases.

Arguments:

  • σ::AbstractArray{State}: An array representing the state of spins in the Ising graph.
  • ig::IsingGraph: The Ising graph defining the interactions and biases.

Returns:

  • Vector{Float64}: An array of energy values for each state.
source
energy(
    ig::LabelledGraphs.LabelledGraph{MetaGraphs.MetaGraph{Int64, T}},
    ig_state::Dict{Int64, Int64}
) -> Any

Calculates the energy of a state in an Ising graph.

This function computes the energy of a given state in the context of an Ising graph. The energy is calculated based on the interactions between spins and their associated biases.

Arguments:

  • ig::IsingGraph{T}: The Ising graph defining the interactions and biases.
  • ig_state::Dict{Int, Int}: A dictionary mapping spin indices to their corresponding states.

Returns:

  • T: The energy of the state in the Ising graph.
source
energy(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    σ::Dict
) -> Any

Calculate the energy of a Potts Hamiltonian state.

This function calculates the energy of a given state in a Potts Hamiltonian. The state is represented as a dictionary mapping each Ising graph vertex to its corresponding spin value.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • σ::Dict{T, Int}: A dictionary mapping Ising graph vertices to their spin values.

Returns:

  • en_potts_h::Float64: The energy of the state in the Potts Hamiltonian.

This function computes the energy by summing the energies associated with individual clusters and the interaction energies between clusters. It takes into account the cluster spectra and projectors stored in the Potts Hamiltonian.

source
SpinGlassPEPS.SpinGlassNetworks.energy_2siteFunction
energy_2site(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    i::Int64,
    j::Int64
) -> Any

Calculate the interaction energy between two nodes in a Potts Hamiltonian.

This function computes the interaction energy between two specified nodes in a Potts Hamiltonian, represented as a labeled graph.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • i::Int: The index of the first site.
  • j::Int: The index of the second site.

Returns:

  • int_eng::AbstractMatrix{T}: The interaction energy matrix between the specified sites.

The function checks if there is an interaction edge between the two sites (i, j) in both directions (i -> j and j -> i). If such edges exist, it retrieves the interaction energy matrix, projectors, and calculates the interaction energy. If no interaction edge is found, it returns a zero matrix.

source
SpinGlassPEPS.SpinGlassNetworks.cluster_sizeFunction
cluster_size(
    potts_hamiltonian::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    vertex
) -> Int64

Get the size of a cluster in a Potts Hamiltonian.

This function returns the size (number of states) of a cluster in a Potts Hamiltonian, represented as a labeled graph.

Arguments:

  • potts_hamiltonian::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • vertex::T: The vertex (cluster) for which the size is to be determined.

Returns:

  • size::Int: The number of states in the specified cluster.

The function retrieves the spectrum associated with the specified cluster and returns the length of the energy vector in that spectrum.

source
cluster_size(
    net::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T},
    v
) -> Any

Determine the cluster size associated with a specific vertex in the Gibbs network.

Arguments

  • net::AbstractGibbsNetwork{S, T}: Gibbs network containing the Potts Hamiltonian.
  • v::S: Vertex for which the cluster size is to be determined.

Returns

  • size::Int: Number of states in the local energy spectrum associated with the specified vertex.
source
SpinGlassPEPS.SpinGlassNetworks.bond_energyFunction
bond_energy(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    potts_h_u::NTuple{N, Int64},
    potts_h_v::NTuple{N, Int64},
    σ::Int64
) -> Any

Calculate the bond energy between two clusters in a Potts Hamiltonian.

This function computes the bond energy between two specified clusters (cluster nodes) in a Potts Hamiltonian, represented as a labeled graph.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • potts_h_u::NTuple{N, Int64}: The coordinates of the first cluster.
  • potts_h_v::NTuple{N, Int64}: The coordinates of the second cluster.
  • σ::Int: Index for which the bond energy is calculated.

Returns:

  • energies::AbstractVector{T}: The bond energy vector between the two clusters for the specified index.

The function checks if there is an edge between the two clusters (u -> v and v -> u). If such edges exist, it retrieves the bond energy matrix and projectors and calculates the bond energy. If no bond edge is found, it returns a zero vector.

source
bond_energy(
    net::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{T, S, R},
    u::NTuple{N, Int64} where N,
    v::NTuple{N, Int64} where N,
    σ::Int64
) -> Any

Calculate the bond energy between nodes u and v for a given index σ in the Gibbs network net.

Arguments

  • net::AbstractGibbsNetwork{T, S}: The Gibbs network.
  • u::Node: One of the nodes connected by the bond.
  • v::Node: The other node connected by the bond.
  • σ::Int: The index for which the bond energy is calculated.

Returns

  • energies::Vector{T}: Vector containing the bond energies between nodes u and v for index σ.
source
SpinGlassPEPS.SpinGlassNetworks.exact_cond_probFunction
exact_cond_prob(
    potts_hamiltonian::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    beta,
    target_state::Dict
) -> Any

Calculate the exact conditional probability of a target state in a Potts Hamiltonian.

This function computes the exact conditional probability of a specified target state in a Potts Hamiltonian, represented as a labelled graph.

Arguments:

  • potts_hamiltonian::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • beta: The inverse temperature parameter.
  • target_state::Dict: A dictionary specifying the target state as a mapping of cluster vertices to Ising spin values.

Returns:

  • prob::Float64: The exact conditional probability of the target state.

The function generates all possible states for the clusters in the Potts Hamiltonian, calculates their energies, and computes the probability distribution based on the given inverse temperature parameter. It then calculates the conditional probability of the specified target state by summing the probabilities of states that match the target state.

source
SpinGlassPEPS.SpinGlassNetworks.decode_potts_hamiltonian_stateFunction
decode_potts_hamiltonian_state(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    state::Vector{Int64}
) -> Dict{Int64, Int64}

Decode a Potts Hamiltonian clustered states into Ising spin states.

This function decodes a state encoded in a Potts Hamiltonian language into states compatible with binary Ising graph and returns a dictionary mapping each Ising graph vertex to its corresponding spin value.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • state::Vector{Int}: The state to be decoded, represented as an array of state indices for each vertex in the Potts Hamiltonian.

Returns:

  • spin_values::Dict{Int, Int}: A dictionary mapping each Ising graph vertex to its corresponding spin value.

This function assumes that the state has the same order as the vertices in the Potts Hamiltonian. It decodes the state consistently based on the cluster assignments and spectra of the Potts Hamiltonian.

source

Belief propagation

SpinGlassPEPS.SpinGlassNetworks.local_energyFunction
local_energy(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    v::Tuple{Int64, Int64, Int64}
) -> Vector{T} where T<:Real

Get the local energy associated with a vertex in a Potts Hamiltonian.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • v::NTuple{3, Int64}: The coordinates of the vertex for which the local energy is requested.

Returns:

  • local_energy::AbstractVector: An abstract vector containing the local energy values associated with the specified vertex.

This function retrieves the local energy values associated with a given vertex v in a Potts Hamiltonian graph potts_h. If the vertex exists in the graph and has associated energy values, it returns those values; otherwise, it returns a vector of zeros.

The local energy values are typically obtained from the spectrum associated with the vertex.

source
local_energy(
    network::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T, R},
    vertex
) -> Any

Retrieve the local energy 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 local energy spectrum is to be retrieved.

Returns

  • Local energy spectrum associated with the specified vertex.
source
SpinGlassPEPS.SpinGlassNetworks.interaction_energyFunction
interaction_energy(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    v::Tuple{Int64, Int64, Int64},
    w::Tuple{Int64, Int64, Int64}
) -> Any

Get the interaction energy between two vertices in a Potts Hamiltonian.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • v::NTuple{3, Int64}: The coordinates of the first vertex.
  • w::NTuple{3, Int64}: The coordinates of the second vertex.

Returns:

  • interaction_energy::AbstractMatrix: An abstract matrix containing the interaction energy values between the specified vertices.

This function retrieves the interaction energy values between two vertices, v and w, in a Potts Hamiltonian graph potts_h. If there is a directed edge from w to v, it returns the corresponding energy values; if there is a directed edge from v to w, it returns the transpose of the energy values; otherwise, it returns a matrix of zeros. The interaction energy values represent the energy associated with the interaction or connection between the two vertices.

source
interaction_energy(
    network::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T, R},
    v,
    w
) -> Any

Compute the interaction energy between two vertices in a Gibbs network.

Arguments

  • network::AbstractGibbsNetwork{S, T}: Gibbs network containing the Potts Hamiltonian.
  • v::S: First vertex.
  • w::S: Second vertex.

Returns

  • energy::Matrix{T}: Interaction energy matrix between vertices v and w.
source
SpinGlassPEPS.SpinGlassNetworks.get_neighborsFunction
get_neighbors(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    vertex::NTuple{N, T} where {N, T}
) -> Vector{Any}

Returns the neighbors of a given vertex in a Potts Hamiltonian.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • vertex::NTuple: The vertex for which neighbors are to be retrieved.

Returns:

  • neighbors::Vector{Tuple}: A vector of tuples representing the neighbors of the specified vertex.

Each tuple contains the following information:

  • dst_node::T: The neighboring vertex.
  • pv::Matrix: The projector associated with the edge connecting the vertex and its neighbor.
  • en::Real: The energy associated with the edge connecting the vertex and its neighbor.

This function retrieves the neighbors of a given vertex in a Potts Hamiltonian graph. It iterates through the edges of the graph and identifies edges connected to the specified vertex. For each neighboring edge, it extracts and returns the neighboring vertex, the associated projector, and the energy.

source
SpinGlassPEPS.SpinGlassNetworks.MergedEnergyType

A custom Julia struct representing energy values in a merged format for use in specific calculations.

Fields:

  • e11::AbstractMatrix{T}
  • e12::AbstractMatrix{T}
  • e21::AbstractMatrix{T}
  • e22::AbstractMatrix{T}

The MergedEnergy struct is used to represent energy values that are organized in a merged format. This format is often utilized in certain computational tasks, where energy values are categorized based on combinations of left and right factors.

Each field of the MergedEnergy struct stores energy values as an AbstractMatrix{T} of type T, where T is a subtype of the Real abstract type. The specific organization and interpretation of these energy values depend on the context in which this struct is used.

source
SpinGlassPEPS.SpinGlassNetworks.update_messageFunction
update_message(
    E_bond::AbstractArray,
    message::Vector,
    beta::Real
) -> Any

Update a message using energy values and temperature.

Arguments:

  • E_bond::AbstractArray: An array of energy values associated with a bond or interaction.
  • message::Vector: The input message vector to be updated.
  • beta::Real: The temperature parameter controlling the influence of energy values.

Returns:

  • updated_message::Vector: The updated message vector after applying the energy-based update.

This function takes energy values E_bond associated with a bond or interaction, an input message vector message, and a temperature parameter beta. It updates the message by first adjusting the energy values relative to their minimum value, exponentiating them with a negative sign and scaling by beta, and then multiplying them element-wise with the input message.

The result is an updated message that reflects the influence of energy values and temperature.

source
update_message(
    E_bond::SpinGlassPEPS.SpinGlassNetworks.MergedEnergy,
    message::Vector,
    beta::Real
) -> Any

Update a message using energy values and temperature in a merged energy format.

Arguments:

  • E_bond::MergedEnergy: An instance of the MergedEnergy type representing energy values for the bond or interaction.
  • message::Vector: The input message vector to be updated.
  • beta::Real: The temperature parameter controlling the influence of energy values.

Returns:

  • updated_message::Vector: The updated message vector after applying the energy-based update.

This function takes energy values E_bond in a merged energy format, an input message vector message, and a temperature parameter beta. It updates the message based on the energy values and temperature using a specified algorithm.

The MergedEnergy type represents energy values in a merged format, and the function processes these values accordingly to update the message vector.

source
SpinGlassPEPS.SpinGlassNetworks.merge_vertices_potts_hFunction
merge_vertices_potts_h(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    β::Real,
    node1::Tuple{Int64, Int64, Int64},
    node2::Tuple{Int64, Int64, Int64}
) -> Tuple{SpinGlassPEPS.SpinGlassNetworks.MergedEnergy, Any, Any}

Merge two vertices in a Potts Hamiltonian to create a single merged vertex.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • β::Real: The temperature parameter controlling the influence of energy values.
  • node1::NTuple{3, Int64}: The coordinates of the first vertex to merge.
  • node2::NTuple{3, Int64}: The coordinates of the second vertex to merge.

Returns:

  • merged_energy::MergedEnergy: An instance of the MergedEnergy type representing the merged energy values.
  • pl::AbstractVector: The merged left projector.
  • pr::AbstractVector: The merged right projector.

This function merges two vertices in a Potts Hamiltonian graph potts_h to create a single merged vertex. The merging process combines projectors and energy values associated with the original vertices based on the provided temperature parameter β.

The merged energy values, left projector pl, and right projector pr are computed based on the interactions between the original vertices and their respective projectors.

source
SpinGlassPEPS.SpinGlassNetworks.projectorFunction
projector(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    v::NTuple{N, Int64},
    w::NTuple{N, Int64}
) -> Union{Vector{Int64}, CUDA.CuVector{Int64}, CUDA.DenseCuVector{Int64}}

Get the projector associated with an edge between two vertices in a Potts Hamiltonian.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • v::NTuple{N, Int64}: The coordinates of one of the two vertices connected by the edge.
  • w::NTuple{N, Int64}: The coordinates of the other vertex connected by the edge.

Returns:

  • p::AbstractVector: An abstract vector representing the projector associated with the specified edge.

This function retrieves the projector associated with an edge between two vertices, v and w, in a Potts Hamiltonian graph potts_h. If there is a directed edge from w to v, it returns the index of right projector (:ipr); if there is a directed edge from v to w, it returns the index of left projector (:ipl). If no edge exists between the vertices, it returns a vector of ones.

source
projector(
    network::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T},
    v,
    w
) -> Any

Compute the projector between two nodes v and w in the Gibbs network network.

Arguments

  • network::AbstractGibbsNetwork{S, T}: The Gibbs network.
  • v::S: Source node.
  • w::S: Target node.

Returns

  • projector::Matrix{T}: Projector matrix between nodes v and w.
source
projector(
    net::SpinGlassPEPS.SpinGlassEngine.AbstractGibbsNetwork{S, T},
    v,
    vertices::NTuple{N, S}
) -> Any

Compute the projector matrix for the given node v onto a tuple of target nodes vertices in the Gibbs network net.

Arguments

  • net::AbstractGibbsNetwork{S, T}: The Gibbs network.
  • v::S: Source node.
  • vertices::NTuple{N, S}: Tuple of target nodes onto which the projector is computed.

Returns

  • first fused projector matrix for node v onto the specified target nodes.
source
SpinGlassPEPS.SpinGlassNetworks.SparseCSCFunction
SparseCSC(
    _::Type{R<:Real},
    p::Vector{Int64}
) -> SparseArrays.SparseMatrixCSC{Tv, Int64} where Tv<:Real

Create a sparse column-compressed (CSC) matrix with specified column indices and values.

Arguments:

  • ::Type{R}: The element type of the sparse matrix (e.g., Float64, Int64).
  • p::Vector{Int64}: A vector of column indices for the non-zero values.

Returns:

  • sparse_matrix::SparseMatrixCSC{R}: A sparse column-compressed matrix with non-zero values at specified columns.

This constructor function creates a sparse column-compressed (CSC) matrix of element type R based on the provided column indices p and values. The resulting matrix has non-zero values at the specified column indices, while all other elements are zero. The SparseCSC constructor is useful for creating sparse matrices with specific column indices and values efficiently.

source

Spectrum

SpinGlassPEPS.SpinGlassNetworks.SpectrumType

A Spectrum represents the energy spectrum of a system.

A Spectrum consists of energy levels, their corresponding states, and integer representations of the states.

Fields:

  • energies::Vector{<:Real}: An array of energy levels.
  • states::AbstractArray{State}: An array of states.
  • states_int::Vector{Int}: An array of integer representations of states.

Constructors:

  • Spectrum(energies, states, states_int): Creates a Spectrum object with the specified energy levels, states, and integer representations.
  • Spectrum(energies, states): Creates a Spectrum object with the specified energy levels and states, automatically generating integer representations.
source
SpinGlassPEPS.SpinGlassNetworks.matrix_to_integersFunction
matrix_to_integers(
    matrix::Vector{<:Vector{<:Integer}}
) -> Any

Converts a matrix of binary vectors to their integer representations.

This function takes a matrix of binary vectors, where each row represents a binary vector, and converts them into their corresponding integer representations.

Arguments:

  • matrix::Vector{Vector{T}}: A matrix of binary vectors.

Returns:

  • Vector{Int}: An array of integer representations of the binary vectors.
source
SpinGlassPEPS.SpinGlassNetworks.gibbs_tensorFunction
gibbs_tensor(
    ig::LabelledGraphs.LabelledGraph{MetaGraphs.MetaGraph{Int64, T}}
) -> Any
gibbs_tensor(
    ig::LabelledGraphs.LabelledGraph{MetaGraphs.MetaGraph{Int64, T}},
    β
) -> Any

Computes the Gibbs tensor for an Ising graph at a given inverse temperature.

This function calculates the Gibbs tensor for an Ising graph at a specified inverse temperature (β). The Gibbs tensor represents the conditional probabilities of states given the inverse temperature and the Ising graph.

Arguments:

  • ig::IsingGraph{T}: The Ising graph for which the Gibbs tensor is computed.
  • β::T (optional): The inverse temperature parameter. Default is 1.

Returns:

  • Matrix{T}: A matrix representing the Gibbs tensor with conditional probabilities.
source
SpinGlassPEPS.SpinGlassNetworks.brute_forceFunction
brute_force(ig, ; num_states)
  • ig::IsingGraph: graph of ising model represented by IsingGraph structure.

Returns energies and states for provided model by naive brute-forece alorithm based on GPU.

source
brute_force(
    ig::LabelledGraphs.LabelledGraph{MetaGraphs.MetaGraph{Int64, T}},
    ::Val{:CPU};
    num_states
) -> Union{Spectrum{T, Vector{Vector{Vector{Int64}}}} where T<:Real, Spectrum{T, Vector{Vector{<:Integer}}} where T<:Real}

TODO only one of bruteforce and fullspectrum should remain

Performs brute-force calculation of the lowest-energy states and their energies for an Ising graph.

This function exhaustively computes the lowest-energy states and their corresponding energies for an Ising graph. The calculation is done using brute-force enumeration, making it feasible only for small Ising graphs.

Arguments:

  • ig::IsingGraph{T}: The Ising graph for which the lowest-energy states are computed.
  • ::Val{:CPU}: A value indicating that the computation is performed on the CPU.
  • num_states::Int (optional): The maximum number of lowest-energy states to calculate. Default is 1.

Returns:

  • Spectrum: A Spectrum object containing the lowest-energy states and their energies.
source

Truncate

SpinGlassPEPS.SpinGlassNetworks.truncate_potts_hamiltonian_1site_BPFunction
truncate_potts_hamiltonian_1site_BP(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    num_states::Int64;
    beta,
    tol,
    iter
) -> PottsHamiltonian

Truncates a Potts Hamiltonian using belief propagation (BP) for a single site cluster.

This function employs belief propagation (BP) to approximate the most probable states and energies for a Potts Hamiltonian associated with a single-site cluster. It then truncates the Potts Hamiltonian based on the most probable states.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • num_states::Int: The maximum number of most probable states to keep.
  • beta::Real (optional): The inverse temperature parameter for the BP algorithm. Default is 1.0.
  • tol::Real (optional): The tolerance value for convergence in BP. Default is 1e-10.
  • iter::Int (optional): The maximum number of BP iterations. Default is 1.

Returns:

  • LabelledGraph{S, T}: A truncated Potts Hamiltonian.
source
SpinGlassPEPS.SpinGlassNetworks.truncate_potts_hamiltonian_2site_energyFunction
truncate_potts_hamiltonian_2site_energy(
    potts_h::SpinGlassPEPS.SpinGlassNetworks.PottsLike,
    num_states::Int64
) -> PottsHamiltonian

Truncate a Potts Hamiltonian based on 2-site energy states.

This function truncates a Potts Hamiltonian by considering 2-site energy states and selecting the most probable states to keep. It computes the energies for all 2-site combinations and selects the states that maximize the probability.

Arguments:

  • potts_h::LabelledGraph{S, T}: The Potts Hamiltonian represented as a labeled graph.
  • num_states::Int: The maximum number of most probable states to keep.

Returns:

  • LabelledGraph{S, T}: A truncated Potts Hamiltonian.
source
SpinGlassPEPS.SpinGlassNetworks.select_numstate_bestFunction
select_numstate_best(E, sx, num_states) -> Tuple{Any, Any}

Select a specified number of best states based on energy.

This function selects a specified number of best states from a list of energies based on energy values in two nodes of Potts Hamiltonian. It fine-tunes the selection to ensure that the resulting states have the expected number.

Arguments:

  • E::Vector{Real}: A vector of energy values.
  • sx::Int: The size of the Potts Hamiltonian for one of the nodes.
  • num_states::Int: The desired number of states to select.

Returns:

  • Tuple{Vector{Int}, Vector{Int}}: A tuple containing two vectors of indices, ind1 and ind2,

which represent the selected states for two nodes of a Potts Hamiltonian.

source

Auxiliary Functions

SpinGlassPEPS.SpinGlassNetworks.load_openGMFunction

Loads some factored graphs written in openGM format. Assumes rectangular lattice.

Args: filename (str): a path to file with factor graph in openGM format. ints Nx, Ny: it is assumed that graph if forming an :math:Nx imes N_y lattice with nearest-neighbour interactions only.

Returns: dictionary with factors and funcitons defining the energy functional.

source