Skip to content

Commit

Permalink
Deploying to gh-pages from @ a788148 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed Dec 13, 2024
1 parent 1ecd888 commit 2c61489
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
16 changes: 8 additions & 8 deletions notebooks/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ version = "1.1.1+0"

[[deps.ConcurrentUtilities]]
deps = ["Serialization", "Sockets"]
git-tree-sha1 = "ea32b83ca4fefa1768dc84e504cc0a94fb1ab8d1"
git-tree-sha1 = "f36e5e8fdffcb5646ea5da81495a5a7566005127"
uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
version = "2.4.2"
version = "2.4.3"

[[deps.Configurations]]
deps = ["ExproniconLite", "OrderedCollections", "TOML"]
Expand Down Expand Up @@ -329,9 +329,9 @@ version = "0.5.5"

[[deps.GenericTensorNetworks]]
deps = ["AbstractTrees", "DelimitedFiles", "Distributed", "DocStringExtensions", "FFTW", "Graphs", "LinearAlgebra", "LuxorGraphPlot", "OMEinsum", "Polynomials", "Primes", "ProblemReductions", "Random", "SIMDTypes", "Serialization", "StatsBase", "TropicalNumbers"]
git-tree-sha1 = "45b82ea9c88ef7f882bf838032368348c59a372a"
git-tree-sha1 = "4f4c564d2a2a5724245c70709a831da6387429da"
uuid = "3521c873-ad32-4bb4-b63d-f4f178f42b49"
version = "3.0.0"
version = "3.1.0"

[deps.GenericTensorNetworks.extensions]
GenericTensorNetworksCUDAExt = "CUDA"
Expand Down Expand Up @@ -911,9 +911,9 @@ version = "1.11.0"

[[deps.ProblemReductions]]
deps = ["BitBasis", "DocStringExtensions", "Graphs", "InteractiveUtils", "MLStyle", "PrettyTables"]
git-tree-sha1 = "7679e48c2f432b9e86307a32d66940eef3512cd4"
git-tree-sha1 = "d476078d1d2ce471516b5150382974fc8a0265e4"
uuid = "899c297d-f7d2-4ebf-8815-a35996def416"
version = "0.2.0"
version = "0.2.1"

[[deps.ProgressLogging]]
deps = ["Logging", "SHA", "UUIDs"]
Expand Down Expand Up @@ -1219,9 +1219,9 @@ version = "1.3.6+1"

[[deps.Xorg_libXrender_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libX11_jll"]
git-tree-sha1 = "47e45cd78224c53109495b3e324df0c37bb61fbe"
git-tree-sha1 = "a490c6212a0e90d2d55111ac956f7c4fa9c277a6"
uuid = "ea2f1a96-1ddc-540d-b46f-429655e07cfa"
version = "0.9.11+0"
version = "0.9.11+1"

[[deps.Xorg_libpthread_stubs_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
Expand Down
2 changes: 1 addition & 1 deletion notebooks/tutorial.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion notebooks/unweighted.html

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions test/dragondrop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ using Random
r1 = solve(GenericTensorNetwork(IndependentSet(graph, weights)), SingleConfigMax())[]
J2 = vcat([Float64[J[i,j] for j=i+1:n] for i=1:n]...)
# note the different sign convention of J
r2 = solve(GenericTensorNetwork(SpinGlass(complete_graph(n), -J2, H)), SingleConfigMax())[]
sg = SpinGlass(complete_graph(n), -J2, H)
r2 = solve(GenericTensorNetwork(sg), SingleConfigMax())[]
@test r1.n - qubo.mis_overhead r2.n
@test r1.n % 1 r2.n % 1
c1 = map_config_back(qubo, r1.c.data)
@test spinglass_energy(complete_graph(n), c1; J=-J2, h=H) spinglass_energy(complete_graph(n), r2.c.data; J=-J2, h=H)
@test GenericTensorNetworks.energy(sg, 1 .- 2 .* Int.(c1)) GenericTensorNetworks.energy(sg, 1 .- 2 .* Int.(r2.c.data))
#display(MappingGrid(UnitDiskMapping.CopyLine[], 0, qubo))
end

Expand Down Expand Up @@ -56,7 +57,7 @@ end
add_edge!(g2, (i-1)*n+j, (i2-1)*n+j2)
push!(weights, J)
end
r2 = solve(GenericTensorNetwork(SpinGlass(g2, -weights)), SingleConfigMax())[]
r2 = solve(GenericTensorNetwork(SpinGlass(g2, -weights, zeros(Int, n*n))), SingleConfigMax())[]
@show r1, r2
end

Expand Down Expand Up @@ -88,9 +89,10 @@ end
for (i,j,h) in onsite
hs[i+(j-1)*m] = h
end
r2 = solve(GenericTensorNetwork(SpinGlass(g2, -Js, hs)), SingleConfigMax())[]
sg = SpinGlass(g2, -Js, hs)
r2 = solve(GenericTensorNetwork(sg), SingleConfigMax())[]
@test r1.n - qubo.mis_overhead r2.n
c1 = map_config_back(qubo, collect(Int,r1.c.data))
c2 = collect(r2.c.data)
@test spinglass_energy(g2, c1; J=-Js, h=hs) spinglass_energy(g2, c2; J=-Js, h=hs)
end
@test GenericTensorNetworks.energy(sg, 1 .- 2 .* Int.(c1)) GenericTensorNetworks.energy(sg, 1 .- 2 .* Int.(c2))
end
6 changes: 3 additions & 3 deletions test/reduceto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ end
]
@info "Testing reduction from $(typeof(source)) to $(target_type)"
# directly solve
best_source = ProblemReductions.findbest(source, ProblemReductions.BruteForce())
solver = GTNSolver(optimizer=TreeSA(ntrials=1))
best_source = ProblemReductions.findbest(source, source isa ConstraintSatisfactionProblem ? solver : ProblemReductions.BruteForce())

# reduce and solve
result = ProblemReductions.reduceto(target_type, source)
target = ProblemReductions.target_problem(result)
@test target isa target_type
#best_target = findbest(target, BruteForce())
best_target = GenericTensorNetworks.solve(GenericTensorNetwork(GenericTensorNetworks.IndependentSet(SimpleGraph(target.graph), collect(target.weights))), ConfigsMax())[].c.data
best_target = ProblemReductions.findbest(IndependentSet(SimpleGraph(target.graph), collect(target.weights)), solver)

# extract the solution
best_source_extracted_single = unique( ProblemReductions.extract_solution.(Ref(result), best_target) )
Expand Down

0 comments on commit 2c61489

Please sign in to comment.