Skip to content

Commit 51c1e03

Browse files
committed
fix docs
1 parent 8bbcb80 commit 51c1e03

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed

docs/src/performancetips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Other optimizers include
2323
One can type `?TreeSA` in a Julia REPL for more information about how to configure the hyper-parameters of `TreeSA` method.
2424
`simplifier` keyword argument is not so important, it is a preprocessing routine to improve the searching speed of the `optimizer`.
2525

26-
The returned instance `problem` contains a field `code` that specifies the tensor network contraction order. For an independence problem, 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``.
26+
The returned instance `problem` contains a field `code` that specifies the tensor network contraction order. For an independent set problem, 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``.
2727
One can check the time, space and read-write complexity with the following function.
2828

2929
```julia

examples/IndependentSet.jl

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,40 @@ locations = [[rot15(0.0, 1.0, i) for i=0:4]..., [rot15(0.0, 0.6, i) for i=0:4]..
1616
show_graph(graph; locs=locations)
1717

1818
# ## Tensor network representation
19-
# Type [`IndependentSet`](@ref) can be used for constructing the tensor network with optimized contraction order for solving an independent set problem.
20-
# we map a vertex ``i\in V`` to a label ``s_i \in \{0, 1\}`` of dimension 2,
21-
# where we use 0 (1) to denote a vertex is absent (present) in the set.
19+
# Let ``G=(V,E)`` be the target graph that we want to solve.
20+
# The tensor network representation map a vertex ``i\in V`` to a label ``s_i \in \{0, 1\}`` of dimension ``2`` in a tensor network, where we use ``0`` (``1``) to denote a vertex is absent (present) in the set.
2221
# For each label ``s_i``, we defined a parametrized rank-one vertex tensor ``W(x_i)`` as
23-
# ```math
24-
# W(x_i)_{s_i} = \left(\begin{matrix}
25-
# 1 \\
26-
# x_i
27-
# \end{matrix}\right)_{s_i}
28-
# ```
29-
# We use subscripts to index tensor elements, e.g.``W(x_i)_0=1`` is the first element associated
30-
# with ``s_i=0`` and ``W(x_i)_1=x_i`` is the second element associated with ``s_i=1``.
22+
# \begin{equation}
23+
# W(x_i) = \left(\begin{matrix}
24+
# 1 \\
25+
# x_i
26+
# \end{matrix}\right).
27+
# \end{equation}
28+
# We use subscripts to index tensor elements, e.g. ``W(x_i)_0=1`` is the first element associated with ``s_i=0`` and ``W(x_i)_1=x_i`` is the second element associated with ``s_i=1``.
3129
# Similarly, on each edge ``(u, v)``, we define a matrix ``B`` indexed by ``s_u`` and ``s_v`` as
32-
# ```math
33-
# B_{s_i s_j} = \left(\begin{matrix}
34-
# 1 & 1\\
35-
# 1 & 0
36-
# \end{matrix}\right)_{s_is_j}
37-
# ```
38-
# Let us contruct the problem instance with optimized tensor network contraction order as bellow.
30+
# \begin{equation}
31+
# \qquad \quad
32+
# B = \left(\begin{matrix}
33+
# 1 & 1\\
34+
# 1 & 0
35+
# \end{matrix}\right). \label{eq:edgetensor}
36+
# \end{equation}
37+
38+
# We can use [`IndependentSet`](@ref) to construct a tensor network
39+
# corresponding to the independent set problem on our target graph.
3940
problem = IndependentSet(graph; optimizer=TreeSA());
4041

41-
# In the input arguments of [`IndependentSet`](@ref), the `optimizer` is for optimizing the contraction orders.
42-
# Here we use the local search based optimizer `TreeSA`.
43-
# The returned instance `problem` contains a field `code` that specifies the tensor network contraction order.
42+
# Key word argument `optimizer` specifies the contraction order optimizer of the tensor network.
43+
# Here we use the local search based optimizer [`TreeSA`](@ref).
44+
# The return value `problem` contains a field `code` that specifies the tensor network and its contraction order.
4445
# The optimal contraction time and space complexity of an independent set problem is ``2^{{\rm tw}(G)}``,
4546
# where ``{\rm tw(G)}`` is the [tree-width](https://en.wikipedia.org/wiki/Treewidth) of ``G``.
4647
# One can check the time, space and read-write complexity with the following function.
4748

4849
timespacereadwrite_complexity(problem)
4950

50-
# The return values are `log2` of the the number of iterations, the number elements in the max tensor and the number of read-write operations to tensor elements.
51-
# For more information about the performance, please check the [Performance Tips](@ref).
52-
51+
# The return values are `log2` of the the number of iterations, the number elements in the tensor with maximum size during contraction and the number of tensor element read-write operations.
52+
# For more information about how to improve the contraction order, please check the [Performance Tips](@ref).
5353

