diff --git a/Project.toml b/Project.toml index 079f5a27..4a32df05 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SpinGlassEngine" uuid = "0563570f-ea1b-4080-8a64-041ac6565a4e" authors = ["Anna Maria Dziubyna ", "Tomasz Śmierzchalski ", "Bartłomiej Gardas ", "Konrad Jałowiecki ", "Łukasz Pawela ", "Marek M. Rams "] -version = "1.2.0" +version = "1.3.0" [deps] CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" @@ -32,7 +32,7 @@ MKL = "0.4.3" NNlib = "0.9.14" ProgressMeter = "1.10" SpinGlassExhaustive = "1.0.0" -SpinGlassNetworks = "1.1.2" +SpinGlassNetworks = "1.2.0" SpinGlassTensors = "1.1.3" Statistics = "1.7.0" TensorCast = "0.4" diff --git a/docs/src/guide.md b/docs/src/guide.md index e2429dc8..15bbac6e 100644 --- a/docs/src/guide.md +++ b/docs/src/guide.md @@ -1,5 +1,5 @@ # Introduction A [Julia](http://julialang.org) package for finding low energy spectrum of Ising spin systems. Part of [SpinGlassPEPS](https://github.com/euro-hpc-pl/SpinGlassPEPS.jl) package. -This part of the documentation is dedicated to describing the `SpinGlassEngine.jl` package, which serves as the actual solver. First, we will demonstrate how to construct a tensor network using the clustered Hamiltonian obtained with the `SpinGlassNetworks.jl` package. Next, we discuss the parameters necessary for conducting calculations, which the user should provide. Finally, we present functions that enable the discovery of low-energy spectra. +This part of the documentation is dedicated to describing the `SpinGlassEngine.jl` package, which serves as the actual solver. First, we will demonstrate how to construct a tensor network using the Potts Hamiltonian obtained with the `SpinGlassNetworks.jl` package. Next, we discuss the parameters necessary for conducting calculations, which the user should provide. Finally, we present functions that enable the discovery of low-energy spectra. diff --git a/docs/src/params.md b/docs/src/params.md index 556c5bf3..cc67e234 100644 --- a/docs/src/params.md +++ b/docs/src/params.md @@ -54,12 +54,12 @@ SquareSingleNode SquareDoubleNode ``` -* `SquareCrossSingleNode` +* `KingSingleNode` ```@raw html ``` ```@docs -SquareCrossSingleNode +KingSingleNode ``` * `SquareCrossDoubleNode` diff --git a/docs/src/peps.md b/docs/src/peps.md index 821a0c53..aa39442b 100644 --- a/docs/src/peps.md +++ b/docs/src/peps.md @@ -1,6 +1,6 @@ # Constructing PEPS tensor network -After creating the clustered Hamiltonian, we can turn it into a PEPS tensor network as shown in the Section [Brief description of the algorithm](../algorithm.md). +After creating the Potts Hamiltonian, we can turn it into a PEPS tensor network as shown in the Section [Brief description of the algorithm](../algorithm.md). ```@docs PEPSNetwork @@ -22,11 +22,11 @@ Layout = GaugesEnergy Sparsity = Sparse ig = ising_graph(instance) -cl_h = clustered_hamiltonian( +potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule=super_square_lattice((m, n, t)) ) -net = PEPSNetwork{SquareCrossSingleNode{Layout}, Sparsity}(m, n, cl_h, transform) +net = PEPSNetwork{KingSingleNode{Layout}, Sparsity}(m, n, potts_h, transform) ``` diff --git a/examples/pegasus.jl b/examples/pegasus.jl index 1712add4..3341d482 100644 --- a/examples/pegasus.jl +++ b/examples/pegasus.jl @@ -19,7 +19,7 @@ function bench(instance::String, β::Real, bond_dim::Integer, num_states::Intege δp = exp(-β * dE) all_betas = [β / 8, β / 4, β / 2, β] - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ising_graph(instance), spectrum = my_brute_force, cluster_assignment_rule = pegasus_lattice((m, n, t)), @@ -32,7 +32,7 @@ function bench(instance::String, β::Real, bond_dim::Integer, num_states::Intege Layout = GaugesEnergy transform = rotation(0) Gauge = NoUpdate - net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}(m, n, cl_h, transform) + net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}(m, n, potts_h, transform) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; diff --git a/examples/truncation_BP.jl b/examples/truncation_BP.jl index 560d8997..751b0a6a 100644 --- a/examples/truncation_BP.jl +++ b/examples/truncation_BP.jl @@ -61,14 +61,14 @@ for cs ∈ cl_states println("Transform ", tran) println("Iter ", iter) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, #rm _gpu to use CPU cluster_assignment_rule = pegasus_lattice((m, n, t)), ) - @time cl_h = truncate_clustered_hamiltonian( - cl_h, + @time potts_h = truncate_potts_hamiltonian( + potts_h, β, cs, results_folder, @@ -76,9 +76,9 @@ for cs ∈ cl_states tol = 1e-6, iter = iter, ) - # @time cl_h = truncate_clustered_hamiltonian_2site_energy(cl_h, cs) - for v in vertices(cl_h) - println(length(get_prop(cl_h, v, :spectrum).states)) + # @time potts_h = truncate_potts_hamiltonian_2site_energy(potts_h, cs) + for v in vertices(potts_h) + println(length(get_prop(potts_h, v, :spectrum).states)) end end end diff --git a/src/PEPS.jl b/src/PEPS.jl index 374aea40..a4f6dcc4 100644 --- a/src/PEPS.jl +++ b/src/PEPS.jl @@ -35,12 +35,12 @@ Construct a Projected Entangled Pair States (PEPS) network. # Arguments - `m::Int`: Number of rows in the PEPS lattice. - `n::Int`: Number of columns in the PEPS lattice. -- `clustered_hamiltonian::LabelledGraph`: clustered hamiltonian representing the Hamiltonian. +- `potts_hamiltonian::LabelledGraph`: Potts Hamiltonian representing the Hamiltonian. - `transformation::LatticeTransformation`: Transformation of the PEPS lattice, as it can be rotated or reflected. - `gauge_type::Symbol=:id`: Type of gauge to initialize (default is identity). # Type Parameters -- `T <: AbstractGeometry`: Type of geometry for the PEPS lattice. It can be `SquareSingleNode`, `SquareDoubleNode`, `SquareCrossSingleNode`, `SquareCrossDoubleNode`. +- `T <: AbstractGeometry`: Type of geometry for the PEPS lattice. It can be `SquareSingleNode`, `SquareDoubleNode`, `KingSingleNode`, `SquareCrossDoubleNode`. - `S <: AbstractSparsity`: Type of sparsity for the PEPS tensors: `Dense` or `Sparse`. # Returns @@ -48,7 +48,7 @@ An instance of PEPSNetwork{T, S}. """ mutable struct PEPSNetwork{T<:AbstractGeometry,S<:AbstractSparsity,R<:Real} <: AbstractGibbsNetwork{Node,PEPSNode,R} - clustered_hamiltonian::LabelledGraph + potts_hamiltonian::LabelledGraph vertex_map::Function lp::PoolOfProjectors m::Int @@ -61,15 +61,15 @@ mutable struct PEPSNetwork{T<:AbstractGeometry,S<:AbstractSparsity,R<:Real} <: function PEPSNetwork{T,S,R}( m::Int, n::Int, - clustered_hamiltonian::LabelledGraph, + potts_hamiltonian::LabelledGraph, transformation::LatticeTransformation, gauge_type::Symbol = :id, ) where {T<:AbstractGeometry,S<:AbstractSparsity,R<:Real} - lp = get_prop(clustered_hamiltonian, :pool_of_projectors) - net = new(clustered_hamiltonian, vertex_map(transformation, m, n), lp, m, n) + lp = get_prop(potts_hamiltonian, :pool_of_projectors) + net = new(potts_hamiltonian, vertex_map(transformation, m, n), lp, m, n) net.nrows, net.ncols = transformation.flips_dimensions ? (n, m) : (m, n) - if !is_compatible(net.clustered_hamiltonian, T.name.wrapper(m, n)) + if !is_compatible(net.potts_hamiltonian, T.name.wrapper(m, n)) throw(ArgumentError("Factor graph not compatible with given network.")) end @@ -139,8 +139,8 @@ function bond_energy( v::Node, σ::Int, ) where {T,S,R} - cl_h_u, cl_h_v = net.vertex_map(u), net.vertex_map(v) - energies = SpinGlassNetworks.bond_energy(net.clustered_hamiltonian, cl_h_u, cl_h_v, σ) + potts_h_u, potts_h_v = net.vertex_map(u), net.vertex_map(v) + energies = SpinGlassNetworks.bond_energy(net.potts_hamiltonian, potts_h_u, potts_h_v, σ) R.(vec(energies)) end @@ -158,9 +158,9 @@ Compute the projector between two nodes `v` and `w` in the Gibbs network `networ - `projector::Matrix{T}`: Projector matrix between nodes `v` and `w`. """ function projector(network::AbstractGibbsNetwork{S,T}, v::S, w::S) where {S,T} - cl_h = network.clustered_hamiltonian - cl_h_v, cl_h_w = network.vertex_map(v), network.vertex_map(w) - SpinGlassNetworks.projector(cl_h, cl_h_v, cl_h_w) + potts_h = network.potts_hamiltonian + potts_h_v, potts_h_w = network.vertex_map(v), network.vertex_map(w) + SpinGlassNetworks.projector(potts_h, potts_h_v, potts_h_w) end """ @@ -215,14 +215,14 @@ $(TYPEDSIGNATURES) Retrieve the spectrum associated with a specific vertex in the Gibbs network. ## Arguments -- `network::AbstractGibbsNetwork{S, T}`: Gibbs network containing the clustered Hamiltonian. +- `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. """ function spectrum(network::AbstractGibbsNetwork{S,T}, vertex::S) where {S,T} - get_prop(network.clustered_hamiltonian, network.vertex_map(vertex), :spectrum) + get_prop(network.potts_hamiltonian, network.vertex_map(vertex), :spectrum) end """ @@ -230,7 +230,7 @@ $(TYPEDSIGNATURES) Retrieve the local energy spectrum associated with a specific vertex in the Gibbs network. ## Arguments -- `network::AbstractGibbsNetwork{S, T}`: Gibbs network containing the clustered Hamiltonian. +- `network::AbstractGibbsNetwork{S, T}`: Gibbs network containing the Potts Hamiltonian. - `vertex::S`: Vertex for which the local energy spectrum is to be retrieved. ## Returns @@ -246,7 +246,7 @@ $(TYPEDSIGNATURES) Determine the cluster size associated with a specific vertex in the Gibbs network. ## Arguments -- `net::AbstractGibbsNetwork{S, T}`: Gibbs network containing the clustered Hamiltonian. +- `net::AbstractGibbsNetwork{S, T}`: Gibbs network containing the Potts Hamiltonian. - `v::S`: Vertex for which the cluster size is to be determined. ## Returns @@ -261,7 +261,7 @@ $(TYPEDSIGNATURES) Compute the interaction energy between two vertices in a Gibbs network. ## Arguments -- `network::AbstractGibbsNetwork{S, T}`: Gibbs network containing the clustered Hamiltonian. +- `network::AbstractGibbsNetwork{S, T}`: Gibbs network containing the Potts Hamiltonian. - `v::S`: First vertex. - `w::S`: Second vertex. @@ -269,12 +269,12 @@ Compute the interaction energy between two vertices in a Gibbs network. - `energy::Matrix{T}`: Interaction energy matrix between vertices `v` and `w`. """ function interaction_energy(network::AbstractGibbsNetwork{S,T,R}, v::S, w::S) where {S,T,R} - cl_h = network.clustered_hamiltonian - cl_h_v, cl_h_w = network.vertex_map(v), network.vertex_map(w) - if has_edge(cl_h, cl_h_w, cl_h_v) - R.(get_prop(cl_h, cl_h_w, cl_h_v, :en)') - elseif has_edge(cl_h, cl_h_v, cl_h_w) - R.(get_prop(cl_h, cl_h_v, cl_h_w, :en)) + potts_h = network.potts_hamiltonian + potts_h_v, potts_h_w = network.vertex_map(v), network.vertex_map(w) + if has_edge(potts_h, potts_h_w, potts_h_v) + R.(get_prop(potts_h, potts_h_w, potts_h_v, :en)') + elseif has_edge(potts_h, potts_h_v, potts_h_w) + R.(get_prop(potts_h, potts_h_v, potts_h_w, :en)) else zeros(R, 1, 1) end @@ -282,19 +282,19 @@ end """ $(TYPEDSIGNATURES) -Check if a clustered Hamiltonian is compatible with a given network graph. +Check if a Potts Hamiltonian is compatible with a given network graph. ## Arguments -- `clustered_hamiltonian::LabelledGraph`: Graph representing the clustered Hamiltonian. +- `potts_hamiltonian::LabelledGraph`: Graph representing the Potts Hamiltonian. - `network_graph::LabelledGraph`: Graph representing the network. ## Returns -- `compatibility::Bool`: `true` if the clustered Hamiltonian is compatible with the network graph, `false` otherwise. +- `compatibility::Bool`: `true` if the Potts Hamiltonian is compatible with the network graph, `false` otherwise. """ -function is_compatible(clustered_hamiltonian::LabelledGraph, network_graph::LabelledGraph) +function is_compatible(potts_hamiltonian::LabelledGraph, network_graph::LabelledGraph) all( has_edge(network_graph, src(edge), dst(edge)) for - edge ∈ edges(clustered_hamiltonian) + edge ∈ edges(potts_hamiltonian) ) end @@ -377,7 +377,7 @@ Decode a state vector into a dictionary representation. ## Arguments - `peps::AbstractGibbsNetwork{S, T}`: The Gibbs network. - `σ::Vector{Int}`: State vector to be decoded. -- `cl_h_order::Bool=false`: If true, use the order of nodes in the clustered Hamiltonian. +- `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. @@ -385,10 +385,10 @@ Decode a state vector into a dictionary representation. function decode_state( peps::AbstractGibbsNetwork{S,T}, σ::Vector{Int}, - cl_h_order::Bool = false, + potts_h_order::Bool = false, ) where {S,T} nodes = - cl_h_order ? peps.vertex_map.(nodes_search_order_Mps(peps)) : - vertices(peps.clustered_hamiltonian) + potts_h_order ? peps.vertex_map.(nodes_search_order_Mps(peps)) : + vertices(peps.potts_hamiltonian) Dict(nodes[1:length(σ)] .=> σ) end diff --git a/src/SpinGlassEngine.jl b/src/SpinGlassEngine.jl index 2740f2cb..c12d300a 100644 --- a/src/SpinGlassEngine.jl +++ b/src/SpinGlassEngine.jl @@ -21,7 +21,7 @@ include("geometry.jl") include("PEPS.jl") include("contractor.jl") include("square_single_node.jl") -include("square_cross_single_node.jl") +include("king_single_node.jl") include("square_double_node.jl") include("square_cross_double_node.jl") include("tensors.jl") diff --git a/src/contractor.jl b/src/contractor.jl index 29efd5e9..fa1b7ea0 100644 --- a/src/contractor.jl +++ b/src/contractor.jl @@ -896,7 +896,7 @@ function boundary_indices( states::Vector{Vector{Int}}, ) where {T,S,N} v, w = nodes - if ctr.peps.vertex_map(v) ∈ vertices(ctr.peps.clustered_hamiltonian) + if ctr.peps.vertex_map(v) ∈ vertices(ctr.peps.potts_hamiltonian) @inbounds idx = [σ[ctr.node_search_index[v]] for σ ∈ states] return @inbounds projector(ctr.peps, v, w)[idx] end diff --git a/src/geometry.jl b/src/geometry.jl index 3805e2ba..0858df69 100644 --- a/src/geometry.jl +++ b/src/geometry.jl @@ -37,7 +37,7 @@ const Node = NTuple{N,Int} where {N} """ $(TYPEDSIGNATURES) -Node for the SquareSingleNode and SquareCrossSingleNode. +Node for the SquareSingleNode and KingSingleNode. """ struct PEPSNode i::Site diff --git a/src/square_cross_single_node.jl b/src/king_single_node.jl similarity index 86% rename from src/square_cross_single_node.jl rename to src/king_single_node.jl index 72c87c88..e646c186 100644 --- a/src/square_cross_single_node.jl +++ b/src/king_single_node.jl @@ -1,4 +1,4 @@ -export SquareCrossSingleNode +export KingSingleNode """ $(TYPEDSIGNATURES) @@ -10,9 +10,9 @@ and additional diagonal edges forming a cross pattern between neighboring nodes. - `T <: AbstractTensorsLayout`: The layout of decomposition of tensors into MPS. Can be `GaugesEnergy`, `EnergyGauges` or `EngGaugesEng`. # Constructors -- `SquareCrossSingleNode(layout::T)`: Create a `SquareCrossSingleNode` with the specified tensor layout. +- `KingSingleNode(layout::T)`: Create a `KingSingleNode` with the specified tensor layout. """ -struct SquareCrossSingleNode{T<:AbstractTensorsLayout} <: AbstractGeometry end +struct KingSingleNode{T<:AbstractTensorsLayout} <: AbstractGeometry end """ $(TYPEDSIGNATURES) @@ -28,7 +28,7 @@ edges forming a cross pattern between neighboring nodes. A `LabelledGraph` representing a grid graph with nodes arranged in an m x n grid, and additional diagonal edges forming a cross pattern between neighboring nodes. """ -function SquareCrossSingleNode(m::Int, n::Int) +function KingSingleNode(m::Int, n::Int) lg = SquareSingleNode(m, n) for i ∈ 1:m-1, j ∈ 1:n-1 add_edge!(lg, (i, j), (i + 1, j + 1)) @@ -45,7 +45,7 @@ VirtualSingleNode(::Type{Sparse}) = :sparse_virtual_single_node function tensor_map( - ::Type{SquareCrossSingleNode{T}}, + ::Type{KingSingleNode{T}}, ::Type{S}, nrows::Int, ncols::Int, @@ -68,7 +68,7 @@ end function tensor_map( - ::Type{SquareCrossSingleNode{T}}, + ::Type{KingSingleNode{T}}, ::Type{S}, nrows::Int, ncols::Int, @@ -96,7 +96,7 @@ end function gauges_list( - ::Type{SquareCrossSingleNode{T}}, + ::Type{KingSingleNode{T}}, nrows::Int, ncols::Int, ) where {T<:GaugesEnergy} @@ -112,7 +112,7 @@ end function gauges_list( - ::Type{SquareCrossSingleNode{T}}, + ::Type{KingSingleNode{T}}, nrows::Int, ncols::Int, ) where {T<:EnergyGauges} @@ -128,7 +128,7 @@ end function gauges_list( - ::Type{SquareCrossSingleNode{T}}, + ::Type{KingSingleNode{T}}, nrows::Int, ncols::Int, ) where {T<:EngGaugesEng} @@ -145,9 +145,9 @@ end """ $(TYPEDSIGNATURES) -Defines the MPO layers for the SquareCrossSingleNode geometry with the EnergyGauges layout. +Defines the MPO layers for the KingSingleNode geometry with the EnergyGauges layout. """ -function MpoLayers(::Type{T}, ncols::Int) where {T<:SquareCrossSingleNode{EnergyGauges}} +function MpoLayers(::Type{T}, ncols::Int) where {T<:KingSingleNode{EnergyGauges}} MpoLayers( Dict(site(i) => (-1 // 6, 0, 3 // 6, 4 // 6) for i ∈ 1//2:1//2:ncols), Dict(site(i) => (3 // 6, 4 // 6) for i ∈ 1//2:1//2:ncols), @@ -158,9 +158,9 @@ end """ $(TYPEDSIGNATURES) -Defines the MPO layers for the SquareCrossSingleNode geometry with the GaugesEnergy layout. +Defines the MPO layers for the KingSingleNode geometry with the GaugesEnergy layout. """ -function MpoLayers(::Type{T}, ncols::Int) where {T<:SquareCrossSingleNode{GaugesEnergy}} +function MpoLayers(::Type{T}, ncols::Int) where {T<:KingSingleNode{GaugesEnergy}} MpoLayers( Dict(site(i) => (-4 // 6, -1 // 2, 0, 1 // 6) for i ∈ 1//2:1//2:ncols), Dict(site(i) => (1 // 6,) for i ∈ 1//2:1//2:ncols), @@ -171,9 +171,9 @@ end """ $(TYPEDSIGNATURES) -Defines the MPO layers for the SquareCrossSingleNode geometry with the EngGaugesEng layout. +Defines the MPO layers for the KingSingleNode geometry with the EngGaugesEng layout. """ -function MpoLayers(::Type{T}, ncols::Int) where {T<:SquareCrossSingleNode{EngGaugesEng}} +function MpoLayers(::Type{T}, ncols::Int) where {T<:KingSingleNode{EngGaugesEng}} MpoLayers( Dict(site(i) => (-2 // 5, -1 // 5, 0, 1 // 5, 2 // 5) for i ∈ 1//2:1//2:ncols), Dict(site(i) => (1 // 5, 2 // 5) for i ∈ 1//2:1//2:ncols), @@ -187,7 +187,7 @@ function conditional_probability( ::Type{T}, ctr::MpsContractor{S}, ∂v::Vector{Int}, -) where {T<:SquareCrossSingleNode,S} +) where {T<:KingSingleNode,S} indβ, β = length(ctr.betas), last(ctr.betas) i, j = ctr.current_node @@ -229,7 +229,7 @@ end function projectors_site_tensor( network::PEPSNetwork{T,S}, vertex::Node, -) where {T<:SquareCrossSingleNode,S} +) where {T<:KingSingleNode,S} i, j = vertex nbrs = ( (@ntuple 3 k -> (i + 2 - k, j - 1)), @@ -241,7 +241,7 @@ function projectors_site_tensor( end -function nodes_search_order_Mps(peps::PEPSNetwork{T,S}) where {T<:SquareCrossSingleNode,S} +function nodes_search_order_Mps(peps::PEPSNetwork{T,S}) where {T<:KingSingleNode,S} ([(i, j) for i ∈ 1:peps.nrows for j ∈ 1:peps.ncols], (peps.nrows + 1, 1)) end @@ -250,7 +250,7 @@ function boundary( ::Type{T}, ctr::MpsContractor{S}, node::Node, -) where {T<:SquareCrossSingleNode,S} +) where {T<:KingSingleNode,S} i, j = node vcat( [ @@ -273,7 +273,7 @@ function update_energy( ::Type{T}, ctr::MpsContractor{S}, σ::Vector{Int}, -) where {T<:SquareCrossSingleNode,S} +) where {T<:KingSingleNode,S} net = ctr.peps i, j = ctr.current_node en = local_energy(net, (i, j)) @@ -285,7 +285,7 @@ end function tensor( - net::PEPSNetwork{SquareCrossSingleNode{T},S}, + net::PEPSNetwork{KingSingleNode{T},S}, node::PEPSNode, β::Real, ::Val{:central_d_single_node}, @@ -299,7 +299,7 @@ end function Base.size( - network::PEPSNetwork{SquareCrossSingleNode{T},S}, + network::PEPSNetwork{KingSingleNode{T},S}, node::PEPSNode, ::Val{:central_d_single_node}, ) where {T<:AbstractTensorsLayout,S<:AbstractSparsity} @@ -311,7 +311,7 @@ end function tensor( - net::PEPSNetwork{SquareCrossSingleNode{T},S}, + net::PEPSNetwork{KingSingleNode{T},S}, node::PEPSNode, β::Real, ::Val{:sparse_virtual_single_node}, @@ -334,7 +334,7 @@ end function tensor( - net::PEPSNetwork{SquareCrossSingleNode{T},Dense}, + net::PEPSNetwork{KingSingleNode{T},Dense}, node::PEPSNode, β::Real, ::Val{:virtual_single_node}, diff --git a/src/search.jl b/src/search.jl index 8018c867..521e97a2 100644 --- a/src/search.jl +++ b/src/search.jl @@ -249,7 +249,7 @@ Retrieve the local spin configurations associated with a vertex in the Gibbs net ## 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 clustered Hamiltonian associated with the vertex. +The local spins are extracted from the spectrum of the Potts Hamiltonian associated with the vertex. """ function local_spins(network::AbstractGibbsNetwork{S,T}, vertex::S) where {S,T} spectrum(network, vertex).states_int @@ -621,7 +621,7 @@ function low_energy_spectrum( # Translate variable order (network --> factor graph) inner_perm = sortperm([ - ctr.peps.clustered_hamiltonian.reverse_label_map[idx] for + ctr.peps.potts_hamiltonian.reverse_label_map[idx] for idx ∈ ctr.peps.vertex_map.(ctr.nodes_search_order) ]) @@ -644,7 +644,7 @@ function low_energy_spectrum( # Final check if states correspond energies @assert sol.energies ≈ energy.( - Ref(ctr.peps.clustered_hamiltonian), + Ref(ctr.peps.potts_hamiltonian), decode_state.(Ref(ctr.peps), sol.states), ) sol, s @@ -703,7 +703,7 @@ function gibbs_sampling( # Translate variable order (network --> factor graph) inner_perm = sortperm([ - ctr.peps.clustered_hamiltonian.reverse_label_map[idx] for + ctr.peps.potts_hamiltonian.reverse_label_map[idx] for idx ∈ ctr.peps.vertex_map.(ctr.nodes_search_order) ]) @@ -725,7 +725,7 @@ function gibbs_sampling( # Final check if states correspond energies @assert sol.energies ≈ energy.( - Ref(ctr.peps.clustered_hamiltonian), + Ref(ctr.peps.potts_hamiltonian), decode_state.(Ref(ctr.peps), sol.states), ) sol diff --git a/src/square_cross_double_node.jl b/src/square_cross_double_node.jl index e35ea523..3a2d9206 100644 --- a/src/square_cross_double_node.jl +++ b/src/square_cross_double_node.jl @@ -12,7 +12,7 @@ Each node is labeled with a tuple (i, j, k), where i is the row index, j is the - `T <: AbstractTensorsLayout`: The layout of decomposition of tensors into MPS. Can be `GaugesEnergy`, `EnergyGauges` or `EngGaugesEng`. # Constructors -- `SquareCrossSingleNode(layout::T)`: Create a `SquareCrossDoubleNode` with the specified tensor layout. +- `KingSingleNode(layout::T)`: Create a `SquareCrossDoubleNode` with the specified tensor layout. ## Description `SquareCrossDoubleNode` is a geometry type that models a double unit cell square lattice with diagonal interaction. diff --git a/src/util.jl b/src/util.jl index e6fefa5e..7982df18 100644 --- a/src/util.jl +++ b/src/util.jl @@ -8,26 +8,26 @@ export exact_marginal_probability, """ $(TYPEDSIGNATURES) -Calculate the exact spectrum and corresponding eigenstates for a clustered Hamiltonian using memoization. +Calculate the exact spectrum and corresponding eigenstates for a Potts Hamiltonian using memoization. ## Arguments -- `clustered_hamiltonian::LabelledGraph{S, T}`: A clustered Hamiltonian represented as a labelled graph. +- `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 clustered Hamiltonian using memoization. +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. """ -@memoize function exact_spectrum(clustered_hamiltonian::LabelledGraph{S,T}) where {S,T} +@memoize function exact_spectrum(potts_hamiltonian::LabelledGraph{S,T}) where {S,T} # TODO: Not going to work without PoolOfProjectors - ver = vertices(clustered_hamiltonian) - rank = cluster_size.(Ref(clustered_hamiltonian), ver) + ver = vertices(potts_hamiltonian) + rank = cluster_size.(Ref(potts_hamiltonian), ver) states = [Dict(ver .=> σ) for σ ∈ Iterators.product([1:r for r ∈ rank]...)] - energy.(Ref(clustered_hamiltonian), states), states + energy.(Ref(potts_hamiltonian), states), states end """ @@ -44,15 +44,15 @@ Calculate the exact marginal probability of a target state within the context of ## 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 clustered 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 clustered Hamiltonian, +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.betas[end]`), normalizes the probabilities, and calculates the marginal probability of the target state. """ function exact_marginal_probability(ctr::MpsContractor{T}, σ::Vector{Int}) where {T} # TODO: Not going to work without PoolOfProjectors target_state = decode_state(ctr.peps, σ, true) - energies, states = exact_spectrum(ctr.peps.clustered_hamiltonian) + energies, states = exact_spectrum(ctr.peps.potts_hamiltonian) prob = exp.(-ctr.betas[end] .* energies) prob ./= sum(prob) sum(prob[findall([all(s[k] == v for (k, v) ∈ target_state) for s ∈ states])]) diff --git a/test/chimera_overlap_python.jl b/test/chimera_overlap_python.jl index 66f821f4..6b031798 100644 --- a/test/chimera_overlap_python.jl +++ b/test/chimera_overlap_python.jl @@ -18,7 +18,7 @@ num_states = 1000 instance = "$(@__DIR__)/instances/chimera_droplets/128power/001.txt" -cl_h = clustered_hamiltonian( +potts_h = potts_hamiltonian( ising_graph(instance), spectrum = full_spectrum, #my_brute_force, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -37,7 +37,7 @@ Gauge = NoUpdate network = PEPSNetwork{SquareSingleNode{GaugesEnergy},Sparsity,Float64}( m, n, - cl_h, + potts_h, rotation(0), ) ctr = MpsContractor{Strategy,Gauge,Float64}( @@ -68,7 +68,7 @@ end net = PEPSNetwork{SquareSingleNode{EnergyGauges},Sparsity,Float64}( m, n, - cl_h, + potts_h, rotation(0), ) ctr = MpsContractor{Strategy,Gauge,Float64}( diff --git a/test/experimental/gauges.jl b/test/experimental/gauges.jl index e96d340e..f8706bb0 100644 --- a/test/experimental/gauges.jl +++ b/test/experimental/gauges.jl @@ -16,7 +16,7 @@ num_states = 1000 instance = "$(@__DIR__)/instances/chimera_droplets/128power/001.txt" -cl_h = clustered_hamiltonian( +potts_h = potts_hamiltonian( ising_graph(instance), max_cl_states, spectrum = full_spectrum, @@ -27,10 +27,10 @@ params = MpsParameters{Float64}(bond_dim, 1E-8, 10) search_params = SearchParameters(num_states, δp) # @testset "Overlaps calculated differently are the same." begin -# for Lattice ∈ (SquareSingleNode, SquareCrossSingleNode) +# for Lattice ∈ (SquareSingleNode, KingSingleNode) # for Sparsity ∈ (Dense, Sparse), transform ∈ all_lattice_transformations[[1]] # for Layout ∈ (GaugesEnergy, EnergyGauges, EngGaugesEng) -# net = PEPSNetwork{Lattice{Layout}, Sparsity}(m, n, cl_h, transform, :id) +# net = PEPSNetwork{Lattice{Layout}, Sparsity}(m, n, potts_h, transform, :id) # ctr_svd = MpsContractor{SVDTruncate, GaugeStrategy}(net, [β/8, β/4, β/2, β], :graduate_truncate, params; onGPU=onGPU) # ctr_anneal = MpsContractor{MPSAnnealing, GaugeStrategy}(net, [β/8, β/4, β/2, β], :graduate_truncate, params; onGPU=onGPU) @@ -48,7 +48,7 @@ search_params = SearchParameters(num_states, δp) # clear_memoize_cache() # for Layout ∈ (GaugesEnergy,) -# net = PEPSNetwork{Lattice{Layout}, Sparsity}(m, n, cl_h, transform, :id) +# net = PEPSNetwork{Lattice{Layout}, Sparsity}(m, n, potts_h, transform, :id) # ctr_svd = MpsContractor{SVDTruncate, GaugeStrategy}(net, [β/8, β/4, β/2, β], :graduate_truncate, params; onGPU=onGPU) # @testset "Overlaps calculated in Python are the same as in Julia." begin # indβ = [4, ] @@ -71,13 +71,13 @@ search_params = SearchParameters(num_states, δp) for Strategy ∈ (SVDTruncate, MPSAnnealing), Sparsity ∈ (Dense, Sparse) for Layout ∈ (GaugesEnergy,) for Gauge ∈ (GaugeStrategy,) - for Lattice ∈ (SquareSingleNode, SquareCrossSingleNode), + for Lattice ∈ (SquareSingleNode, KingSingleNode), transform ∈ all_lattice_transformations net = PEPSNetwork{Lattice{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, :id, ) diff --git a/test/experimental/gauges_cuda.jl b/test/experimental/gauges_cuda.jl index 8641ab34..afcf6544 100644 --- a/test/experimental/gauges_cuda.jl +++ b/test/experimental/gauges_cuda.jl @@ -18,7 +18,7 @@ end δp = 1E-5 * exp(-β * DE) ig = ising_graph("$(@__DIR__)/../instances/pegasus_random/minimal.txt") INDβ = [1, 2, 3] - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = my_brute_force, cluster_assignment_rule = pegasus_lattice((m, n, t)), @@ -37,7 +37,7 @@ end net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( @@ -51,10 +51,10 @@ end sol, s = low_energy_spectrum(ctr, search_params) #sol = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ energy.(Ref(ig), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) # println( maximum(abs.(norm_prob ./ exp.(-β .* (sol.energies .- sol.energies[1]))) .- 1 )) diff --git a/test/experimental/mpo_size.jl b/test/experimental/mpo_size.jl index a9b288c7..f865d767 100644 --- a/test/experimental/mpo_size.jl +++ b/test/experimental/mpo_size.jl @@ -49,20 +49,20 @@ for cl_states in cluster_states println("====================") println("cluster states: ", cl_states) - # cl_h = clustered_hamiltonian( + # potts_h = potts_hamiltonian( # ig, # cl_states, # spectrum=my_brute_force, #rm _gpu to use CPU # cluster_assignment_rule=pegasus_lattice((m, n, t)) # ) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, #rm _gpu to use CPU cluster_assignment_rule = pegasus_lattice((m, n, t)), ) - cl_h = truncate_clustered_hamiltonian_2site_energy(cl_h, cl_states) + potts_h = truncate_potts_hamiltonian_2site_energy(potts_h, cl_states) params = MpsParameters{Float64}( Dcut, @@ -84,7 +84,7 @@ for cl_states in cluster_states i = div(m, 2) indβ = 1 - net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparse,Float64}(m, n, cl_h, tran) + net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparse,Float64}(m, n, potts_h, tran) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; diff --git a/test/experimental/sampling.jl b/test/experimental/sampling.jl index 55fb78b2..f3bdc80d 100644 --- a/test/experimental/sampling.jl +++ b/test/experimental/sampling.jl @@ -19,7 +19,7 @@ bond_dim = 2 num_states = 7 #22 ig = ising_graph("$(@__DIR__)/../instances/square_gauss/S12/001.txt") -cl_h = clustered_hamiltonian( +potts_h = potts_hamiltonian( ig, spectrum = my_brute_force, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -35,7 +35,7 @@ Layout = EnergyGauges Lattice = SquareSingleNode transform = rotation(0) -net = PEPSNetwork{Lattice{Layout},Sparsity,Float64}(m, n, cl_h, transform) +net = PEPSNetwork{Lattice{Layout},Sparsity,Float64}(m, n, potts_h, transform) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; diff --git a/test/experimental/search_chimera_gauge.jl b/test/experimental/search_chimera_gauge.jl index de8e9929..74ee0d2a 100644 --- a/test/experimental/search_chimera_gauge.jl +++ b/test/experimental/search_chimera_gauge.jl @@ -14,7 +14,7 @@ instance = "$(@__DIR__)/instances/chimera_droplets/512power/001.txt" INDβ = [1, 2, 3] ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -31,7 +31,7 @@ net = PEPSNetwork{SquareSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( @@ -45,10 +45,10 @@ sol, s = low_energy_spectrum(ctr, search_params) #sol = low_energy_spectrum(ctr, search_params, merge_branches(ctr)) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ energy.(Ref(ig), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) # println( maximum(abs.(norm_prob ./ exp.(-β .* (sol.energies .- sol.energies[1]))) .- 1 )) diff --git a/test/experimental/squarestar_double_node_pegasus.jl b/test/experimental/squarestar_double_node_pegasus.jl index 3c110c92..0d579d08 100644 --- a/test/experimental/squarestar_double_node_pegasus.jl +++ b/test/experimental/squarestar_double_node_pegasus.jl @@ -4,7 +4,7 @@ function my_brute_force(ig::IsingGraph; num_states::Int) brute_force(ig, onGPU ? :GPU : :CPU, num_states = num_states) end -function check_ground_state(cl_h) +function check_ground_state(potts_h) ground_state = [ 982, 751, @@ -244,9 +244,9 @@ function check_ground_state(cl_h) 65 => -1, ) decoded_states = zeros(18) - for (i, node) in enumerate(vertices(cl_h)) - node_states = get_prop(cl_h, node, :spectrum).states - spins = get_prop(cl_h, node, :cluster).labels + for (i, node) in enumerate(vertices(potts_h)) + node_states = get_prop(potts_h, node, :spectrum).states + spins = get_prop(potts_h, node, :cluster).labels decoded_from_ig = [gs[key] for key in spins] if decoded_from_ig in node_states @@ -284,13 +284,13 @@ if !Base.Filesystem.isdir(results_folder) Base.Filesystem.mkpath(results_folder) end -cl_h = clustered_hamiltonian( +potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, #rm _gpu to use CPU cluster_assignment_rule = pegasus_lattice((m, n, t)), ) -cl_h = truncate_clustered_hamiltonian( - cl_h, +potts_h = truncate_potts_hamiltonian( + potts_h, β, cs, results_folder, @@ -298,7 +298,7 @@ cl_h = truncate_clustered_hamiltonian( tol = 1e-6, iter = iter, ) -check_ground_state(cl_h) +check_ground_state(potts_h) params = MpsParameters{Float64}(bond_dim, VAR_TOL, MS, TOL_SVD, ITERS_SVD, ITERS_VAR, DTEMP_MULT) search_params = SearchParameters(num_states, δp) @@ -309,7 +309,7 @@ Layout = GaugesEnergy Gauge = NoUpdate for tran ∈ all_lattice_transformations #[LatticeTransformation((1, 2, 3, 4), false), ] - net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}(m, n, cl_h, tran) + net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}(m, n, potts_h, tran) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; @@ -328,7 +328,7 @@ for tran ∈ all_lattice_transformations #[LatticeTransformation((1, 2, 3, 4), f ) println(sol.energies) # println(sol.states) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) # println(ig_states) clear_memoize_cache() end diff --git a/test/experimental/squarestar_double_node_zephyr.jl b/test/experimental/squarestar_double_node_zephyr.jl index aab12d7e..77a47098 100644 --- a/test/experimental/squarestar_double_node_zephyr.jl +++ b/test/experimental/squarestar_double_node_zephyr.jl @@ -18,14 +18,14 @@ cs = 2^10 ig = ising_graph("$(@__DIR__)/../instances/zephyr_random/Z3/RAU/SpinGlass/001_sg.txt") results_folder = "$(@__DIR__)/../instances/zephyr_random/Z3/RAU/SpinGlass/BP" inst = "001" -cl_h = clustered_hamiltonian( +potts_h = potts_hamiltonian( ig, # max_cl_states, spectrum = full_spectrum, #brute_force_gpu, # rm _gpu to use CPU cluster_assignment_rule = zephyr_lattice((m, n, t)), ) -@time cl_h = truncate_clustered_hamiltonian( - cl_h, +@time potts_h = truncate_potts_hamiltonian( + potts_h, β, cs, results_folder, @@ -45,7 +45,7 @@ tran = LatticeTransformation((4, 1, 2, 3), true) Layout = GaugesEnergy Gauge = NoUpdate -net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}(m, n, cl_h, tran) +net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}(m, n, potts_h, tran) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; diff --git a/test/experimental/truncate.jl b/test/experimental/truncate.jl index ff1c9e17..68518b73 100644 --- a/test/experimental/truncate.jl +++ b/test/experimental/truncate.jl @@ -57,16 +57,16 @@ for cs ∈ cl_states println("===============") println("Transform ", tran) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, #rm _gpu to use CPU cluster_assignment_rule = pegasus_lattice((m, n, t)), ) println("Truncate iter ", iter) - #@time cl_h = truncate_clustered_hamiltonian_2site_energy(cl_h, cs) - @time cl_h = truncate_clustered_hamiltonian( - cl_h, + #@time potts_h = truncate_potts_hamiltonian_2site_energy(potts_h, cs) + @time potts_h = truncate_potts_hamiltonian( + potts_h, β, cs, results_folder, @@ -74,11 +74,11 @@ for cs ∈ cl_states tol = 1e-6, iter = iter, ) - for v ∈ vertices(cl_h) - println(v, " -> ", length(get_prop(cl_h, v, :spectrum).energies)) + for v ∈ vertices(potts_h) + println(v, " -> ", length(get_prop(potts_h, v, :spectrum).energies)) end - net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparse}(m, n, cl_h, tran) + net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparse}(m, n, potts_h, tran) ctr = MpsContractor{Strategy,Gauge}( net, params; diff --git a/test/experimental/truncate_small.jl b/test/experimental/truncate_small.jl index f48d984e..ead4b2ce 100644 --- a/test/experimental/truncate_small.jl +++ b/test/experimental/truncate_small.jl @@ -68,17 +68,17 @@ function run_test(instance, m, n, t) println("===============") println("Transform ", tran) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, #_gpu, # rm _gpu to use CPU cluster_assignment_rule = pegasus_lattice((m, n, t)), ) - cl_h = truncate_clustered_hamiltonian_2site_energy(cl_h, cl) + potts_h = truncate_potts_hamiltonian_2site_energy(potts_h, cl) net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, tran, ) diff --git a/test/experimental/zipper.jl b/test/experimental/zipper.jl index 4df3ba47..fcdf1efc 100644 --- a/test/experimental/zipper.jl +++ b/test/experimental/zipper.jl @@ -34,7 +34,7 @@ indβ = 1 ig = ising_graph("$(@__DIR__)/../instances/chimera_droplets/512power/001.txt") -cl_h = clustered_hamiltonian( +potts_h = potts_hamiltonian( ig, spectrum = my_brute_force, #rm _gpu to use CPU cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -50,7 +50,7 @@ Gauge = NoUpdate i = div(m, 2) indβ = 1 -net = PEPSNetwork{SquareSingleNode{Layout},Sparse,Float64}(m, n, cl_h, tran) +net = PEPSNetwork{SquareSingleNode{Layout},Sparse,Float64}(m, n, potts_h, tran) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; @@ -61,7 +61,7 @@ ctr = MpsContractor{Strategy,Gauge,Float64}( Ws = SpinGlassEngine.mpo(ctr, ctr.layers.main, i, indβ) println(" Ws -> ", which_device(Ws), " ", format_bytes.(measure_memory(Ws))) -net = PEPSNetwork{SquareSingleNode{Layout},Dense,Float64}(m, n, cl_h, tran) +net = PEPSNetwork{SquareSingleNode{Layout},Dense,Float64}(m, n, potts_h, tran) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; diff --git a/test/mwe.jl b/test/mwe.jl index 7b9dcc1d..2e1c0a13 100644 --- a/test/mwe.jl +++ b/test/mwe.jl @@ -22,7 +22,7 @@ Layout = GaugesEnergy onGPU = true transform = all_lattice_transformations[1] ig = ising_graph(instance) -cl_h = clustered_hamiltonian( +potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = pegasus_lattice((m, n, t)), @@ -45,7 +45,7 @@ for T in [Float64, Float32] ) search_params = SearchParameters(mstates, δp) - net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,T}(m, n, cl_h, transform) + net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,T}(m, n, potts_h, transform) ctr = MpsContractor{Strategy,Gauge,T}( net, params; diff --git a/test/random_markov_field.jl b/test/random_markov_field.jl index 3577b6b2..d07861ff 100644 --- a/test/random_markov_field.jl +++ b/test/random_markov_field.jl @@ -5,8 +5,8 @@ bond_dim = 8 δp = 1E-4 num_states = 64 - cl_h = clustered_hamiltonian(instance_dir) - Nx, Ny = get_prop(cl_h, :Nx), get_prop(cl_h, :Ny) + potts_h = potts_hamiltonian(instance_dir) + Nx, Ny = get_prop(potts_h, :Nx), get_prop(potts_h, :Ny) params = MpsParameters{Float64}(; bd = bond_dim, ϵ = 1E-8, sw = 4) search_params = SearchParameters(; max_states = num_states, cut_off_prob = δp) Gauge = NoUpdate @@ -16,7 +16,7 @@ Layout = GaugesEnergy Sparsity = Sparse transform = rotation(0) - net = PEPSNetwork{SquareCrossSingleNode{Layout},Sparsity}(Nx, Ny, cl_h, transform) + net = PEPSNetwork{KingSingleNode{Layout},Sparsity}(Nx, Ny, potts_h, transform) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; diff --git a/test/search_chimera_droplets.jl b/test/search_chimera_droplets.jl index b940a35d..c86033fb 100644 --- a/test/search_chimera_droplets.jl +++ b/test/search_chimera_droplets.jl @@ -18,7 +18,7 @@ function bench(instance::String) num_states = 500 all_betas = [β / 8, β / 4, β / 2, β] - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ising_graph(instance), max_cl_states, spectrum = my_brute_force, @@ -34,7 +34,7 @@ function bench(instance::String) net = PEPSNetwork{SquareSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( @@ -61,12 +61,12 @@ function bench(instance::String) push!(energies, sol1.energies) for sol ∈ (sol1, sol2) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ SpinGlassNetworks.energy.(Ref(ising_graph(instance)), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ SpinGlassNetworks.energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ SpinGlassNetworks.energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) @test norm_prob ≈ exp.(-β .* (sol.energies .- sol.energies[1])) diff --git a/test/search_chimera_full.jl b/test/search_chimera_full.jl index 60a97ca9..40733607 100644 --- a/test/search_chimera_full.jl +++ b/test/search_chimera_full.jl @@ -17,7 +17,7 @@ function bench(instance::String) num_states = 500 all_betas = [β / 8, β / 4, β / 2, β] - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ising_graph(instance), max_cl_states, spectrum = full_spectrum, @@ -34,7 +34,7 @@ function bench(instance::String) net = PEPSNetwork{SquareSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( diff --git a/test/search_chimera_pathological.jl b/test/search_chimera_pathological.jl index a09e1536..21381225 100644 --- a/test/search_chimera_pathological.jl +++ b/test/search_chimera_pathological.jl @@ -7,7 +7,7 @@ transform = $transform " for Sparsity ∈ (Dense, Sparse), Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng), - Lattice ∈ (SquareSingleNode, SquareCrossSingleNode), + Lattice ∈ (SquareSingleNode, KingSingleNode), transform ∈ all_lattice_transformations m, n, t = 3, 4, 3 @@ -42,7 +42,7 @@ transform = $transform -15.4, ] - # degenerate cl_h solutions + # degenerate potts_h solutions exact_states = [ # E =-16.4 [ [1, 4, 5, 1, 2, 2, 1, 1, 1, 4, 2, 1], @@ -109,7 +109,7 @@ transform = $transform ) ig = ising_graph("$(@__DIR__)/instances/pathological/chim_$(m)_$(n)_$(t).txt") - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -121,7 +121,7 @@ transform = $transform energies = Vector{Float64}[] - net = PEPSNetwork{Lattice{Layout},Sparsity,Float64}(m, n, cl_h, transform) + net = PEPSNetwork{Lattice{Layout},Sparsity,Float64}(m, n, potts_h, transform) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; @@ -133,11 +133,11 @@ transform = $transform @test sol.energies ≈ exact_energies - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ energy.(Ref(ig), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) for (i, σ) ∈ enumerate(sol.states) @test σ ∈ exact_states[deg[i]] diff --git a/test/search_chimera_pathological_Z2.jl b/test/search_chimera_pathological_Z2.jl index 7f043e17..fc290780 100644 --- a/test/search_chimera_pathological_Z2.jl +++ b/test/search_chimera_pathological_Z2.jl @@ -31,7 +31,7 @@ -15.4, ] - # degenerate cl_h solutions + # degenerate potts_h solutions exact_states = [ # E =-16.4 [ [1, 4, 5, 1, 2, 2, 1, 1, 1, 4, 2, 1], @@ -98,7 +98,7 @@ ) ig = ising_graph("$(@__DIR__)/instances/pathological/chim_$(m)_$(n)_$(t)_Z2.txt") - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -110,13 +110,13 @@ energies = Vector{Float64}[] for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), Sparsity ∈ (Dense, Sparse) for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng) - for Lattice ∈ (SquareSingleNode, SquareCrossSingleNode), + for Lattice ∈ (SquareSingleNode, KingSingleNode), transform ∈ all_lattice_transformations net = PEPSNetwork{SquareSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( @@ -139,11 +139,11 @@ sol2 = unpack_droplets(sol1, β) for sol ∈ (sol1, sol2) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ energy.(Ref(ig), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) @test norm_prob ≈ exp.(-β .* (sol.energies .- sol.energies[1])) diff --git a/test/search_chimera_pathological_droplets.jl b/test/search_chimera_pathological_droplets.jl index 34c29754..c379375f 100644 --- a/test/search_chimera_pathological_droplets.jl +++ b/test/search_chimera_pathological_droplets.jl @@ -32,7 +32,7 @@ -15.4, ] - # degenerate cl_h solutions + # degenerate potts_h solutions exact_states = [ # E =-16.4 [ [1, 4, 5, 1, 2, 2, 1, 1, 1, 4, 2, 1], @@ -99,7 +99,7 @@ ) ig = ising_graph("$(@__DIR__)/instances/pathological/chim_$(m)_$(n)_$(t).txt") - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -111,7 +111,7 @@ energies = Vector{Float64}[] # for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), Sparsity ∈ (Dense, Sparse) # for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng) - # for Lattice ∈ (SquareSingleNode, SquareCrossSingleNode), transform ∈ all_lattice_transformations + # for Lattice ∈ (SquareSingleNode, KingSingleNode), transform ∈ all_lattice_transformations for Strategy ∈ (Zipper,), Sparsity ∈ (Dense,) for Layout ∈ (EnergyGauges,) for transform ∈ all_lattice_transformations @@ -119,7 +119,7 @@ net = PEPSNetwork{SquareSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( @@ -147,11 +147,11 @@ @test sol2.energies[1:length(exact_energies)] ≈ exact_energies for sol ∈ (sol1, sol2) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ energy.(Ref(ig), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) @test norm_prob ≈ exp.(-β .* (sol.energies .- sol.energies[1])) diff --git a/test/search_chimera_pathological_hamming.jl b/test/search_chimera_pathological_hamming.jl index a6776e85..7bee9ee9 100644 --- a/test/search_chimera_pathological_hamming.jl +++ b/test/search_chimera_pathological_hamming.jl @@ -44,7 +44,7 @@ end -15.4, ] - # degenerate cl_h solutions + # degenerate potts_h solutions exact_states = [ # E =-16.4 [ [1, 4, 5, 1, 2, 2, 1, 1, 1, 4, 2, 1], @@ -111,7 +111,7 @@ end ) ig = ising_graph("$(@__DIR__)/instances/pathological/chim_$(m)_$(n)_$(t).txt") - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -124,13 +124,13 @@ end energies = Vector{Float64}[] for Strategy ∈ (SVDTruncate,), Sparsity ∈ (Sparse,) for Layout ∈ (EnergyGauges,) - for Lattice ∈ (SquareCrossSingleNode,), + for Lattice ∈ (KingSingleNode,), transform ∈ all_lattice_transformations[[1]] net = PEPSNetwork{SquareSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( @@ -152,7 +152,7 @@ end ) @test sol1.energies ≈ [exact_energies[1]] sol2 = unpack_droplets(sol1, β) - (dict1, dict2) = decode_clustered_hamiltonian_state.(Ref(cl_h), sol2.states) + (dict1, dict2) = decode_potts_hamiltonian_state.(Ref(potts_h), sol2.states) @test hamming_distance( sol1.droplets[1][1].flip, Flip([], [], [], []), diff --git a/test/search_chimera_smallest.jl b/test/search_chimera_smallest.jl index a77ebbb9..ed266a82 100644 --- a/test/search_chimera_smallest.jl +++ b/test/search_chimera_smallest.jl @@ -10,7 +10,7 @@ instance = "$(@__DIR__)/instances/pathological/chim_$(n)_$(m)_$(t).txt" ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -26,7 +26,7 @@ Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng), transform ∈ all_lattice_transformations - net = PEPSNetwork{SquareSingleNode{Layout},Sparsity,T}(m, n, cl_h, transform) + net = PEPSNetwork{SquareSingleNode{Layout},Sparsity,T}(m, n, potts_h, transform) ctr = MpsContractor{Strategy,Gauge,T}( net, params; @@ -38,10 +38,10 @@ @test eltype(sol.energies) == T @test sol.energies ≈ exact_energies - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ energy.(Ref(ig), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) @test isapprox( diff --git a/test/search_chimera_smallest_droplets.jl b/test/search_chimera_smallest_droplets.jl index 11ca746c..a7af33e8 100644 --- a/test/search_chimera_smallest_droplets.jl +++ b/test/search_chimera_smallest_droplets.jl @@ -10,7 +10,7 @@ instance = "$(@__DIR__)/instances/pathological/chim_$(n)_$(m)_$(t).txt" ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -27,7 +27,7 @@ net = PEPSNetwork{SquareSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( @@ -53,11 +53,11 @@ @test sol2.energies ≈ exact_energies[1:5] for sol ∈ (sol1, sol2) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ energy.(Ref(ig), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) @test norm_prob ≈ exp.(-β .* (sol.energies .- sol.energies[1])) diff --git a/test/search_cross_square_star.jl b/test/search_cross_square_star.jl index 0e9cee21..6b283ec6 100644 --- a/test/search_cross_square_star.jl +++ b/test/search_cross_square_star.jl @@ -10,7 +10,7 @@ instance = "$(@__DIR__)/instances/pathological/cross_$(m)_$(n)_mdd.txt" ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -22,8 +22,8 @@ energies = Vector{Float64}[] for Strategy ∈ (MPSAnnealing, Zipper, SVDTruncate), Sparsity ∈ (Dense, Sparse) for Layout ∈ (GaugesEnergy, EngGaugesEng, EnergyGauges) # - for transform ∈ all_lattice_transformations, Lattice ∈ (SquareCrossSingleNode,) - net = PEPSNetwork{Lattice{Layout},Sparsity,Float64}(m, n, cl_h, transform) + for transform ∈ all_lattice_transformations, Lattice ∈ (KingSingleNode,) + net = PEPSNetwork{Lattice{Layout},Sparsity,Float64}(m, n, potts_h, transform) ctr = MpsContractor{Strategy,Gauge,Float64}( net, params; @@ -33,11 +33,11 @@ ) sol, s = low_energy_spectrum(ctr, search_params) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ energy.(Ref(ig), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) @test norm_prob ≈ exp.(-β .* (sol.energies .- sol.energies[1])) diff --git a/test/search_pegasus_droplets.jl b/test/search_pegasus_droplets.jl index 2f57eb8c..415d8477 100644 --- a/test/search_pegasus_droplets.jl +++ b/test/search_pegasus_droplets.jl @@ -18,7 +18,7 @@ function bench(instance::String) num_states = 500 all_betas = [β / 8, β / 4, β / 2, β] - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ising_graph(instance), # max_cl_states, spectrum = my_brute_force, @@ -34,7 +34,7 @@ function bench(instance::String) net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( @@ -55,19 +55,19 @@ function bench(instance::String) ) sol2 = unpack_droplets(sol1, β) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol2.states) - # cl_h_states = decode_state.(Ref(net), sol2.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol2.states) + # potts_h_states = decode_state.(Ref(net), sol2.states) # @test sol1.energies[begin] ≈ ground_energy # @test sol2.energies[begin] ≈ ground_energy # push!(energies, sol1.energies) # for sol ∈ (sol1, sol2) - # ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + # ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) # @test sol.energies ≈ energy.(Ref(ising_graph(instance)), ig_states) - # cl_h_states = decode_state.(Ref(net), sol.states) - # @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + # potts_h_states = decode_state.(Ref(net), sol.states) + # @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) # norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) # @test norm_prob ≈ exp.(-β .* (sol.energies .- sol.energies[1])) diff --git a/test/search_pegasus_nodiag_square_cross.jl b/test/search_pegasus_nodiag_square_cross.jl index e525b9b1..36bb3f62 100644 --- a/test/search_pegasus_nodiag_square_cross.jl +++ b/test/search_pegasus_nodiag_square_cross.jl @@ -13,7 +13,7 @@ function bench(instance::String) num_states = 1000 ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, max_cl_states, spectrum = my_brute_force, @@ -28,10 +28,10 @@ function bench(instance::String) transform ∈ all_lattice_transformations for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng), Sparsity ∈ (Dense,) - net = PEPSNetwork{SquareCrossSingleNode{Layout},Sparsity,Float64}( + net = PEPSNetwork{KingSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,NoUpdate,Float64}( diff --git a/test/search_pegasus_square_cross.jl b/test/search_pegasus_square_cross.jl index 798ec032..b32b6888 100644 --- a/test/search_pegasus_square_cross.jl +++ b/test/search_pegasus_square_cross.jl @@ -11,7 +11,7 @@ function bench(instance::String) num_states = 20 ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, max_cl_states, spectrum = my_brute_force, @@ -28,10 +28,10 @@ function bench(instance::String) transform ∈ all_lattice_transformations for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng), Sparsity ∈ (Dense,) - net = PEPSNetwork{SquareCrossSingleNode{Layout},Sparsity,Float64}( + net = PEPSNetwork{KingSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,Gauge,Float64}( diff --git a/test/search_smallest_cross_square_cross.jl b/test/search_smallest_cross_square_cross.jl index 330a0c01..57c1bce8 100644 --- a/test/search_smallest_cross_square_cross.jl +++ b/test/search_smallest_cross_square_cross.jl @@ -10,7 +10,7 @@ instance = "$(@__DIR__)/instances/pathological/cross_3_2.txt" ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -21,10 +21,10 @@ for Strategy ∈ (SVDTruncate, MPSAnnealing, Zipper), Sparsity ∈ (Dense, Sparse) for Layout ∈ (EnergyGauges, GaugesEnergy, EngGaugesEng) for transform ∈ all_lattice_transformations - net = PEPSNetwork{SquareCrossSingleNode{Layout},Sparsity,Float64}( + net = PEPSNetwork{KingSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, transform, ) ctr = MpsContractor{Strategy,NoUpdate,Float64}( @@ -36,11 +36,11 @@ ) sol, s = low_energy_spectrum(ctr, search_params) - ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) @test sol.energies ≈ energy.(Ref(ig), ig_states) - cl_h_states = decode_state.(Ref(net), sol.states) - @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + potts_h_states = decode_state.(Ref(net), sol.states) + @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) norm_prob = exp.(sol.probabilities .- sol.probabilities[1]) @test norm_prob ≈ exp.(-β .* (sol.energies .- sol.energies[1])) diff --git a/test/search_square_double_node_basic.jl b/test/search_square_double_node_basic.jl index a6d0018a..e4083a89 100644 --- a/test/search_square_double_node_basic.jl +++ b/test/search_square_double_node_basic.jl @@ -9,12 +9,12 @@ function run_test_square_double_node(instance, m, n, t) ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, #_gpu, # rm _gpu to use CPU cluster_assignment_rule = pegasus_lattice((m, n, t)), ) - cl_h2 = clustered_hamiltonian( + potts_h2 = potts_hamiltonian( ig, spectrum = full_spectrum, #_gpu, # rm _gpu to use CPU cluster_assignment_rule = super_square_lattice((m, n, 8)), @@ -30,11 +30,11 @@ function run_test_square_double_node(instance, m, n, t) for tran ∈ all_lattice_transformations net = - PEPSNetwork{SquareDoubleNode{Layout},Sparsity,Float64}(m, n, cl_h, tran) + PEPSNetwork{SquareDoubleNode{Layout},Sparsity,Float64}(m, n, potts_h, tran) net2 = PEPSNetwork{SquareSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h2, + potts_h2, tran, ) @@ -56,10 +56,10 @@ function run_test_square_double_node(instance, m, n, t) sol, s = low_energy_spectrum(ctr, search_params) #, merge_branches(ctr)) sol2, s = low_energy_spectrum(ctr2, search_params) # , merge_branches(ctr2)) - # ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + # ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) # @test sol.energies ≈ energy.(Ref(ig), ig_states) - # cl_h_states = decode_state.(Ref(net), sol.states) - # @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + # potts_h_states = decode_state.(Ref(net), sol.states) + # @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) #@test sol.energies ≈ sol2.energies @test sol.energies[1:div(num_states, 8)] ≈ diff --git a/test/search_square_lattice.jl b/test/search_square_lattice.jl index b6528e89..f1efcdf6 100644 --- a/test/search_square_lattice.jl +++ b/test/search_square_lattice.jl @@ -10,7 +10,7 @@ function bench(instance::String) num_states = 20 ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, cluster_assignment_rule = super_square_lattice((m, n, t)), @@ -24,7 +24,7 @@ function bench(instance::String) transform ∈ all_lattice_transformations for Layout ∈ (GaugesEnergy, EnergyGauges, EngGaugesEng), Sparsity ∈ (Dense, Sparse) - net = PEPSNetwork{SquareCrossSingleNode{Layout},Sparsity}(m, n, cl_h, transform) + net = PEPSNetwork{KingSingleNode{Layout},Sparsity}(m, n, potts_h, transform) ctr = MpsContractor{Strategy,Gauge}( net, params; diff --git a/test/search_squarecross_double_node_basic.jl b/test/search_squarecross_double_node_basic.jl index eb4eb1f5..efef11f0 100644 --- a/test/search_squarecross_double_node_basic.jl +++ b/test/search_squarecross_double_node_basic.jl @@ -9,12 +9,12 @@ function run_test_squarecross_double_node(instance, m, n, t) ig = ising_graph(instance) - cl_h = clustered_hamiltonian( + potts_h = potts_hamiltonian( ig, spectrum = full_spectrum, #_gpu, # rm _gpu to use CPU cluster_assignment_rule = pegasus_lattice((m, n, t)), ) - cl_h2 = clustered_hamiltonian( + potts_h2 = potts_hamiltonian( ig, spectrum = full_spectrum, #_gpu, # rm _gpu to use CPU cluster_assignment_rule = super_square_lattice((m, n, 8)), @@ -33,13 +33,13 @@ function run_test_squarecross_double_node(instance, m, n, t) net = PEPSNetwork{SquareCrossDoubleNode{Layout},Sparsity,Float64}( m, n, - cl_h, + potts_h, tran, ) - net2 = PEPSNetwork{SquareCrossSingleNode{Layout},Sparsity,Float64}( + net2 = PEPSNetwork{KingSingleNode{Layout},Sparsity,Float64}( m, n, - cl_h2, + potts_h2, tran, ) @@ -61,10 +61,10 @@ function run_test_squarecross_double_node(instance, m, n, t) sol, s = low_energy_spectrum(ctr, search_params) #, merge_branches(ctr)) sol2, s = low_energy_spectrum(ctr2, search_params) #, merge_branches(ctr2)) - # ig_states = decode_clustered_hamiltonian_state.(Ref(cl_h), sol.states) + # ig_states = decode_potts_hamiltonian_state.(Ref(potts_h), sol.states) # @test sol.energies ≈ energy.(Ref(ig), ig_states) - # cl_h_states = decode_state.(Ref(net), sol.states) - # @test sol.energies ≈ energy.(Ref(cl_h), cl_h_states) + # potts_h_states = decode_state.(Ref(net), sol.states) + # @test sol.energies ≈ energy.(Ref(potts_h), potts_h_states) @test sol.energies[1:div(num_states, 2)] ≈ sol2.energies[1:div(num_states, 2)]