@@ -3,55 +3,146 @@ export solve, SizeMax, CountingAll, CountingMax, GraphPolynomial, SingleConfigMa
33abstract type AbstractProperty end
44_support_weight (:: AbstractProperty ) = false
55
6+ """
7+ SizeMax <: AbstractProperty
8+ SizeMax()
9+
10+ The maximum independent set size.
11+
12+ * The corresponding tensor element type is [`Tropical`](@ref).
13+ * It is compatible with weighted graph problems.
14+ * BLAS (on CPU) and GPU are supported,
15+ """
616struct SizeMax <: AbstractProperty end
717_support_weight (:: SizeMax ) = true
818
19+ """
20+ CountingAll <: AbstractProperty
21+ CountingAll()
22+
23+ Counting the total number of sets. e.g. for [`Independence`](@ref) problem, it counts the independent sets.
24+
25+ * The corresponding tensor element type is [`Base.Real`](@ref).
26+ * The weights on graph does not have effect.
27+ * BLAS (GPU and CPU) and GPU are supported,
28+ """
929struct CountingAll <: AbstractProperty end
1030_support_weight (:: CountingAll ) = true
1131
32+ """
33+ CountingMax{K} <: AbstractProperty
34+ CountingMax(K=1)
35+
36+ Counting the number of sets with `K` largest size. e.g. for [`Independence`](@ref) problem,
37+ it counts independent sets of size ``\\ alpha(G), \\ alpha(G)-1, \\ ldots, \\ alpha(G)-K+1``.
38+
39+ * The corresponding tensor element type is [`CountingTropical`](@ref) for `K == 1`, and [`TruncatedPoly{K}`](@ref) for `K > 1`.
40+ * Weighted graph problems is only supported for `K == 1`.
41+ * GPU is supported,
42+ """
1243struct CountingMax{K} <: AbstractProperty end
1344CountingMax (K:: Int = 1 ) = CountingMax {K} ()
1445max_k (:: CountingMax{K} ) where K = K
1546_support_weight (:: CountingMax{1} ) = true
1647
48+ """
49+ GraphPolynomial{METHOD} <: AbstractProperty
50+ GraphPolynomial(; method=:finitefield, kwargs...)
51+
52+ Compute the graph polynomial, e.g. for [`Independence`](@ref) problem, it is the independence polynomial.
53+ The `METHOD` type parameter can be one of the following symbols
54+
55+ * `:finitefield`, it uses finite field algebra to fit the polynomial.
56+ * The corresponding tensor element type is [`Mods.Mod`](@ref),
57+ * It does not have round-off error,
58+ * GPU is supported,
59+ * It accepts keyword arguments `maxorder` (optional, e.g. the MIS size in the [`Independence`](@ref) problem).
60+ * `:polynomial`, the program uses polynomial numbers to solve the polynomial directly.
61+ * The corresponding tensor element type is [`Polynomials.Polynomial`](@ref).
62+ * It might have small round-off error depending on the data type for storing the counting.
63+ * It has memory overhead that linear to the graph size.
64+ * `:fft`,
65+ * The corresponding tensor element type is [`Base.Complex`](@ref).
66+ * It has (controllable) round-off error.
67+ * BLAS and GPU are supported.
68+ * It accepts keyword arguments `maxorder` (optional) and `r`,
69+ if `r > 1`, one has better precision for coefficients of large order, if `r < 1`,
70+ one has better precision for coefficients of small order.
71+
72+ Graph polynomials are not defined for weighted graph problems.
73+ """
1774struct GraphPolynomial{METHOD} <: AbstractProperty
1875 kwargs
1976end
2077GraphPolynomial (; method:: Symbol = :finitefield , kwargs... ) = GraphPolynomial {method} (kwargs)
2178graph_polynomial_method (:: GraphPolynomial{METHOD} ) where METHOD = METHOD
2279
80+ """
81+ SingleConfigMax{BOUNDED} <: AbstractProperty
82+ SingleConfigMax(; bounded=false)
83+
84+ Finding single best solution, e.g. for [`Independence`](@ref) problem, it is one of the maximum independent sets.
85+
86+ * The corresponding data type is [`CountingTropical{Float64,<:ConfigSampler}`](@ref) if `BOUNDED` is `true`, [`Tropical`](@ref) otherwise.
87+ * Weighted graph problems is supported.
88+ * GPU is supported,
89+ """
2390struct SingleConfigMax{BOUNDED} <: AbstractProperty end
2491SingleConfigMax (; bounded:: Bool = false ) = SingleConfigMax {bounded} ()
2592_support_weight (:: SingleConfigMax ) = true
2693
94+ """
95+ ConfigsAll <:AbstractProperty
96+ ConfigsAll()
97+
98+ Find all valid configurations, e.g. for [`Independence`](@ref) problem, it is finding all independent sets.
99+
100+ * The corresponding data type is [`ConfigEnumerator`](@ref).
101+ * Weights do not take effect.
102+ """
27103struct ConfigsAll <: AbstractProperty end
28104_support_weight (:: ConfigsAll ) = true
29105
106+ """
107+ ConfigsMax{K, BOUNDED} <:AbstractProperty
108+ ConfigsMax(K=1; bounded=true)
109+
110+ Find configurations with largest sizes, e.g. for [`Independence`](@ref) problem,
111+ it is finding all independent sets of sizes ``\\ alpha(G), \\ alpha(G)-1, \\ ldots, \\ alpha(G)-K+1``.
112+
113+ * The corresponding data type is [`CountingTropical{Float64,<:ConfigEnumerator}`](@ref) for `K == 1` and [`TruncatedPoly{K,<:ConfigEnumerator}`] for `K > 1`.
114+ * Weighted graph problems is only supported for `K == 1`.
115+ """
30116struct ConfigsMax{K, BOUNDED} <: AbstractProperty end
31117ConfigsMax (K:: Int = 1 ; bounded:: Bool = true ) = ConfigsMax {K,bounded} ()
32118max_k (:: ConfigsMax{K} ) where K = K
33119_support_weight (:: ConfigsMax{1} ) = true
34120
35121"""
36- solve(problem, task ; usecuda=false)
122+ solve(problem, property ; usecuda=false, T=Float64 )
37123
124+ Solving a certain property of a graph problem.
125+
126+ Positional Arguments
127+ ---------------------------
38128* `problem` is the graph problem with tensor network information,
39- * `task` is string specifying the task. Using the maximum independent set problem as an example, it can be one of
40- * "size max", the maximum independent set size,
41- * "counting sum", total number of independent sets,
42- * "counting max", the dengeneracy of maximum independent sets (MIS),
43- * "counting max2", the dengeneracy of MIS and MIS-1,
44- * "counting all", independence polynomial, the polynomial number approach,
45- * "counting all (fft)", independence polynomial, the fourier transformation approach,
46- * "counting all (finitefield)", independence polynomial, the finite field approach,
47- * "config max", one of the maximum independent set,
48- * "config max (bounded)", one of the maximum independent set, the bounded version,
49- * "configs max", all MIS configurations,
50- * "configs max2", all MIS configurations and MIS-1 configurations,
51- * "configs all", all IS configurations,
52- * "configs max (bounded)", all MIS configurations, the bounded approach (much faster),
53- * "configs max2 (bounded)", all MIS and MIS-1 configurations, the bounded approach (much faster),
54- * "configs max3 (bounded)", all MIS, MIS-1 and MIS-2 configurations, the bounded approach (much faster),
129+ * `property` is string specifying the task. Using the maximum independent set problem as an example, it can be one of
130+
131+ * [`SizeMax`](@ref) for finding maximum configuration size,
132+
133+ * [`CountingMax`](@ref) for counting configurations with top `K` sizes,
134+ * [`CountingAll`](@ref) for counting all configurations,
135+ * [`GraphPolynomial`](@ref) for evaluating the graph polynomial,
136+
137+ * [`SingleConfigMax`](@ref) for finding one maximum configuration,
138+ * [`ConfigsMax`](@ref) for enumerating configurations with top `K` sizes,
139+ * [`ConfigsAll`](@ref) for enumerating all configurations,
140+
141+
142+ Keyword arguments
143+ -------------------------------------
144+ * `usecuda` is a switch to use CUDA (if possible), user need to call statement `using CUDA` before turning on this switch.
145+ * `T` is the "base" element type, sometimes can be used to reduce the memory cost.
55146"""
56147function solve (gp:: GraphProblem , property:: AbstractProperty ; T= Float64, usecuda= false )
57148 if ! _support_weight (property) && _has_weight (gp)
@@ -78,7 +169,7 @@ function solve(gp::GraphProblem, property::AbstractProperty; T=Float64, usecuda=
78169 elseif property isa (ConfigsMax{K, false } where K)
79170 return solutions (gp, TruncatedPoly{max_k (property),T,T}; all= true , usecuda= usecuda)
80171 elseif property isa ConfigsAll
81- return solutions (gp, Polynomial{T, :x } ; all= true , usecuda= usecuda)
172+ return solutions (gp, Real ; all= true , usecuda= usecuda)
82173 elseif property isa SingleConfigMax{true }
83174 return best_solutions (gp; all= false , usecuda= usecuda)
84175 elseif property isa ConfigsMax{1 ,true }
0 commit comments