5454
# ## Solving properties
5555

@@ -64,12 +64,12 @@ count_all_independent_sets = solve(problem, CountingAll())[]
6464
count_max2_independent_sets = solve(problem, CountingMax(2))[]
6565

6666
# ##### independence polynomial
67-
# The graph polynomial defined for the independence problem is known as the independence polynomial.
67+
# The graph polynomial for the independent set problem is known as the independence polynomial.
6868
# ```math
6969
# I(G, x) = \sum_{k=0}^{\alpha(G)} a_k x^k,
7070
# ```
7171
# where ``\alpha(G)`` is the maximum independent set size,
72-
# ``a_k`` is the number of independent sets of size ``k`` in graph ``G=(V,E)``.
72+
# ``a_k`` is the number of independent sets of size ``k``.
7373
# The total number of independent sets is thus equal to ``I(G, 1)``.
7474
# There are 3 methods to compute a graph polynomial, `:finitefield`, `:fft` and `:polynomial`.
7575
# These methods are introduced in the docstring of [`GraphPolynomial`](@ref).
@@ -80,7 +80,7 @@ independence_polynomial = solve(problem, GraphPolynomial(; method=:finitefield))
8080
# There are two approaches to find one of the best solution.
8181
# The unbounded (default) version uses [`ConfigSampler`](@ref) to sample one of the best solutions directly.
8282
# The bounded version uses the binary gradient back-propagation (see our paper) to compute the gradients.
83-
# It requires caching intermediate states, but is often faster on CPU because it can use [`TropicalGEMM`](https://github.com/TensorBFS/TropicalGEMM.jl).
83+
# It requires caching intermediate states, but is often faster (on CPU) because it can use [`TropicalGEMM`](https://github.com/TensorBFS/TropicalGEMM.jl) (see [Performance Tips](@ref)).
8484
max_config = solve(problem, SingleConfigMax(; bounded=false))[]
8585

8686
# The return value contains a bit string, and one should read this bit string from left to right.
@@ -132,14 +132,14 @@ max_config_weighted = solve(problem, SingleConfigMax())[]
132132
show_graph(graph; locs=locations, vertex_colors=
133133
[iszero(max_config_weighted.c.data[i]) ? "white" : "red" for i=1:nv(graph)])
134134

135-
# The following code computes the MIS tropical tensor (reference to be added) with open vertices 1 and 2.
135+
# The following code computes the MIS tropical tensor (reference to be added) with open vertices 1, 2 and 3.
136136
problem = IndependentSet(graph; openvertices=[1,2,3])
137137

138138
mis_tropical_tensor = solve(problem, SizeMax())
139139

140140
# The MIS tropical tensor shows the MIS size under different configuration of open vertices.
141141
# It is useful in MIS tropical tensor analysis.
142-
# One can compatify this MIS-Tropical tensor by typing
142+
# One can compatify (reference to be added) this MIS-Tropical tensor by typing
143143

144144
mis_compactify!(mis_tropical_tensor)
145145

examples/Matching.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ max_matching = solve(problem, SizeMax())[]
5454
# The largest number of matching is 5, which means we have a perfect matching (vertices are all paired).
5555

5656
# ##### matching polynomial
57-
# The graph polynomial defined for the independence problem is known as the matching polynomial.
57+
# The graph polynomial defined for the matching problem is known as the matching polynomial.
5858
# Here, we adopt the first definition in the [wiki page](https://en.wikipedia.org/wiki/Matching_polynomial).
5959
# ```math
6060
# M(G, x) = \sum\limits_{k=1}^{|V|/2} c_k x^k,

examples/PaintShop.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ show_graph(graph; locs=locations, texts=string.(sequence), edge_colors=
6464
problem = PaintShop(sequence);
6565

6666
# ### Counting properties
67-
# ##### maximal independence polynomial
67+
# ##### graph polynomial
6868
# The graph polynomial defined for the maximal independent set problem is
6969
# ```math
7070
# I_{\rm max}(G, x) = \sum_{k=0}^{\alpha(G)} b_k x^k,

test/interfaces.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using GraphTensorNetworks
22
using Graphs, Test
33

4-
@testset "independence problem" begin
4+
@testset "independent set problem" begin
55
g = Graphs.smallgraph("petersen")
66
for optimizer in (GreedyMethod(), TreeSA(ntrials=1))
77
gp = IndependentSet(g; optimizer=optimizer)

0 commit comments

Comments
 (0)