Documentation
¶
Overview ¶
Package gen contains generators for common kinds of formulas.
Package gen also supplies a random solver, which returns random results within a random period of time.
Index ¶
- func BinCycle(dst inter.Adder, n int)
- func HardRand3Cnf(dst inter.Adder, n int)
- func PartVar(i, k, n int) z.Lit
- func Partition(dst inter.Adder, n, k int)
- func Php(dst inter.Adder, P, H int)
- func Py2Triples(dst inter.Adder, n int)
- func PyTriples(dst inter.Adder, n, k int)
- func Rand3Cnf(dst inter.Adder, n, m int)
- func RandColor(dst inter.Adder, n, m, k int)
- func RandGraph(n, m int) [][]int
- func RandS(d time.Duration, res int) inter.S
- func RandSr(d time.Duration, res int, src rand.Source) inter.S
- func Seed(s int64)
- type RandCuber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HardRand3Cnf ¶
HardRand3Cnf generates a random 3cnf with n variables.
func Partition ¶
Partition adds constraints to dst stating that there exists a partition of n elements into k parts. Every model of the result is a partition with PartVar(i, k, n) true if and only if element i is in partition k.
func Php ¶
Php generates a pigeon hole problem asking whether or not P pigeons can be placed in H holes with 1 pigeon per hole.
func Py2Triples ¶
Py2Triples adds constraints to dst stating that there is a 2-partition of [1..n] such that no triple (a,b,c) appears in one partition with a^2 + b^2 = c^2.
func PyTriples ¶
PyTriples adds constraints stating there is no triple (i,j,k) s.t i^2 + j^2 = k^2 in some partition of a k-partition of [1..n]
func RandColor ¶
RandColor creates a formula asking if a random (simple) graph with n nodes and m edges can be colored with k colors. Every node must have a color and no 2 adjacent nodes may have the same color.
func RandGraph ¶
RandGraph creates a simple (undirected) random graph with n nodes and m edges. If m > n*(n-1)/2, RandGraph returns nil.
The result is in the form of an edge list, namely each node is idenitified by an integer in [0..n) and the edgelist for node i is result[i], which is a list of edges. There are no multi-edges, no self edges, and sampling is done without replacement. The number m is is the number of edges (a, b) such that a < b, the symmetric view of the graph is returned with 2*m edges symmetrified.
func RandS ¶
RandS creates an inter.S which just returns result to Solve() within a random period of time chosen from [0..d). The result may be specified ahead of time, however if the result is 0, then a random value from {-1,1} is chosen.
GoSolve() works as usual.
other inter.S methods are just stubs with default values.
This is useful for testing applications using inter.S