|
| 1 | +### A Pluto.jl notebook ### |
| 2 | +# v0.15.1 |
| 3 | + |
| 4 | +using Markdown |
| 5 | +using InteractiveUtils |
| 6 | + |
| 7 | +# ╔═╡ 54d71646-ffad-11eb-3866-5f1c0bc5d0bf |
| 8 | +begin |
| 9 | + using Pkg |
| 10 | + Pkg.activate(dirname(pwd())) |
| 11 | + using Revise, GraphTensorNetworks |
| 12 | +end |
| 13 | + |
| 14 | +# ╔═╡ 83fc0a3c-ef51-4d5c-9c46-baa645f80fd2 |
| 15 | +locs = [rand(2) for i=1:70]; |
| 16 | + |
| 17 | +# ╔═╡ 1522938d-d60b-4133-8625-5a09615a7b26 |
| 18 | +g = unitdisk_graph(locs, 0.2) |
| 19 | + |
| 20 | +# ╔═╡ 05ac5610-4a1d-4433-ba0d-1d13fd8a6733 |
| 21 | +vizconfig(g; locs=locs, unit=0.5) |
| 22 | + |
| 23 | +# ╔═╡ b6e916e2-7d43-4085-a3c8-5c57069e8384 |
| 24 | +gp = Independence(g; optmethod=:auto); |
| 25 | + |
| 26 | +# ╔═╡ 03840394-3a5b-4c24-8b52-15f7e400f900 |
| 27 | +timespace_complexity(gp) |
| 28 | + |
| 29 | +# ╔═╡ 11c71de9-caa9-40c6-84cb-a0f29d873805 |
| 30 | +results = solutions(gp, CountingTropical{Float64}; all=false) |
| 31 | + |
| 32 | +# ╔═╡ edfc5600-9a4a-4657-b165-8eb3e8540edf |
| 33 | +vizconfig(g; locs=locs, unit=0.5, config=results[].c.data) |
| 34 | + |
| 35 | +# ╔═╡ 3666f629-7a87-4b50-aaf1-cc128d598aaf |
| 36 | +md"## Different Algebras" |
| 37 | + |
| 38 | +# ╔═╡ 51f0f187-d14d-48ab-ab30-96e71d796959 |
| 39 | +md"There are commutative semiring algebras defined in the package. For each type, we have implemented two operations `+` and `*` and two special elements `zero` and `one` on it." |
| 40 | + |
| 41 | +# ╔═╡ a5b63d08-2917-4e9f-9c5c-b5f17181d2aa |
| 42 | +md"### Polynomials |
| 43 | +`Polynomial` type is defined in package [Polynomials.jl](https://github.com/JuliaMath/Polynomials.jl) |
| 44 | +" |
| 45 | + |
| 46 | +# ╔═╡ 0d3b2752-c800-43f3-b241-9c96084f1fc9 |
| 47 | +xp, yp = Polynomial([1.0, 2.0, 3.0]), Polynomial([2.0, 1.0]) |
| 48 | + |
| 49 | +# ╔═╡ e779a111-ba70-4350-88bc-2b94d11741c6 |
| 50 | +xp + yp |
| 51 | + |
| 52 | +# ╔═╡ 677895f4-be68-4565-97ca-6f4e31c56819 |
| 53 | +xp * yp |
| 54 | + |
| 55 | +# ╔═╡ e1bc2d30-919a-4675-a674-c82c534c4ccf |
| 56 | +zero(Polynomial{Float64,:x}) |
| 57 | + |
| 58 | +# ╔═╡ c560a001-8fbb-4fbb-94fc-c68cf5e67c1e |
| 59 | +one(Polynomial{Float64,:x}) |
| 60 | + |
| 61 | +# ╔═╡ ae3c308d-40cc-4cbe-ac37-f0f2cd0eecbe |
| 62 | +md"### Polynomial truncated to largest two orders" |
| 63 | + |
| 64 | +# ╔═╡ 69779c4f-b939-4d0c-8548-1dc31578949c |
| 65 | +xp2, yp2 = Max2Poly(2.0, 3.0, 2.0), Max2Poly(2.0, 1.0, 1.0) |
| 66 | + |
| 67 | +# ╔═╡ b7f7453f-445a-40e3-9639-1c93e5b257ff |
| 68 | +zero(Max2Poly{Float64,Float64}) |
| 69 | + |
| 70 | +# ╔═╡ 9da24765-b182-4f60-a318-d7a808e2872a |
| 71 | +one(Max2Poly{Float64,Float64}) |
| 72 | + |
| 73 | +# ╔═╡ 731012e5-257f-44e1-8888-16a6cbe50279 |
| 74 | +zero(Max2Poly{Float64,Float64}) |
| 75 | + |
| 76 | +# ╔═╡ 2761c355-2b10-4437-8496-a0c260bbac2c |
| 77 | +md"### Tropical algebra" |
| 78 | + |
| 79 | +# ╔═╡ 7c584a2c-ab29-4e04-971b-06aeeb61fd0f |
| 80 | +xt, yt = Tropical(2.0), Tropical(3.0) |
| 81 | + |
| 82 | +# ╔═╡ e5b166f4-7307-4712-8790-0eb914ff839c |
| 83 | +xt + yt # same as regular `max` |
| 84 | + |
| 85 | +# ╔═╡ 50dadd8b-e73f-461b-baa9-8e1c5052e7fd |
| 86 | +xt * yt # same as regular `+` |
| 87 | + |
| 88 | +# ╔═╡ ff6ffae0-dfd4-44ba-bcfc-02435ef4221a |
| 89 | +zero(Tropical{Float64}) |
| 90 | + |
| 91 | +# ╔═╡ ab5b237c-b4aa-4cc9-91ca-b51a3d3d9d0e |
| 92 | +one(Tropical{Float64}) |
| 93 | + |
| 94 | +# ╔═╡ ce303530-bbe8-43fc-add0-2481f78a2e9f |
| 95 | +md"### Tropical algebra with counting" |
| 96 | + |
| 97 | +# ╔═╡ aefff7b7-f372-4eba-b9c9-effbb547665e |
| 98 | +xct, yct = CountingTropical(2.0, 2.0), CountingTropical(3.0, 5.0) |
| 99 | + |
| 100 | +# ╔═╡ 585d7ccb-5f23-4dc0-a482-076721f0be27 |
| 101 | +xct + yct |
| 102 | + |
| 103 | +# ╔═╡ 82a2eee5-451e-4679-a11a-74a690c13817 |
| 104 | +xct * yct |
| 105 | + |
| 106 | +# ╔═╡ b26358f3-d752-4df3-9a50-526a91615796 |
| 107 | +zero(CountingTropical{Float64,Float64}) |
| 108 | + |
| 109 | +# ╔═╡ be5b52c5-787f-4521-b14a-25f54b439d79 |
| 110 | +one(CountingTropical{Float64,Float64}) |
| 111 | + |
| 112 | +# ╔═╡ 539503f4-68f5-4f83-918f-d21163e4df6f |
| 113 | +md"### Configuration and Set algebra" |
| 114 | + |
| 115 | +# ╔═╡ a77d1d41-3964-41cb-ad1a-71db411537ee |
| 116 | +md"Let us first define bit strings" |
| 117 | + |
| 118 | +# ╔═╡ 6fd32061-0a0c-46b7-9bcb-00736d372f8c |
| 119 | +bs1, bs2, bs3 = StaticBitVector([1,0,1,1,0]), StaticBitVector([0,0,0,1,1]), StaticBitVector([1,1,1,1,0]) |
| 120 | + |
| 121 | +# ╔═╡ 2a800fa6-4967-4d01-aac1-548f852e7cad |
| 122 | +cs1, cs2 = ConfigSampler(bs1), ConfigSampler(bs2) |
| 123 | + |
| 124 | +# ╔═╡ 74203e2b-b231-4a45-8d74-a3ee3299cad8 |
| 125 | +cs1 + cs2 |
| 126 | + |
| 127 | +# ╔═╡ 6392edb7-c86c-40e5-8dc1-cd3cbbf436c2 |
| 128 | +cs1 * cs2 |
| 129 | + |
| 130 | +# ╔═╡ 97b8e445-99b5-488e-9437-76618cf6321e |
| 131 | +zero(cs1) |
| 132 | + |
| 133 | +# ╔═╡ 07f2dff4-d9de-49a2-b8f4-e29b43df5e23 |
| 134 | +one(cs2) |
| 135 | + |
| 136 | +# ╔═╡ 31f866f8-9ad0-439d-8c08-29a27efd3948 |
| 137 | +ce1, ce2 = ConfigEnumerator([bs1, bs2]), ConfigEnumerator([bs3]) |
| 138 | + |
| 139 | +# ╔═╡ ee28ad87-479e-49e0-a534-6bfca71dfb96 |
| 140 | +ce1 + ce2 |
| 141 | + |
| 142 | +# ╔═╡ f783b71b-5b7e-457a-be66-015f0e602ea2 |
| 143 | +ce1 * ce2 |
| 144 | + |
| 145 | +# ╔═╡ 554cebaf-bbe8-4a02-905b-e4b508e0c064 |
| 146 | +zero(typeof(ce1)) |
| 147 | + |
| 148 | +# ╔═╡ 12619536-8ea4-465b-b60d-3230bfb7b570 |
| 149 | +one(typeof(ce2)) |
| 150 | + |
| 151 | +# ╔═╡ Cell order: |
| 152 | +# ╠═54d71646-ffad-11eb-3866-5f1c0bc5d0bf |
| 153 | +# ╠═83fc0a3c-ef51-4d5c-9c46-baa645f80fd2 |
| 154 | +# ╠═1522938d-d60b-4133-8625-5a09615a7b26 |
| 155 | +# ╠═05ac5610-4a1d-4433-ba0d-1d13fd8a6733 |
| 156 | +# ╠═b6e916e2-7d43-4085-a3c8-5c57069e8384 |
| 157 | +# ╠═03840394-3a5b-4c24-8b52-15f7e400f900 |
| 158 | +# ╠═11c71de9-caa9-40c6-84cb-a0f29d873805 |
| 159 | +# ╠═edfc5600-9a4a-4657-b165-8eb3e8540edf |
| 160 | +# ╟─3666f629-7a87-4b50-aaf1-cc128d598aaf |
| 161 | +# ╟─51f0f187-d14d-48ab-ab30-96e71d796959 |
| 162 | +# ╟─a5b63d08-2917-4e9f-9c5c-b5f17181d2aa |
| 163 | +# ╠═0d3b2752-c800-43f3-b241-9c96084f1fc9 |
| 164 | +# ╠═e779a111-ba70-4350-88bc-2b94d11741c6 |
| 165 | +# ╠═677895f4-be68-4565-97ca-6f4e31c56819 |
| 166 | +# ╠═e1bc2d30-919a-4675-a674-c82c534c4ccf |
| 167 | +# ╠═c560a001-8fbb-4fbb-94fc-c68cf5e67c1e |
| 168 | +# ╟─ae3c308d-40cc-4cbe-ac37-f0f2cd0eecbe |
| 169 | +# ╠═69779c4f-b939-4d0c-8548-1dc31578949c |
| 170 | +# ╠═b7f7453f-445a-40e3-9639-1c93e5b257ff |
| 171 | +# ╠═9da24765-b182-4f60-a318-d7a808e2872a |
| 172 | +# ╠═731012e5-257f-44e1-8888-16a6cbe50279 |
| 173 | +# ╟─2761c355-2b10-4437-8496-a0c260bbac2c |
| 174 | +# ╠═7c584a2c-ab29-4e04-971b-06aeeb61fd0f |
| 175 | +# ╠═e5b166f4-7307-4712-8790-0eb914ff839c |
| 176 | +# ╠═50dadd8b-e73f-461b-baa9-8e1c5052e7fd |
| 177 | +# ╠═ff6ffae0-dfd4-44ba-bcfc-02435ef4221a |
| 178 | +# ╠═ab5b237c-b4aa-4cc9-91ca-b51a3d3d9d0e |
| 179 | +# ╟─ce303530-bbe8-43fc-add0-2481f78a2e9f |
| 180 | +# ╠═aefff7b7-f372-4eba-b9c9-effbb547665e |
| 181 | +# ╠═585d7ccb-5f23-4dc0-a482-076721f0be27 |
| 182 | +# ╠═82a2eee5-451e-4679-a11a-74a690c13817 |
| 183 | +# ╠═b26358f3-d752-4df3-9a50-526a91615796 |
| 184 | +# ╠═be5b52c5-787f-4521-b14a-25f54b439d79 |
| 185 | +# ╟─539503f4-68f5-4f83-918f-d21163e4df6f |
| 186 | +# ╟─a77d1d41-3964-41cb-ad1a-71db411537ee |
| 187 | +# ╠═6fd32061-0a0c-46b7-9bcb-00736d372f8c |
| 188 | +# ╠═2a800fa6-4967-4d01-aac1-548f852e7cad |
| 189 | +# ╠═74203e2b-b231-4a45-8d74-a3ee3299cad8 |
| 190 | +# ╠═6392edb7-c86c-40e5-8dc1-cd3cbbf436c2 |
| 191 | +# ╠═97b8e445-99b5-488e-9437-76618cf6321e |
| 192 | +# ╠═07f2dff4-d9de-49a2-b8f4-e29b43df5e23 |
| 193 | +# ╠═31f866f8-9ad0-439d-8c08-29a27efd3948 |
| 194 | +# ╠═ee28ad87-479e-49e0-a534-6bfca71dfb96 |
| 195 | +# ╠═f783b71b-5b7e-457a-be66-015f0e602ea2 |
| 196 | +# ╠═554cebaf-bbe8-4a02-905b-e4b508e0c064 |
| 197 | +# ╠═12619536-8ea4-465b-b60d-3230bfb7b570 |
0 commit comments