You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/performancetips.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,9 +191,9 @@ The graphs in all benchmarks are random three-regular graphs, which have treewid
191
191
Panel (a) shows the time and space complexity of tensor network contraction fordifferent graph sizes. The contraction order is obtained using the `TreeSA` algorithm that implementedin [OMEinsumContractionOrders](https://github.com/TensorBFS/OMEinsumContractionOrders.jl). If we assume our contraction-order finding program has found the optimal treewidth, which is very likely to be true, the space complexity is the same as the treewidth of the problem graph.
192
192
Slicing technique has been used forgraphs with space complexity greater than ``2^{27}`` (above the yellow dashed line) to fit the computation into a 16GB memory. One can see that all the computation timesin panels (b), (c), and (d) have a strong correlation with the predicted time and space complexity.
193
193
While in panel (d), the computation time of configuration enumeration also strongly correlates with other factors such as the configuration space size.
194
-
Among these benchmarks, computational tasks with data types real numbers, complex numbers, or [Tropical](@ref) numbers (CPU only) can utilize fast basic linear algebra subprograms (BLAS) functions. These tasks usually compute much faster than ones with other element types in the same category.
194
+
Among these benchmarks, computational tasks with data types real numbers, complex numbers, or [`Tropical`](@ref) numbers (CPU only) can utilize fast basic linear algebra subprograms (BLAS) functions. These tasks usually compute much faster than ones with other element types in the same category.
195
195
Immutable data types with no reference to other values can be compiled to GPU devices that run much faster than CPUs in all cases when the problem scale is big enough.
196
-
These data types do not include those defined in [Polynomial](@ref), [ConfigEnumerator](@ref), [ExtendedTropical](@ref) and [SumProductTree](@ref) or a data type containing them as a part.
196
+
These data types do not include those defined in [`Polynomial`](@ref), [`ConfigEnumerator`](@ref), [`ExtendedTropical`](@ref) and [`SumProductTree`](@ref) or a data type containing them as a part.
197
197
In panel (c), one can see the Fourier transformation-based method is the fastest in computing the independence polynomial,
198
198
but it may suffer from round-off errors. The finite field (GF(p)) approach is the only method that does not have round-off errors and can be run on a GPU.
199
199
In panel (d), one can see the technique to bound the enumeration space (see paper) improves the performance formore than one order of magnitudein enumerating the MISs. The bounding technique can also reduce the memory usage significantly, without which the largest computable graph size is only ``\sim150`` on a device with 32GB main memory.
# It is highly recommended to read the [Independent set problem](@ref) chapter before reading this one.
5
5
6
6
# ## Problem definition
7
-
# In graph theory, a [cut](https://en.wikipedia.org/wiki/Cut_(graph_theory)) is a partition of the vertices of a graph into two disjoint subsets.
8
-
# It is closely related to the [spin-glass](https://en.wikipedia.org/wiki/Spin_glass) problem in physics.
9
-
# Finding the maximum cut is NP-Hard, where a maximum cut is a cut whose size is at least the size of any other cut,
7
+
# Let ``G=(V, E)`` be a graph, the [spin-glass](https://en.wikipedia.org/wiki/Spin_glass) problem in physics is characterized by the following energy function
# where ``h_i`` is an onsite energy term associated with spin ``s_i \in \{0, 1\}``, and ``J_{ij}`` is the coupling strength between spins ``s_i`` and ``s_j``.
12
+
#
13
+
# The spin glass problem very close related to the cutting problem in graph theory.
14
+
# A [cut](https://en.wikipedia.org/wiki/Cut_(graph_theory)) is a partition of the vertices of a graph into two disjoint subsets.
15
+
# Finding the maximum cut (the spin glass maximum energy) is NP-Hard, where a maximum cut is a cut whose size is at least the size of any other cut,
10
16
# where the size of a cut is the number of edges (or the sum of weights on edges) crossing the cut.
11
17
12
18
using GenericTensorNetworks, Graphs
13
19
14
-
# In the following, we are going to defined an cutting problem for the Petersen graph.
20
+
# In the following, we are going to defined an spin glass problem for the Petersen graph.
15
21
16
22
graph = Graphs.smallgraph(:petersen)
17
23
@@ -23,52 +29,52 @@ locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]..
23
29
show_graph(graph; locs=locations, format=:svg)
24
30
25
31
# ## Generic tensor network representation
26
-
# We define the cutting problem as
27
-
problem =MaxCut(graph);
32
+
# We define the spin glass problem as
33
+
problem =SpinGlass(graph);
28
34
29
35
# ### Theory (can skip)
30
36
#
31
37
# For a vertex ``v\in V``, we define a boolean degree of freedom ``s_v\in\{0, 1\}``.
32
-
# Then the maximum cutting problem can be encoded to tensor networks by mapping an edge ``(i,j)\in E`` to an edge matrix labelled by ``s_is_j``
38
+
# Then the spin glass problem can be encoded to tensor networks by mapping an edge ``(i,j)\in E`` to an edge matrix labelled by ``s_is_j``
33
39
# ```math
34
40
# B(x_{\langle i, j\rangle}) = \left(\begin{matrix}
35
41
# 1 & x_{\langle i, j\rangle}^{w_{\langle i,j \rangle}}\\
36
42
# x_{\langle i, j\rangle}^{w_{\langle i,j \rangle}} & 1
37
43
# \end{matrix}\right),
38
44
# ```
39
-
# If and only if there is a cut on edge ``(i, j)``,
45
+
# If and only if the spin configuration is anti-parallel on edge ``(i, j)``,
40
46
# this tensor contributes a factor ``x_{\langle i, j\rangle}^{w_{\langle i,j \rangle}}``,
41
47
# where ``w_{\langle i,j\rangle}`` is the weight of this edge.
42
48
# Similar to other problems, we can define a polynomial about edges variables by setting ``x_{\langle i, j\rangle} = x``,
43
-
# where its k-th coefficient is two times the number of configurations of cut size k.
49
+
# where its k-th coefficient is two times the number of configurations with energy (cut size) k.
44
50
45
51
# Its contraction time space complexity is ``2^{{\rm tw}(G)}``, where ``{\rm tw(G)}`` is the [tree-width](https://en.wikipedia.org/wiki/Treewidth) of ``G``.
46
52
47
53
# ## Solving properties
48
-
# ### Maximum cut size ``\gamma(G)``
49
-
max_cut_size=solve(problem, SizeMax())[]
54
+
# ### Maximum energy ``E^*(G)``
55
+
Emax=solve(problem, SizeMax())[]
50
56
51
57
# ### Counting properties
52
58
# ##### graph polynomial
53
-
# The graph polynomial defined for the cutting problem is
59
+
# The graph polynomial defined for the spin glass problem is
54
60
# ```math
55
-
# C(G, x) = \sum_{k=0}^{\gamma(G)} c_k x^k,
61
+
# C(G, x) = \sum_{k=0}^{E^*(G)} c_k x^k,
56
62
# ```
57
63
# where ``\alpha(G)`` is the maximum independent set size,
58
-
# ``c_k/2`` is the number of cuts of size ``k`` in graph ``G=(V,E)``.
64
+
# ``c_k/2`` is the number of anti-parallel edges (cuts) of size ``k`` in graph ``G=(V,E)``.
59
65
# Since the variable ``x`` is defined on edges,
60
66
# the coefficients of the polynomial is the number of configurations having different number of anti-parallel edges.
The [spin glass](https://psychic-meme-f4d866f8.pages.github.io/dev/generated/SpinGlass.html) problem (or cutting problem).
9
+
10
+
Positional arguments
11
+
-------------------------------
12
+
* `graph` is the problem graph.
13
+
14
+
Keyword arguments
15
+
-------------------------------
16
+
* `edge_weights` are associated with the edges of the `graph`, also known as the coupling strengths in spin glasses.
17
+
* `vertex_weights` are associated with the vertices of the `graph`, also known the onsite energy term in spin glasses.
18
+
* `optimizer` and `simplifier` are for tensor network optimization, check [`optimize_code`](@ref) for details.
19
+
* `fixedvertices` is a dict to specify the values of degree of freedoms, where a value can be `0` (in one side of the cut) or `1` (in the other side of the cut).
20
+
* `openvertices` is a tuple of labels to specify the output tensor. Theses degree of freedoms will not be contracted.
0 commit comments