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
# Open degrees of freedom is useful when the graph under consideration is an induced subgraph of another graph.
3
-
#The vertices connected to the rest part of the parent graph can not be summed over directly, which can be specified with the `openvertices` keyword argument in the graph problem constructor.
1
+
# # Open and fixed degrees of freedom
2
+
# Open degrees of freedom is useful when one want to get the marginal about certain degrees of freedom.
3
+
#When one specifies the `openvertices` keyword argument in [`solve`](@ref) function as a tuple of vertices, the output will be a tensor that can be indexed by these degrees of freedom.
4
4
# Let us use the maximum independent set problem on Petersen graph as an example.
5
5
#
6
6
using GenericTensorNetworks, Graphs
7
7
8
8
graph = Graphs.smallgraph(:petersen)
9
9
10
10
# The following code computes the MIS tropical tensor (reference to be added) with open vertices 1, 2 and 3.
11
-
problem =IndependentSet(graph; openvertices=[1,2,3])
11
+
problem =IndependentSet(graph; openvertices=[1,2,3]);
12
12
13
-
mis_tropical_tensor=solve(problem, SizeMax())
13
+
marginal=solve(problem, SizeMax())
14
14
15
15
# The return value is a rank-3 tensor, with its elements being the MIS sizes under different configuration of open vertices.
16
16
# For the maximum independent set problem, this tensor is also called the MIS tropical tensor, which can be useful in the MIS tropical tensor analysis (reference to be added).
17
+
18
+
# One can also specify the fixed degrees of freedom by providing the `fixedvertices` keyword argument as a `Dict`, which can be used to get conditioned probability.
19
+
# For example, we can use the following code to do the same calculation as using `openvertices`.
20
+
problem =IndependentSet(graph; fixedvertices=Dict(1=>0, 2=>0, 3=>0));
21
+
22
+
output =zeros(TropicalF64,2,2,2);
23
+
24
+
marginal_alternative =map(CartesianIndices((2,2,2))) do ci
25
+
problem.fixedvertices[1] = ci.I[1]-1
26
+
problem.fixedvertices[2] = ci.I[2]-1
27
+
problem.fixedvertices[3] = ci.I[3]-1
28
+
output[ci] =solve(problem, SizeMax())[]
29
+
end
30
+
31
+
# One can easily check this one also gets the correct marginal on vertices 1, 2 and 3.
32
+
# As a reminder, their computational hardness can be different, because the contraction order optimization program can optimize over open degrees of freedom.
0 commit comments