@@ -14,11 +14,12 @@ using Random
1414 r1 = solve(GenericTensorNetwork(IndependentSet(graph, weights)), SingleConfigMax())[]
1515 J2 = vcat([Float64[J[i,j] for j=i+1:n] for i=1:n]...)
1616 # note the different sign convention of J
17- r2 = solve(GenericTensorNetwork(SpinGlass(complete_graph(n), -J2, H)), SingleConfigMax())[]
17+ sg = SpinGlass(complete_graph(n), -J2, H)
18+ r2 = solve(GenericTensorNetwork(sg), SingleConfigMax())[]
1819 @test r1.n - qubo.mis_overhead ≈ r2.n
1920 @test r1.n % 1 ≈ r2.n % 1
2021 c1 = map_config_back(qubo, r1.c.data)
21- @test spinglass_energy(complete_graph(n), c1; J=-J2, h=H) ≈ spinglass_energy(complete_graph(n), r2.c.data; J=-J2, h=H )
22+ @test GenericTensorNetworks.energy(sg, 1 .- 2 .* Int.(c1)) ≈ GenericTensorNetworks.energy(sg, 1 .- 2 .* Int.( r2.c.data) )
2223 #display(MappingGrid(UnitDiskMapping.CopyLine[], 0, qubo))
2324end
2425
5657 add_edge!(g2, (i-1)*n+j, (i2-1)*n+j2)
5758 push!(weights, J)
5859 end
59- r2 = solve(GenericTensorNetwork(SpinGlass(g2, -weights)), SingleConfigMax())[]
60+ r2 = solve(GenericTensorNetwork(SpinGlass(g2, -weights, zeros(Int, n*n) )), SingleConfigMax())[]
6061 @show r1, r2
6162end
6263
8889 for (i,j,h) in onsite
8990 hs[i+(j-1)*m] = h
9091 end
91- r2 = solve(GenericTensorNetwork(SpinGlass(g2, -Js, hs)), SingleConfigMax())[]
92+ sg = SpinGlass(g2, -Js, hs)
93+ r2 = solve(GenericTensorNetwork(sg), SingleConfigMax())[]
9294 @test r1.n - qubo.mis_overhead ≈ r2.n
9395 c1 = map_config_back(qubo, collect(Int,r1.c.data))
9496 c2 = collect(r2.c.data)
95- @test spinglass_energy(g2, c1; J=-Js, h=hs) ≈ spinglass_energy(g2, c2; J=-Js, h=hs )
96- end
97+ @test GenericTensorNetworks.energy(sg, 1 .- 2 .* Int.(c1)) ≈ GenericTensorNetworks.energy(sg, 1 .- 2 .* Int.(c2) )
98+ end
0 commit comments