Skip to content

Commit

Permalink
rename cl_h to potts_h
Browse files Browse the repository at this point in the history
  • Loading branch information
annamariadziubyna committed Jul 26, 2024
1 parent 5245ece commit e153279
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 294 deletions.
2 changes: 1 addition & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interaction_energy
get_neighbors
MergedEnergy
update_message
merge_vertices_cl_h
merge_vertices_potts_h
projector
SparseCSC
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/clh.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ instance = "$(@__DIR__)/../../src/instances/square_diagonal/5x5/diagonal.txt"
ig = ising_graph(instance)
# Create Potts Hamiltonian
cl_h = potts_hamiltonian(
potts_h = potts_hamiltonian(
ig,
cluster_assignment_rule = super_square_lattice((5,5,4))
)
Expand Down
10 changes: 5 additions & 5 deletions docs/src/lattice.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ m = 5
n = 5
t = 4
cl_h = potts_hamiltonian(
potts_h = potts_hamiltonian(
ig,
cluster_assignment_rule = super_square_lattice((m, n, t))
)
println("Number of nodes in oryginal instance: ", length(LabelledGraphs.vertices(ig)), "\n", " Number of nodes in Potts Hamiltonian: ", length(LabelledGraphs.vertices(cl_h)))
println("Number of nodes in oryginal instance: ", length(LabelledGraphs.vertices(ig)), "\n", " Number of nodes in Potts Hamiltonian: ", length(LabelledGraphs.vertices(potts_h)))
```

## Pegasus graphs
Expand Down Expand Up @@ -61,12 +61,12 @@ m = 3
n = 3
t = 3
cl_h = potts_hamiltonian(
potts_h = potts_hamiltonian(
ig,
cluster_assignment_rule = pegasus_lattice((m, n, t))
)
println("Number of nodes in original instance: ", length(LabelledGraphs.vertices(ig)), "\n", " Number of nodes in Potts Hamiltonian: ", length(LabelledGraphs.vertices(cl_h))/2)
println("Number of nodes in original instance: ", length(LabelledGraphs.vertices(ig)), "\n", " Number of nodes in Potts Hamiltonian: ", length(LabelledGraphs.vertices(potts_h))/2)
```


Expand Down Expand Up @@ -96,7 +96,7 @@ m = 6
n = 6
t = 4
cl_h = potts_hamiltonian(
potts_h = potts_hamiltonian(
ig,
cluster_assignment_rule = zephyr_lattice((m, n, t))
)
Expand Down
12 changes: 6 additions & 6 deletions examples/bp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ function create_larger_example_potts_hamiltonian_tree()
9 => (3, 3, 1),
)

cl_h = potts_hamiltonian(
potts_h = potts_hamiltonian(
ig,
Dict{NTuple{3,Int},Int}(),
spectrum = full_spectrum,
cluster_assignment_rule = assignment_rule,
)

ig, cl_h
ig, potts_h
end

ig, cl_h = create_larger_example_potts_hamiltonian_tree()
ig, potts_h = create_larger_example_potts_hamiltonian_tree()
beta = 0.1
iter = 0
beliefs = belief_propagation(cl_h, beta; iter = iter)
beliefs = belief_propagation(potts_h, beta; iter = iter)

for v in vertices(cl_h)
en = get_prop(cl_h, v, :spectrum).energies
for v in vertices(potts_h)
en = get_prop(potts_h, v, :spectrum).energies
println("vertex ", v, " energy = ", en .- minimum(en), " bp = ", beliefs[v])
end
14 changes: 7 additions & 7 deletions examples/temp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,27 @@ function potts_hamiltonian(fname::String, Nx::Integer = 240, Ny::Integer = 320)
N = loaded_rmf["N"]

clusters = super_square_lattice((Nx, Ny, 1))
cl_h = LabelledGraph{MetaDiGraph}(sort(collect(values(clusters))))
for v cl_h.labels
potts_h = LabelledGraph{MetaDiGraph}(sort(collect(values(clusters))))
for v potts_h.labels
x, y = v
sp = Spectrum(
Vector{Real}(undef, 1),
Array{Vector{Int}}(undef, 1, 1),
Vector{Int}(undef, 1),
)
set_props!(cl_h, v, Dict(:cluster => v, :spectrum => sp))
set_props!(potts_h, v, Dict(:cluster => v, :spectrum => sp))
end
for (index, value) in factors
if length(index) == 2
y, x = index
Eng = sum(functions[value])
set_props!(cl_h, (x + 1, y + 1), Dict(:eng => Eng))
set_props!(potts_h, (x + 1, y + 1), Dict(:eng => Eng))
elseif length(index) == 4
y1, x1, y2, x2 = index
add_edge!(cl_h, (x1 + 1, y1 + 1), (x2 + 1, y2 + 1))
add_edge!(potts_h, (x1 + 1, y1 + 1), (x2 + 1, y2 + 1))
Eng = sum(functions[value], dims = 2)
set_props!(
cl_h,
potts_h,
(x1 + 1, y1 + 1),
(x2 + 1, y2 + 1),
Dict(
Expand All @@ -127,7 +127,7 @@ function potts_hamiltonian(fname::String, Nx::Integer = 240, Ny::Integer = 320)
end
end

cl_h
potts_h
end


Expand Down
Loading

0 comments on commit e153279

Please sign in to comment.