Skip to content

Commit 7ff47d1

Browse files
Add the 5 vertex example in the paper (#47)
* save * add examples * update * update README * update notebooks guide * Update notebooks/unweighted.jl Co-authored-by: Shengtao Wang <[email protected]> * Update notebooks/unweighted.jl Co-authored-by: Shengtao Wang <[email protected]> * Update notebooks/unweighted.jl Co-authored-by: Shengtao Wang <[email protected]> * Update notebooks/unweighted.jl Co-authored-by: Shengtao Wang <[email protected]> * Update notebooks/unweighted.jl Co-authored-by: Shengtao Wang <[email protected]> * Update notebooks/unweighted.jl Co-authored-by: Shengtao Wang <[email protected]> --------- Co-authored-by: Shengtao Wang <[email protected]>
1 parent 8504e7c commit 7ff47d1

File tree

6 files changed

+297
-63
lines changed

6 files changed

+297
-63
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name = "UnitDiskMapping"
22
uuid = "1b61a8d9-79ed-4491-8266-ef37f39e1727"
33
authors = ["QuEra Computing Inc."]
4-
version = "0.3.1"
4+
version = "0.3.2"
55

66
[deps]
77
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
88
LuxorGraphPlot = "1f49bdf2-22a7-4bc4-978b-948dc219fbbc"
99

1010
[compat]
1111
Graphs = "1.6"
12-
LuxorGraphPlot = "0.2"
12+
LuxorGraphPlot = "0.3"
1313
julia = "1"
1414

1515
[extras]

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ pkg> add UnitDiskMapping
2929

3030
## Examples
3131

32-
Please check this [notebook](https://queracomputing.github.io/UnitDiskMapping.jl/notebooks/tutorial.html), which contains the following examples:
32+
Please check the following notebooks:
33+
1. [Unit Disk Mapping](https://queracomputing.github.io/UnitDiskMapping.jl/notebooks/tutorial.html), which contains the examples in ["Quantum Optimization with Arbitrary Connectivity Using Rydberg Atom Arrays"](https://journals.aps.org/prxquantum/abstract/10.1103/PRXQuantum.4.010316):
34+
* Reduction from a generic weighted or unweighted maximum independent set (MIS) problem to that on a King's subgraph (KSG).
35+
* Reduction from a generic or square-lattice QUBO problem to an MIS problem on a unit-disk grid graph.
36+
* Reduction from an integer factorization problem to an MIS problem on a unit-disk grid graph.
3337

34-
* Reduction from a generic weighted or unweighted maximum independent set (MIS) problem to that on a diagonal coupled unit-disk grid graph (DUGG).
35-
* Reduction from a generic or square-lattice QUBO problem to an MIS problem on a unit-disk grid graph.
36-
* Reduction from an integer factorization problem to an MIS problem on a unit-disk grid graph.
38+
2. [Unweighted KSG reduction of the independent set problem](https://queracomputing.github.io/UnitDiskMapping.jl/notebooks/unweighted.html), which contains the unweighted reduction from a general graph to a King's subgraph. It covers all example graphs in paper: "Computer-Assisted Gadget Design and Problem Reduction of Unweighted Maximum Independent Set" (To be published).
3739

3840
![](https://user-images.githubusercontent.com/6257240/198861111-4499c17d-9938-406b-8253-943b01f4633c.png)
3941

40-
To run the notebook locally, you will need the [Pluto](https://github.com/fonsp/Pluto.jl) and [GenericTensorNetworks](https://github.com/QuEraComputing/GenericTensorNetworks.jl) Julia packages installed. You can run the following after entering the Package mode:
41-
42-
```
43-
pkg> add Pluto
44-
pkg> add GenericTensorNetworks
42+
To run the notebook locally, you will need to activate and instantiate the local environment that specified in the [`notebooks`](notebooks) directory:
43+
```bash
44+
$ cd notebooks
45+
$ julia --project -e 'using Pkg; Pkg.instantiate()'
4546
```
4647

47-
and returning to the Julia REPL (you can do this by hitting Backspace in the Package mode) to run:
48-
49-
```
50-
julia> import Pluto; Pluto.run()
48+
To run the notebook, just type in the same terminal:
49+
```bash
50+
julia --project -e "import Pluto; Pluto.run()"
5151
```
52-
in the `notebooks` directory of this project. At this point, your browser should automatically launch and display a list of available notebooks you can run. You should just see `tutorial.jl` listed.
52+
At this point, your browser should automatically launch and display a list of available notebooks you can run. You should just see the notebooks listed.
5353

5454

5555
## Supporting and Citing

examples/petersen.jl

Lines changed: 0 additions & 22 deletions
This file was deleted.

notebooks/tutorial.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.19.27
2+
# v0.19.32
33

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

5151
# ╔═╡ eac6ceda-f5d4-11ec-23db-b7b4d00eaddf
5252
md"# Unit Disk Mapping"

notebooks/unweighted.jl

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
### A Pluto.jl notebook ###
2+
# v0.19.32
3+
4+
using Markdown
5+
using InteractiveUtils
6+
7+
# ╔═╡ f55dbf80-8425-11ee-2e7d-4d1ad4f693af
8+
# ╠═╡ show_logs = false
9+
begin
10+
using Pkg; Pkg.activate(".")
11+
using Revise
12+
using PlutoUI
13+
# left right layout
14+
function leftright(a, b; width=600)
15+
HTML("""
16+
<style>
17+
table.nohover tr:hover td {
18+
background-color: white !important;
19+
}</style>
20+
21+
<table width=$(width)px class="nohover" style="border:none">
22+
<tr>
23+
<td>$(html(a))</td>
24+
<td>$(html(b))</td>
25+
</tr></table>
26+
""")
27+
end
28+
29+
# up down layout
30+
function updown(a, b; width=nothing)
31+
HTML("""<table class="nohover" style="border:none" $(width === nothing ? "" : "width=$(width)px")>
32+
<tr>
33+
<td>$(html(a))</td>
34+
</tr>
35+
<tr>
36+
<td>$(html(b))</td>
37+
</tr></table>
38+
""")
39+
end
40+
PlutoUI.TableOfContents()
41+
end
42+
43+
# ╔═╡ be011e30-74e6-49cd-b45a-288972dc5f18
44+
using UnitDiskMapping, Graphs # for mapping graphs to a King's subgraph (KSG)
45+
46+
# ╔═╡ 31250cb9-6f3a-429a-975d-752cb7c07883
47+
using GenericTensorNetworks # for solving the maximum independent sets
48+
49+
# ╔═╡ 9017a42c-9791-4933-84a4-9ff509967323
50+
md"""
51+
# Unweighted KSG reduction of the independent set problem
52+
"""
53+
54+
# ╔═╡ f0e7c030-4e43-4356-a5bb-717a7f382a17
55+
md"This notebook contains examples from the paper, "Computer-Assisted Gadget Design and Problem Reduction of Unweighted Maximum Independent Set"."
56+
57+
# ╔═╡ cb4a9655-6df2-46b3-8969-8b6f2db7c59a
58+
md"""
59+
## Example 1: The 5-vertex graph
60+
The five vertex demo graph in the paper.
61+
"""
62+
63+
# ╔═╡ 956a5c3a-b8c6-4040-9553-3b4e2337b163
64+
md"#### Step 1: Prepare a source graph."
65+
66+
# ╔═╡ d858f57e-1706-4b73-bc23-53f7af073b0c
67+
# the demo graph in the main text
68+
function demograph()
69+
g = SimpleGraph(5)
70+
for (i, j) in [(1, 2), (2, 4), (3, 4), (1, 3), (4, 5), (1, 5)]
71+
add_edge!(g, i, j)
72+
end
73+
return g
74+
end
75+
76+
# ╔═╡ a3a86c62-ee6e-4a3b-99b3-c484de3b5220
77+
g5 = demograph()
78+
79+
# ╔═╡ e6170e72-0804-401e-b9e5-65b8ee7d7edb
80+
show_graph(g5)
81+
82+
# ╔═╡ 625bdcf4-e37e-4bb8-bd1a-907cdcc5fe24
83+
md"""
84+
#### Step 2: Map the source graph to an unweighted King's subgraph (KSG)
85+
The vertex order is optimized with the Branching path decomposition algorithm
86+
"""
87+
88+
# ╔═╡ f9e57a6b-1186-407e-a8b1-cb8f31a17bd2
89+
g5res = UnitDiskMapping.map_graph(g5; vertex_order=Branching())
90+
91+
# ╔═╡ e64e7ca4-b297-4c74-8699-bec4b4fbb843
92+
md"Visualize the mapped KSG graph in terminal"
93+
94+
# ╔═╡ 0a860597-0610-48f6-b1ee-711939712de4
95+
print(g5res.grid_graph)
96+
97+
# ╔═╡ eeae7074-ee21-44fc-9605-3555acb84cee
98+
md"or in a plotting plane"
99+
100+
# ╔═╡ 3fa6052b-74c2-453d-a473-68f4b3ca0490
101+
show_graph(g5res.grid_graph)
102+
103+
# ╔═╡ 942e8dfb-b89d-4f2d-b1db-f4636d4e5de6
104+
md"#### Step 3: Solve the MIS size of the mapped graph"
105+
106+
# ╔═╡ 766018fa-81bd-4c37-996a-0cf77b0909af
107+
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."
108+
109+
# ╔═╡ 67fd2dd2-5add-4402-9618-c9b7c7bfe95b
110+
missize_g5_ksg = solve(IndependentSet(SimpleGraph(g5res.grid_graph)), SizeMax())[]
111+
112+
# ╔═╡ aaee9dbc-5b9c-41b1-b0d4-35d2cac7c773
113+
md"The predicted MIS size for the source graph is:"
114+
115+
# ╔═╡ 114e2c42-aaa3-470b-a267-e5a7c6b08607
116+
missize_g5_ksg.n - g5res.mis_overhead
117+
118+
# ╔═╡ e6fa2404-cbe9-4f9b-92a0-0d6fdb649c44
119+
md"""
120+
One of the best solutions can be obtained by solving the `SingleConfigMax()` property.
121+
"""
122+
123+
# ╔═╡ 0142f661-0855-45b4-852a-78f560e98c67
124+
mis_g5_ksg = solve(IndependentSet(SimpleGraph(g5res.grid_graph)), SingleConfigMax())[].c.data
125+
126+
# ╔═╡ fa046f3c-fd7d-4e91-b3f5-fc4591d3cae2
127+
md"Plot the solution"
128+
129+
# ╔═╡ 0cbcd2a6-b8ae-47ff-8541-963b9dae700a
130+
show_config(g5res.grid_graph, mis_g5_ksg)
131+
132+
# ╔═╡ 4734dc0b-0770-4f84-8046-95a74104936f
133+
md"#### Step 4: Map the KSG solution back"
134+
135+
# ╔═╡ 0f27de9f-2e06-4d5e-b96f-b7c7fdadabca
136+
md"In the following, we will show how to obtain an MIS of the source graph from that of its KSG reduction."
137+
138+
# ╔═╡ fc968df0-832b-44c9-8335-381405b92199
139+
mis_g5 = UnitDiskMapping.map_config_back(g5res, collect(mis_g5_ksg))
140+
141+
# ╔═╡ 29458d07-b2b2-49af-a696-d0cb0ad35481
142+
md"Show that the overhead in the MIS size is correct"
143+
144+
# ╔═╡ fa4888b2-fc67-4285-8305-da655c42a898
145+
md"Verify the result:"
146+
147+
# ╔═╡ e84102e8-d3f2-4f91-87be-dba8e81462fb
148+
# the extracted solution is an independent set
149+
UnitDiskMapping.is_independent_set(g5, mis_g5)
150+
151+
# ╔═╡ 88ec52b3-73fd-4853-a69b-442f5fd2e8f7
152+
# and its size is maximized
153+
count(isone, mis_g5)
154+
155+
# ╔═╡ 5621bb2a-b1c6-4f0d-921e-980b2ce849d5
156+
solve(IndependentSet(g5), SizeMax())[].n
157+
158+
# ╔═╡ 1fe6c679-2962-4c1b-8b12-4ceb77ed9e0f
159+
md"""
160+
## Example 2: The Petersen graph
161+
162+
We just quickly go through a second example, the Petersen graph.
163+
"""
164+
165+
# ╔═╡ ea379863-95dd-46dd-a0a3-0a564904476a
166+
petersen = smallgraph(:petersen)
167+
168+
# ╔═╡ d405e7ec-50e3-446c-8d19-18f1a66c1e3b
169+
show_graph(petersen)
170+
171+
# ╔═╡ 409b03d1-384b-48d3-9010-8079cbf66dbf
172+
md"We first map it to a grid graph (unweighted)."
173+
174+
# ╔═╡ a0e7da6b-3b71-43d4-a1da-f1bd953e4b50
175+
petersen_res = UnitDiskMapping.map_graph(petersen)
176+
177+
# ╔═╡ 4f1f0ca0-dd2a-4768-9b4e-80813c9bb544
178+
md"The MIS size of the petersen graph is 4."
179+
180+
# ╔═╡ bf97a268-cd96-4dbc-83c6-10eb1b03ddcc
181+
missize_petersen = solve(IndependentSet(petersen), SizeMax())[]
182+
183+
# ╔═╡ 2589f112-5de5-4c98-bcd1-138b6143cd30
184+
md" The MIS size of the mapped KSG graph is much larger"
185+
186+
# ╔═╡ 1b946455-b152-4d6f-9968-7dc6e22d171a
187+
missize_petersen_ksg = solve(IndependentSet(SimpleGraph(petersen_res.grid_graph)), SizeMax())[]
188+
189+
# ╔═╡ 4e7f7d9e-fae4-46d2-b95d-110d36b691d9
190+
md"The difference in the MIS size is:"
191+
192+
# ╔═╡ d0e49c1f-457d-4b61-ad0e-347afb029114
193+
petersen_res.mis_overhead
194+
195+
# ╔═╡ 03d8adb3-0bf4-44e6-9b0a-fffc90410cfc
196+
md"Find an MIS of the mapped KSG and map it back an MIS on the source graph."
197+
198+
# ╔═╡ 0d08cb1a-f7f3-4d63-bd70-78103db086b3
199+
mis_petersen_ksg = solve(IndependentSet(SimpleGraph(petersen_res.grid_graph)), SingleConfigMax())[].c.data
200+
201+
# ╔═╡ c27d8aed-c81f-4eb7-85bf-a4ed88c2537f
202+
mis_petersen = UnitDiskMapping.map_config_back(petersen_res, collect(mis_petersen_ksg))
203+
204+
# ╔═╡ 20f81eef-12d3-4f2a-9b91-ccf2705685ad
205+
md"""The obtained solution is an independent set and its size is maximized."""
206+
207+
# ╔═╡ 0297893c-c978-4818-aae8-26e60d8c9e9e
208+
UnitDiskMapping.is_independent_set(petersen, mis_petersen)
209+
210+
# ╔═╡ 5ffe0e4f-bd2c-4d3e-98ca-61673a7e5230
211+
count(isone, mis_petersen)
212+
213+
# ╔═╡ 8c1d46e8-dc36-41bd-9d9b-5a72c380ef26
214+
md"The number printed should be consistent with the MIS size of the petersen graph."
215+
216+
# ╔═╡ Cell order:
217+
# ╟─f55dbf80-8425-11ee-2e7d-4d1ad4f693af
218+
# ╟─9017a42c-9791-4933-84a4-9ff509967323
219+
# ╟─f0e7c030-4e43-4356-a5bb-717a7f382a17
220+
# ╠═be011e30-74e6-49cd-b45a-288972dc5f18
221+
# ╠═31250cb9-6f3a-429a-975d-752cb7c07883
222+
# ╟─cb4a9655-6df2-46b3-8969-8b6f2db7c59a
223+
# ╟─956a5c3a-b8c6-4040-9553-3b4e2337b163
224+
# ╠═d858f57e-1706-4b73-bc23-53f7af073b0c
225+
# ╠═a3a86c62-ee6e-4a3b-99b3-c484de3b5220
226+
# ╠═e6170e72-0804-401e-b9e5-65b8ee7d7edb
227+
# ╟─625bdcf4-e37e-4bb8-bd1a-907cdcc5fe24
228+
# ╠═f9e57a6b-1186-407e-a8b1-cb8f31a17bd2
229+
# ╟─e64e7ca4-b297-4c74-8699-bec4b4fbb843
230+
# ╠═0a860597-0610-48f6-b1ee-711939712de4
231+
# ╟─eeae7074-ee21-44fc-9605-3555acb84cee
232+
# ╠═3fa6052b-74c2-453d-a473-68f4b3ca0490
233+
# ╟─942e8dfb-b89d-4f2d-b1db-f4636d4e5de6
234+
# ╟─766018fa-81bd-4c37-996a-0cf77b0909af
235+
# ╠═67fd2dd2-5add-4402-9618-c9b7c7bfe95b
236+
# ╟─aaee9dbc-5b9c-41b1-b0d4-35d2cac7c773
237+
# ╠═114e2c42-aaa3-470b-a267-e5a7c6b08607
238+
# ╟─e6fa2404-cbe9-4f9b-92a0-0d6fdb649c44
239+
# ╠═0142f661-0855-45b4-852a-78f560e98c67
240+
# ╟─fa046f3c-fd7d-4e91-b3f5-fc4591d3cae2
241+
# ╠═0cbcd2a6-b8ae-47ff-8541-963b9dae700a
242+
# ╟─4734dc0b-0770-4f84-8046-95a74104936f
243+
# ╟─0f27de9f-2e06-4d5e-b96f-b7c7fdadabca
244+
# ╠═fc968df0-832b-44c9-8335-381405b92199
245+
# ╟─29458d07-b2b2-49af-a696-d0cb0ad35481
246+
# ╟─fa4888b2-fc67-4285-8305-da655c42a898
247+
# ╠═e84102e8-d3f2-4f91-87be-dba8e81462fb
248+
# ╠═88ec52b3-73fd-4853-a69b-442f5fd2e8f7
249+
# ╠═5621bb2a-b1c6-4f0d-921e-980b2ce849d5
250+
# ╟─1fe6c679-2962-4c1b-8b12-4ceb77ed9e0f
251+
# ╠═ea379863-95dd-46dd-a0a3-0a564904476a
252+
# ╠═d405e7ec-50e3-446c-8d19-18f1a66c1e3b
253+
# ╟─409b03d1-384b-48d3-9010-8079cbf66dbf
254+
# ╠═a0e7da6b-3b71-43d4-a1da-f1bd953e4b50
255+
# ╟─4f1f0ca0-dd2a-4768-9b4e-80813c9bb544
256+
# ╠═bf97a268-cd96-4dbc-83c6-10eb1b03ddcc
257+
# ╟─2589f112-5de5-4c98-bcd1-138b6143cd30
258+
# ╠═1b946455-b152-4d6f-9968-7dc6e22d171a
259+
# ╟─4e7f7d9e-fae4-46d2-b95d-110d36b691d9
260+
# ╠═d0e49c1f-457d-4b61-ad0e-347afb029114
261+
# ╟─03d8adb3-0bf4-44e6-9b0a-fffc90410cfc
262+
# ╠═0d08cb1a-f7f3-4d63-bd70-78103db086b3
263+
# ╠═c27d8aed-c81f-4eb7-85bf-a4ed88c2537f
264+
# ╟─20f81eef-12d3-4f2a-9b91-ccf2705685ad
265+
# ╠═0297893c-c978-4818-aae8-26e60d8c9e9e
266+
# ╠═5ffe0e4f-bd2c-4d3e-98ca-61673a7e5230
267+
# ╟─8c1d46e8-dc36-41bd-9d9b-5a72c380ef26

0 commit comments

Comments
 (0)