Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed Jun 24, 2024
1 parent 72fb1a6 commit 7a31603
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 85 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LuxorGraphPlot = "1f49bdf2-22a7-4bc4-978b-948dc219fbbc"

[compat]
Graphs = "1.6"
LuxorGraphPlot = "0.3"
LuxorGraphPlot = "0.5"
julia = "1"

[extras]
Expand Down
11 changes: 11 additions & 0 deletions notebooks/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ PlutoSliderServer = "2fc8631c-6f24-4c5b-bca7-cbb509c42db4"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
UnitDiskMapping = "1b61a8d9-79ed-4491-8266-ef37f39e1727"

[compat]
GenericTensorNetworks = "2"
Graphs = "1.6"
LinearAlgebra = "1"
LuxorGraphPlot = "0.4"
PlutoSliderServer = "0.3"
PlutoUI = "0.7"
Revise = "3"
UnitDiskMapping = "0.4"
julia = "1"
33 changes: 18 additions & 15 deletions notebooks/tutorial.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### A Pluto.jl notebook ###
# v0.19.32
# v0.19.42

using Markdown
using InteractiveUtils
Expand Down Expand Up @@ -46,7 +46,7 @@ using UnitDiskMapping, Graphs, GenericTensorNetworks, LinearAlgebra
# ╔═╡ 98459516-4833-4e4a-916f-d5ea3e657ceb
# Visualization setup.
# To make the plots dark-mode friendly, we use white-background color.
using UnitDiskMapping.LuxorGraphPlot.Luxor, LuxorGraphPlot; GraphDisplayConfig.unit[] = 25; GraphDisplayConfig.background_color[]="white";
using UnitDiskMapping.LuxorGraphPlot.Luxor, LuxorGraphPlot

# ╔═╡ eac6ceda-f5d4-11ec-23db-b7b4d00eaddf
md"# Unit Disk Mapping"
Expand All @@ -64,7 +64,7 @@ md"Let the source graph be the Petersen graph."
graph = smallgraph(:petersen)

# ╔═╡ 0302be92-076a-4ebe-8d6d-4b352a77cfce
LuxorGraphPlot.show_graph(graph; unit=50)
LuxorGraphPlot.show_graph(graph)

# ╔═╡ 417b18f6-6a8f-45fb-b979-6ec9d12c6246
md"We can use the `map_graph` function to map the unweighted MIS problem on the Petersen graph to one on a defected King's graph."
Expand All @@ -86,9 +86,11 @@ fieldnames(unweighted_res |> typeof)
md"The field `grid_graph` is the mapped grid graph."

# ╔═╡ 520fbc23-927c-4328-8dc6-5b98853fb90d
# `unit` is the number of pixels per unit distance
LuxorGraphPlot.show_graph(unweighted_res.grid_graph)

# ╔═╡ af162d39-2da9-4a06-9cde-8306e811ba7a
unweighted_res.grid_graph.size

