diff --git a/Project.toml b/Project.toml index c7690b6..06f94f1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "UnitDiskMapping" uuid = "1b61a8d9-79ed-4491-8266-ef37f39e1727" authors = ["QuEra Computing Inc."] -version = "0.4.0" +version = "0.5.0" [deps] Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" @@ -16,7 +16,7 @@ ProblemReductionsExt = "ProblemReductions" [compat] Graphs = "1.6" LuxorGraphPlot = "0.5" -ProblemReductions = "0.1.1" +ProblemReductions = "0.2" julia = "1" [extras] diff --git a/README.md b/README.md index f8a9298..208a120 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,9 @@   package for reducing a generic maximum (weighted) independent set problem, quadratic unconstrained binary optimization (QUBO) problem or integer factorization problem to a maximum independent set problem on a unit disk grid graph (or hardcore lattice gas in physics), which can then be naturally encoded in neutral-atom quantum computers. To install UnitDiskMapping, please open - Julia's interactive session (known as REPL) and press the ] key in the REPL to use the package mode, and then type the commands below. + Julia's interactive session (known as REPL) and press the ] key in the REPL to use the package mode, and then type the command below:

-For installing the current master branch, please type: - -```julia -pkg> add https://github.com/QuEraComputing/UnitDiskMapping.jl.git -``` - -For stable release (not yet ready): - ```julia pkg> add UnitDiskMapping ``` diff --git a/notebooks/Project.toml b/notebooks/Project.toml index 2c5bcd3..d6eb186 100644 --- a/notebooks/Project.toml +++ b/notebooks/Project.toml @@ -9,12 +9,12 @@ Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" UnitDiskMapping = "1b61a8d9-79ed-4491-8266-ef37f39e1727" [compat] -GenericTensorNetworks = "2" +GenericTensorNetworks = "3" Graphs = "1.6" LinearAlgebra = "1" LuxorGraphPlot = "0.5" -PlutoSliderServer = "0.3" +PlutoSliderServer = "0.3, 0.4" PlutoUI = "0.7" Revise = "3" -UnitDiskMapping = "0.4" +UnitDiskMapping = "0.4, 0.5" julia = "1" diff --git a/notebooks/tutorial.jl b/notebooks/tutorial.jl index f54ed28..549c37c 100644 --- a/notebooks/tutorial.jl +++ b/notebooks/tutorial.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.19.42 +# v0.20.3 using Markdown using InteractiveUtils diff --git a/notebooks/unweighted.jl b/notebooks/unweighted.jl index 6fc1613..3e678f9 100644 --- a/notebooks/unweighted.jl +++ b/notebooks/unweighted.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.19.42 +# v0.20.3 using Markdown using InteractiveUtils @@ -46,6 +46,9 @@ using UnitDiskMapping, Graphs # for mapping graphs to a King's subgraph (KSG) # ╔═╡ 31250cb9-6f3a-429a-975d-752cb7c07883 using GenericTensorNetworks # for solving the maximum independent sets +# ╔═╡ e9a94e5a-274f-4740-ac05-bd3bb613df4d +using GenericTensorNetworks.ProblemReductions + # ╔═╡ 9017a42c-9791-4933-84a4-9ff509967323 md""" # Unweighted KSG reduction of the independent set problem @@ -213,6 +216,48 @@ count(isone, mis_petersen) # ╔═╡ 8c1d46e8-dc36-41bd-9d9b-5a72c380ef26 md"The number printed should be consistent with the MIS size of the petersen graph." +# ╔═╡ fba5edd7-e5b7-4631-94cc-0c49240917ff +md""" +## Extension: ProblemReductions +Unit-disk mapping implements the unified interface for reduction in package [ProblemReductions.jl](https://github.com/GiggleLiu/ProblemReductions.jl) as an extension. +""" + +# ╔═╡ 0f12b761-fb74-455b-9123-6d1b720aaf52 +md""" +Step 1: perform the problem reduction. +""" + +# ╔═╡ 1113d5b9-8ebe-46fd-b24e-03e5fbc79435 +source_problem = IndependentSet(smallgraph(:petersen)) + +# ╔═╡ 333a8123-1683-491e-8891-83987bad16eb +# the Independent set problem with 2D GridGraph topology, unweighted. +target_problem_type = IndependentSet{ProblemReductions.GridGraph{2}, Int, UnitWeight} + +# ╔═╡ 339fd327-a594-4460-9e00-8b3304aa0a78 +# the result not only contains the target problem, but also the intermediate information +reduction_result = reduceto(target_problem_type, source_problem) + +# ╔═╡ 0e2f9caa-d84e-411f-ad5d-64c10cdaa028 +target_problem(reduction_result) + +# ╔═╡ 077045b9-3b88-4c41-a88c-354b8b30c31f +md"Step 2: solve the target problem." + +# ╔═╡ d7562423-06cd-4949-a1fd-92d8e5c31280 +# get single maximum independent set of the mapped problem +config = solve(GenericTensorNetwork(target_problem(reduction_result)), SingleConfigMax())[].c.data + +# ╔═╡ 51a9d53b-b92f-41c4-a60e-d8ceedd3fead +md"Step 3. Extract the solution back" + +# ╔═╡ 6ad557b1-04d3-4c7e-a350-20408c09b960 +extracted_config = extract_solution(reduction_result, config) + +# ╔═╡ f685ed77-151f-4778-8342-112903255932 +# finally, we check the validity of the solution. +UnitDiskMapping.is_independent_set(source_problem.graph, extracted_config) + # ╔═╡ Cell order: # ╟─f55dbf80-8425-11ee-2e7d-4d1ad4f693af # ╟─9017a42c-9791-4933-84a4-9ff509967323 @@ -265,3 +310,15 @@ md"The number printed should be consistent with the MIS size of the petersen gra # ╠═0297893c-c978-4818-aae8-26e60d8c9e9e # ╠═5ffe0e4f-bd2c-4d3e-98ca-61673a7e5230 # ╟─8c1d46e8-dc36-41bd-9d9b-5a72c380ef26 +# ╟─fba5edd7-e5b7-4631-94cc-0c49240917ff +# ╠═e9a94e5a-274f-4740-ac05-bd3bb613df4d +# ╟─0f12b761-fb74-455b-9123-6d1b720aaf52 +# ╠═1113d5b9-8ebe-46fd-b24e-03e5fbc79435 +# ╠═333a8123-1683-491e-8891-83987bad16eb +# ╠═339fd327-a594-4460-9e00-8b3304aa0a78 +# ╠═0e2f9caa-d84e-411f-ad5d-64c10cdaa028 +# ╟─077045b9-3b88-4c41-a88c-354b8b30c31f +# ╠═d7562423-06cd-4949-a1fd-92d8e5c31280 +# ╟─51a9d53b-b92f-41c4-a60e-d8ceedd3fead +# ╠═6ad557b1-04d3-4c7e-a350-20408c09b960 +# ╠═f685ed77-151f-4778-8342-112903255932