Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added first example and required instance #86

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions examples/instances/3x3x2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
1 2 -0.5320600854590267
3 4 0.38402265869664154
3 1 -0.5436924524983267
3 2 0.21977738991479145
4 1 -0.5628699912291399
4 2 0.7923812769160723
5 6 0.38332124497444475
5 3 -0.2766447992621366
5 4 0.43076811014522653
6 3 0.08210571803994982
6 4 -0.9915874978177643
7 8 0.6014253456011047
7 1 0.37763583164851355
7 2 -0.26590744578208203
8 1 0.9690946973530548
8 2 -0.67694551766651
9 10 -0.14153430905690412
9 3 0.16759090162116919
9 4 -0.8174998097136141
10 3 -0.40403760194281046
10 4 -0.6356483089131602
9 7 0.04392506131183804
9 8 0.9829874976922899
10 7 -0.35689548049316144
10 8 -0.1672648223095825
9 1 -0.5786261566035802
9 2 -0.34406623378116596
10 1 0.100481750570526
10 2 0.8038842162474464
11 12 -0.8956911493893849
11 5 -0.8630057217020062
11 6 0.6306623988860585
12 5 0.7504141436046725
12 6 -0.9352371863606841
11 9 -0.6803222587957678
11 10 0.689782704271011
12 9 0.7752150591589735
12 10 -0.8343312141855883
11 3 -0.5559557250718317
11 4 0.17582966006044876
12 3 0.19181763419530173
12 4 0.27431075715253805
13 14 0.7478095997218
13 7 -0.4883614012946449
13 8 0.9576256441396791
14 7 -0.28912688765567185
14 8 0.1089802463072973
15 16 0.38262916472610375
15 9 -0.3873909056772129
15 10 -0.25725344989877863
16 9 0.28309439316509377
16 10 0.2501090573988438
15 13 -0.6485175435412747
15 14 -0.7668063443712008
16 13 0.8137706230969115
16 14 -0.2661847224606624
15 7 -0.6442936476294694
15 8 -0.5878720857895017
16 7 -0.2581141133504936
16 8 0.8888574164902534
17 18 0.041339313482924744
17 11 0.08787406849163526
17 12 0.3277246664347784
18 11 0.6635244080829124
18 12 0.895970973800222
17 15 -0.8035789245059162
17 16 -0.21808521717755824
18 15 -0.08569957531620931
18 16 -0.49482281831259667
17 9 0.2431182105351657
17 10 0.20271622624323782
18 9 0.6760555244443007
18 10 -0.9602980312054934
3 7 -0.24974831265384578
3 8 0.9495698025338444
4 7 0.8113253594825927
4 8 0.7115673096585802
5 9 0.025972963895515067
5 10 -0.05189668641649137
6 9 -0.28231537364653914
6 10 -0.6298126342821251
9 13 -0.17065967935812698
9 14 -0.5828355422867022
10 13 -0.6395271429265674
10 14 -0.6326498113627528
11 15 -0.342645305990952
11 16 -0.6444311859249112
12 15 0.5023530387484465
12 16 0.4161687742404492
57 changes: 57 additions & 0 deletions examples/ising_model_on_a_kings_graph.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using SpinGlassPEPS

function get_instance(topology::NTuple{3, Int})
m, n, t = topology
"$(@__DIR__)/instances/$(m)x$(n)x$(t).txt"
end

function run_square_diag_bench(::Type{T}; topology::NTuple{3, Int}) where {T}
m, n, _ = topology
instance = get_instance(topology)
lattice = super_square_lattice(topology)

best_energies = T[]

potts_h = potts_hamiltonian(
ising_graph(instance),
spectrum = full_spectrum,
cluster_assignment_rule = lattice,
)

params = MpsParameters{T}(; bond_dim = 16, num_sweeps = 1)
search_params = SearchParameters(; max_states = 2^8, cutoff_prob = 1E-4)

for transform ∈ all_lattice_transformations
net = PEPSNetwork{KingSingleNode{GaugesEnergy}, Dense, T}(
m, n, potts_h, transform,
)

ctr = MpsContractor{SVDTruncate, NoUpdate, T}(
net, params;
onGPU = false, beta = T(2), graduate_truncation = true,
)

# After update to SpinGlassEngine 1.5
# ctr = MpsContractor(SVDTruncate, net, params;
# onGPU = false, beta = T(2), graduate_truncation = true,
# )

droplets = SingleLayerDroplets(; max_energy = 10, min_size = 5, metric = :hamming)
merge_strategy = merge_branches(
ctr; merge_prob = :none , droplets_encoding = droplets,
)

sol, info = low_energy_spectrum(ctr, search_params, merge_strategy)

push!(best_energies, sol.energies[1])
clear_memoize_cache()
end

ground = minimum(best_energies)
@assert all(ground .≈ best_energies)

println("Best energy found: $(ground)")
end

T = Float32
@time run_square_diag_bench(T; topology = (3, 3, 2))
Loading