# ╔═╡ 96ca41c0-ac77-404c-ada3-0cdc4a426e44
md"The field `lines` is a vector of copy gadgets arranged in a `⊢` shape. These copy gadgets form a *crossing lattice*, in which two copy lines cross each other whenever their corresponding vertices in the source graph are connected by an edge.
```
Expand Down Expand Up @@ -121,7 +123,7 @@ unweighted_res.mis_overhead
md"We can solve the mapped graph with [`GenericTensorNetworks`](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/)."

# ╔═╡ f084b98b-097d-4b33-a0d3-0d0a981f735e
res = solve(IndependentSet(SimpleGraph(unweighted_res.grid_graph)), SingleConfigMax())[]
res = solve(GenericTensorNetwork(IndependentSet(SimpleGraph(unweighted_res.grid_graph))), SingleConfigMax())[]

# ╔═╡ 86457b4e-b83e-4bf5-9d82-b5e14c055b4b
md"You might want to read [the documentation page of `GenericTensorNetworks`](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/) for a detailed explanation on this function. Here, we just visually check the solution configuration."
Expand Down Expand Up @@ -180,7 +182,7 @@ md"Now that we have both the graph and the weights, let us solve the mapped prob
wmap_config = let
graph, _ = graph_and_weights(weighted_res.grid_graph)
collect(Int,
solve(IndependentSet(graph; weights=mapped_weights), SingleConfigMax())[].c.data
solve(GenericTensorNetwork(IndependentSet(graph, mapped_weights)), SingleConfigMax())[].c.data
)
end

Expand All @@ -197,7 +199,7 @@ map_config_back(weighted_res, wmap_config)
# ╔═╡ beb7c0e5-6221-4f20-9166-2bd56902be1b
# Directly solving the source graph
collect(Int,
solve(IndependentSet(graph; weights=source_weights), SingleConfigMax())[].c.data
solve(GenericTensorNetwork(IndependentSet(graph, source_weights)), SingleConfigMax())[].c.data
)

# ╔═╡ cf7e88cb-432e-4e3a-ae8b-8fa12689e485
Expand Down Expand Up @@ -248,7 +250,7 @@ show_grayscale(qubo.grid_graph)
md"By solving this maximum independent set problem, we will get the following configuration."

# ╔═╡ ef149d9a-6aa9-4f34-b936-201b9d77543c
qubo_mapped_solution = collect(Int, solve(IndependentSet(qubo_graph; weights=qubo_weights), SingleConfigMax())[].c.data)
qubo_mapped_solution = collect(Int, solve(GenericTensorNetwork(IndependentSet(qubo_graph, qubo_weights)), SingleConfigMax())[].c.data)

# ╔═╡ 4ea4f26e-746d-488e-9968-9fc584c04bcf
show_config(qubo.grid_graph, qubo_mapped_solution)
Expand All @@ -264,8 +266,8 @@ map_config_back(qubo, collect(Int, qubo_mapped_solution))
md"This solution is consistent with the exact solution:"

# ╔═╡ 7dd900fc-9531-4bd6-8b6d-3aac3d5a2386
# Directly solving the source graph
collect(Int, solve(SpinGlass(J, h), SingleConfigMax())[].c.data)
# Directly solving the source graph, due to the convention issue, we flip the signs of `J` and `h`
collect(Int, solve(GenericTensorNetwork(spin_glass_from_matrix(-J, -h)), SingleConfigMax())[].c.data)

# ╔═╡ 13f952ce-642a-4396-b574-00ea6584008c
md"### QUBO problem on a square lattice"
Expand Down Expand Up @@ -308,7 +310,7 @@ md"Let us solve the independent set problem on the mapped graph."
square_graph, square_weights = UnitDiskMapping.graph_and_weights(qubo_square.grid_graph);

# ╔═╡ 5c25abb7-e3ee-4104-9a82-eb4aa4e773d2
config_square = collect(Int, solve(IndependentSet(square_graph; weights=square_weights), SingleConfigMax())[].c.data);
config_square = collect(Int, solve(GenericTensorNetwork(IndependentSet(square_graph, square_weights)), SingleConfigMax())[].c.data);

# ╔═╡ 4cec7232-8fbc-4ac1-96bb-6c7fea5fe117
md"We will get the following configuration."
Expand Down Expand Up @@ -343,7 +345,7 @@ let
for (i,j,h) in square_onsite
hs[i+(j-1)*n] = h
end
collect(Int, solve(SpinGlass(g2; J=Js, h=hs), SingleConfigMax())[].c.data)
collect(Int, solve(GenericTensorNetwork(SpinGlass(g2, -Js, -hs)), SingleConfigMax())[].c.data)
end

# ╔═╡ 9db831d6-7f10-47be-93d3-ebc892c4b3f2
Expand Down Expand Up @@ -386,7 +388,7 @@ md"To solve this factoring problem, one can use the following statement:"

# ╔═╡ e5da7214-0e69-4b5a-a65e-ed92d0616c71
multiplier_output = UnitDiskMapping.solve_factoring(mres, 6) do g, ws
collect(Int, solve(IndependentSet(g; weights=ws), SingleConfigMax())[].c.data)
collect(Int, solve(GenericTensorNetwork(IndependentSet(g, ws)), SingleConfigMax())[].c.data)
end

# ╔═╡ 9dc01591-5c37-4d83-b640-83280513941e
Expand Down Expand Up @@ -416,7 +418,7 @@ md"2. Then, we solve this new grid graph."
# ╔═╡ 57f7e085-9589-4a6c-ac14-488ea9924692
config_factoring6 = let
mg, mw = graph_and_weights(mapped_grid_graph)
solve(IndependentSet(mg; weights=mw), SingleConfigMax())[].c.data
solve(GenericTensorNetwork(IndependentSet(mg, mw)), SingleConfigMax())[].c.data
end;

# ╔═╡ 4c7d72f1-688a-4a70-8ce6-a4801127bb9a
Expand All @@ -440,7 +442,7 @@ md"## Logic Gates"
md"Let us define a helper function for visualization."

# ╔═╡ c17bca17-a00a-4118-a212-d21da09af9b5
parallel_show(gate) = leftright(show_pins(Gate(gate); format=:png, unit=80), show_grayscale(gate_gadget(Gate(gate))[1]; format=:png, unit=80, wmax=2));
parallel_show(gate) = leftright(show_pins(Gate(gate)), show_grayscale(gate_gadget(Gate(gate))[1], wmax=2));

# ╔═╡ 6aee2288-1934-4fc5-9a9c-f45b7ce4e767
md"1. NOT gate: ``y_1 =\neg x_1``"
Expand Down Expand Up @@ -485,6 +487,7 @@ md"Since most logic gates have 3 pins, it is natural to embed a circuit to a 3D
# ╠═ae5c8359-6bdb-4a2a-8b54-cd2c7d2af4bd
# ╟─56bdcaa6-c8b9-47de-95d4-6e95204af0f2
# ╠═520fbc23-927c-4328-8dc6-5b98853fb90d
# ╠═af162d39-2da9-4a06-9cde-8306e811ba7a
# ╟─96ca41c0-ac77-404c-ada3-0cdc4a426e44
# ╠═5dfa8a74-26a5-45c4-a80c-47ba4a6a4ae9
# ╟─a64c2094-9a51-4c45-b9d1-41693c89a212
Expand Down
14 changes: 7 additions & 7 deletions notebooks/unweighted.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### A Pluto.jl notebook ###
# v0.19.32
# v0.19.42

using Markdown
using InteractiveUtils
Expand Down Expand Up @@ -107,7 +107,7 @@ md"#### Step 3: Solve the MIS size of the mapped graph"
md"The independent set size can be obtained by solving the `SizeMax()` property using the [generic tensor network](https://github.com/QuEraComputing/GenericTensorNetworks.jl) method."

# ╔═╡ 67fd2dd2-5add-4402-9618-c9b7c7bfe95b
missize_g5_ksg = solve(IndependentSet(SimpleGraph(g5res.grid_graph)), SizeMax())[]
missize_g5_ksg = solve(GenericTensorNetwork(IndependentSet(SimpleGraph(g5res.grid_graph))), SizeMax())[]

# ╔═╡ aaee9dbc-5b9c-41b1-b0d4-35d2cac7c773
md"The predicted MIS size for the source graph is:"
Expand All @@ -121,7 +121,7 @@ One of the best solutions can be obtained by solving the `SingleConfigMax()` pro
"""

# ╔═╡ 0142f661-0855-45b4-852a-78f560e98c67
mis_g5_ksg = solve(IndependentSet(SimpleGraph(g5res.grid_graph)), SingleConfigMax())[].c.data
mis_g5_ksg = solve(GenericTensorNetwork(IndependentSet(SimpleGraph(g5res.grid_graph))), SingleConfigMax())[].c.data

# ╔═╡ fa046f3c-fd7d-4e91-b3f5-fc4591d3cae2
md"Plot the solution"
Expand Down Expand Up @@ -153,7 +153,7 @@ UnitDiskMapping.is_independent_set(g5, mis_g5)
count(isone, mis_g5)

# ╔═╡ 5621bb2a-b1c6-4f0d-921e-980b2ce849d5
solve(IndependentSet(g5), SizeMax())[].n
solve(GenericTensorNetwork(IndependentSet(g5)), SizeMax())[].n

# ╔═╡ 1fe6c679-2962-4c1b-8b12-4ceb77ed9e0f
md"""
Expand All @@ -178,13 +178,13 @@ petersen_res = UnitDiskMapping.map_graph(petersen)
md"The MIS size of the petersen graph is 4."

# ╔═╡ bf97a268-cd96-4dbc-83c6-10eb1b03ddcc
missize_petersen = solve(IndependentSet(petersen), SizeMax())[]
missize_petersen = solve(GenericTensorNetwork(IndependentSet(petersen)), SizeMax())[]

# ╔═╡ 2589f112-5de5-4c98-bcd1-138b6143cd30
md" The MIS size of the mapped KSG graph is much larger"

# ╔═╡ 1b946455-b152-4d6f-9968-7dc6e22d171a
missize_petersen_ksg = solve(IndependentSet(SimpleGraph(petersen_res.grid_graph)), SizeMax())[]
missize_petersen_ksg = solve(GenericTensorNetwork(IndependentSet(SimpleGraph(petersen_res.grid_graph))), SizeMax())[]

# ╔═╡ 4e7f7d9e-fae4-46d2-b95d-110d36b691d9
md"The difference in the MIS size is:"
Expand All @@ -196,7 +196,7 @@ petersen_res.mis_overhead
md"Find an MIS of the mapped KSG and map it back an MIS on the source graph."

# ╔═╡ 0d08cb1a-f7f3-4d63-bd70-78103db086b3
mis_petersen_ksg = solve(IndependentSet(SimpleGraph(petersen_res.grid_graph)), SingleConfigMax())[].c.data
mis_petersen_ksg = solve(GenericTensorNetwork(IndependentSet(SimpleGraph(petersen_res.grid_graph))), SingleConfigMax())[].c.data

# ╔═╡ c27d8aed-c81f-4eb7-85bf-a4ed88c2537f
mis_petersen = UnitDiskMapping.map_config_back(petersen_res, collect(mis_petersen_ksg))
Expand Down
2 changes: 1 addition & 1 deletion src/mapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ struct MappingResult{NT}
end

"""
map_graph([mode=Weighted(),] g::SimpleGraph; vertex_order=Branching(), ruleset=[...])
map_graph([mode=UnWeighted(),] g::SimpleGraph; vertex_order=Branching(), ruleset=[...])
Map a graph to a unit disk grid graph that being "equivalent" to the original graph, and return a `MappingResult` instance.
Here "equivalent" means a maximum independent set in the grid graph can be mapped back to
Expand Down
67 changes: 37 additions & 30 deletions src/visualize.jl
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
# normalized to minimum weight and maximum weight
function LuxorGraphPlot.show_graph(gg::GridGraph;
format=:svg, filename=nothing,
vertex_size=0.35,
fontsize=20,
kwargs...)
# transpose (i, j) to make them consistent with terminal output
unit = GraphDisplayConfig.unit[]
locs = [(j,i) for (i,j) in coordinates(gg)]
length(locs) == 0 && return _draw(()->nothing, 100, 100; format, filename)
edges = [(e.src, e.dst) for e in Graphs.edges(graph_and_weights(gg)[1])]

# configure canvas and plot
config = LuxorGraphPlot.graphsizeconfig(locs)
transform(loc) = loc[1]-config.xmin+config.xpad, loc[2]-config.ymin+config.ypad
Dx, Dy = ((config.xmax-config.xmin)+2*config.xpad)*unit, ((config.ymax-config.ymin)+2*config.ypad)*unit
# compute empty locations
empty_locations = Tuple{Int,Int}[]
for i=config.xmin:config.xmax, j=config.ymin:config.ymax
(i, j) locs && push!(empty_locations, (i, j))
end

format = :svg,
filename = nothing,
padding_left = 10,
padding_right = 10,
padding_top = 10,
padding_bottom = 10,
show_number = false,
config = GraphDisplayConfig(),
texts = nothing,
vertex_colors=nothing,
)
texts !== nothing && show_number && @warn "not showing number due to the manually specified node texts."
# plot!
LuxorGraphPlot._draw(Dx, Dy; format, filename) do
LuxorGraphPlot.@temp GraphDisplayConfig.vertex_size[] = vertex_size GraphDisplayConfig.fontsize[] = fontsize begin
LuxorGraphPlot._show_graph(locs, edges;
vertex_size, fontsize, kwargs...)
unit = 33.0
coos = coordinates(gg)
xmin, xmax = extrema(first.(coos))
ymin, ymax = extrema(last.(coos))
nodestore() do ns
filledlocs = map(coo->circle!((unit * (coo[2] - 1), -unit * (coo[1] - 1)), config.vertex_size), coos)
emptylocs, edges = [], []
for i=xmin:xmax, j=ymin:ymax
(i, j) coos && push!(emptylocs, circle!(((j-1) * unit, -(i-1) * unit), config.vertex_size/10))
end

# visualize dots
LuxorGraphPlot.@temp GraphDisplayConfig.vertex_size[] = vertex_size/10 GraphDisplayConfig.fontsize[] = fontsize GraphDisplayConfig.vertex_color[]="#333333" GraphDisplayConfig.vertex_stroke_color[]="transparent" GraphDisplayConfig.background_color[]="transparent" begin
LuxorGraphPlot._show_graph(empty_locations, []; texts=fill("", length(empty_locations)))
for e in Graphs.edges(graph_and_weights(gg)[1])
i, j = e.src, e.dst
push!(edges, Connection(filledlocs[i], filledlocs[j]))
end
with_nodes(ns; format, filename, padding_bottom, padding_left, padding_right, padding_top, background=config.background) do
config2 = copy(config)
config2 = GraphDisplayConfig(; vertex_color="#333333", vertex_stroke_color="transparent")
texts = texts===nothing && show_number ? string.(1:length(filledlocs)) : texts
LuxorGraphPlot.render_nodes(filledlocs, config; texts, vertex_colors)
LuxorGraphPlot.render_edges(edges, config)
LuxorGraphPlot.render_nodes(emptylocs, config2; texts=nothing)
end
end
end

function show_grayscale(gg::GridGraph; wmax=nothing, kwargs...)
_, ws = graph_and_weights(gg)
_, ws0 = graph_and_weights(gg)
ws = tame_weights.(ws0)
if wmax === nothing
wmax = maximum(abs, ws)
end
Expand All @@ -46,6 +51,8 @@ function show_grayscale(gg::GridGraph; wmax=nothing, kwargs...)
vertex_colors= [cmap[max(1, round(Int, 100+w/wmax*100))] for w in ws]
show_graph(gg; vertex_colors, kwargs...)
end
tame_weights(w::ONE) = 1.0
tame_weights(w::Real) = w

function show_pins(gg::GridGraph, color_pins::AbstractDict; kwargs...)
vertex_colors=String[]
Expand Down Expand Up @@ -90,7 +97,7 @@ function show_config(gg::GridGraph, config; kwargs...)
show_graph(gg; vertex_colors, kwargs...)
end

function show_pins(mres::MappingResult; kwargs...)
function show_pins(mres::MappingResult{<:WeightedNode}; kwargs...)
locs = getfield.(mres.grid_graph.nodes, :loc)
center_indices = map(loc->findfirst(==(loc), locs), trace_centers(mres))
color_pins = Dict{Int,Tuple{String,String}}()
Expand Down
11 changes: 5 additions & 6 deletions test/dragondrop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using Random
@test show_pins(qubo) !== nothing
println(qubo)
graph, weights = UnitDiskMapping.graph_and_weights(qubo.grid_graph)
r1 = solve(IndependentSet(graph; weights), SingleConfigMax())[]
r1 = solve(GenericTensorNetwork(IndependentSet(graph, weights)), SingleConfigMax())[]
J2 = vcat([Float64[J[i,j] for j=i+1:n] for i=1:n]...)
r2 = solve(SpinGlass(complete_graph(n); J=J2, h=H), SingleConfigMax())[]
@test r1.n - qubo.mis_overhead r2.n
Expand All @@ -28,10 +28,9 @@ end
n = nv(g0)
w0 = ones(n) * 0.01
wmis = UnitDiskMapping.map_simple_wmis(g0, w0)
@test show_pins(wmis) !== nothing
graph, weights = UnitDiskMapping.graph_and_weights(wmis.grid_graph)
r1 = solve(IndependentSet(graph; weights), SingleConfigMax())[]
r2 = solve(IndependentSet(g0; weights=w0), SingleConfigMax())[]
r1 = solve(GenericTensorNetwork(IndependentSet(graph, weights)), SingleConfigMax())[]
r2 = solve(GenericTensorNetwork(IndependentSet(g0, w0)), SingleConfigMax())[]
@test r1.n - wmis.mis_overhead r2.n
@test r1.n % 1 r2.n % 1
c1 = map_config_back(wmis, r1.c.data)
Expand All @@ -47,7 +46,7 @@ end
]
qubo = UnitDiskMapping.map_qubo_restricted(coupling)
graph, weights = UnitDiskMapping.graph_and_weights(qubo.grid_graph)
r1 = solve(IndependentSet(graph; weights), SingleConfigMax())[]
r1 = solve(GenericTensorNetwork(IndependentSet(graph, weights)), SingleConfigMax())[]


weights = Int[]
Expand All @@ -70,7 +69,7 @@ end
onsite = vec([(i, j, 0.01*randn()) for i=1:m, j=1:n])
qubo = UnitDiskMapping.map_qubo_square(coupling, onsite)
graph, weights = UnitDiskMapping.graph_and_weights(qubo.grid_graph)
r1 = solve(IndependentSet(graph; weights), SingleConfigMax())[]
r1 = solve(GenericTensorNetwork(IndependentSet(graph, weights)), SingleConfigMax())[]

# solve spin glass directly
g2 = SimpleGraph(m*n)
Expand Down
6 changes: 3 additions & 3 deletions test/extracting_results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ using GenericTensorNetworks
locs, g, pins = mapped_graph(s)
d1 = UnitDiskMapping.mapped_entry_to_compact(s)
d2 = UnitDiskMapping.source_entry_to_configs(s)
m = solve(IndependentSet(g, openvertices=pins), ConfigsMax())
t = solve(IndependentSet(g0, openvertices=pins0), SizeMax())
for i=1:length(m)
m = solve(GenericTensorNetwork(IndependentSet(g), openvertices=pins), ConfigsMax())
t = solve(GenericTensorNetwork(IndependentSet(g0), openvertices=pins0), SizeMax())
for i in eachindex(m)
for v in m[i].c.data
bc = UnitDiskMapping.mapped_boundary_config(s, v)
compact_bc = d1[bc]
Expand Down
4 changes: 2 additions & 2 deletions test/gadgets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ using Graphs
locs1, g1, pins1 = source_graph(s)
locs2, g2, pins2 = mapped_graph(s)
@assert length(locs1) == nv(g1)
m1 = mis_compactify!(solve(IndependentSet(g1, openvertices=pins1), SizeMax()))
m2 = mis_compactify!(solve(IndependentSet(g2, openvertices=pins2), SizeMax()))
m1 = mis_compactify!(solve(GenericTensorNetwork(IndependentSet(g1), openvertices=pins1), SizeMax()))
m2 = mis_compactify!(solve(GenericTensorNetwork(IndependentSet(g2), openvertices=pins2), SizeMax()))
@test nv(g1) == length(locs1) && nv(g2) == length(locs2)
sig, diff = UnitDiskMapping.is_diff_by_const(content.(m1), content.(m2))
@test diff == -mis_overhead(s)
Expand Down
2 changes: 1 addition & 1 deletion test/logicgates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using GenericTensorNetworks
@info gate
g, inputs, outputs = gate_gadget(Gate(gate))
@test UnitDiskMapping.truth_table(Gate(gate)) do graph, weights
collect.(Int, solve(IndependentSet(graph; weights), ConfigsMax())[].c.data)
collect.(Int, solve(GenericTensorNetwork(IndependentSet(graph, weights)), ConfigsMax())[].c.data)
end == [f([x>>(i-1) & 1 == 1 for i=1:length(inputs)]...) for x in 0:1<<length(inputs)-1]
end
end
Loading

0 comments on commit 7a31603

Please sign in to comment.