Skip to content

Commit af19ea2

Browse files
committed
update project.toml
1 parent ffb5fad commit af19ea2

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ version = "0.2.0"
66
[deps]
77
Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
88
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
9+
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
10+
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
911
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1012
LuxurySparse = "d05aeea4-b7d4-55ac-b691-9e7fabb07ba2"
1113
NiLang = "ab4ef3a6-0b42-11ea-31f6-e34652774712"
@@ -22,6 +24,8 @@ Yao = "5872b779-8223-5990-8dd0-5abbb0748c8c"
2224
Compose = "0.9"
2325
LuxurySparse = "0.6"
2426
NiLang = "0.8"
27+
LightGraphs = "1.3"
28+
HDF5 = "0.15"
2529
Requires = "1"
2630
SimpleTensorNetworks = "0.1"
2731
TropicalNumbers = "0.2.1"

src/pluto.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using .Pluto
22

3-
@info "You can use the notebooks now by typing, e.g.
3+
@info "You can use the notebooks in `TropicalTensors` now by typing, e.g.
44
∘ `TropicalTensors.notebook(\"spinglass\")`, solving square lattice spinglass using a quantum simulator.
55
∘ `TropicalTensors.notebook(\"ising_and_2sat\")`, solving Ising spinglass and 2-SAT counting using tensor network contraction.
66
"

test/second_neighbor.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,21 @@ end
6161
sg = Spinglass(lt, [-1,1], [0,0,0])
6262
@test solve(sg).n == 2
6363
end
64+
65+
@testset "forwarddiff" begin
66+
L = 6
67+
lt = rand_maskedsquare(L, L, 0.8)
68+
hs = zeros(length(lt))
69+
Js = rand([-1,1.0], length(sgbonds(lt)))
70+
res = solve(lt, Js, hs; usecuda=false).n
71+
gs = ForwardDiff.gradient(x->(dn = solve(lt, eltype(x).(Js), x; usecuda=false).n; (@test ForwardDiff.value(dn)==res); dn), hs)
72+
function compute_loss(lt, Js, config)
73+
res = 0.0
74+
vs = vertices(lt)
75+
for (i, (src, dst)) in enumerate(sgbonds(lt))
76+
res += Js[i] * config[findfirst(==(src), vs)] * config[findfirst(==(dst), vs)]
77+
end
78+
return res
79+
end
80+
@test compute_loss(lt, Js, gs) == res
81+
end

0 commit comments

Comments
 (0)