Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Solver ¶
type Solver struct { // Trace, if set to true, will output trace debugging information // via the standard library `log` package. If true, Tracer must also // be set to a non-nil value. The easiest implmentation is a logger // created with log.NewLogger. Trace bool Tracer Tracer // contains filtered or unexported fields }
Solver is a SAT solver.
Solver must be created using New(). You cannot use a solver that is manually allocated.
Add clauses or a formula using the AddClause and AddFormula functions, respectively. These must be called prior to calling Solve().
Solve() will attempt to solve the problem, returning false on unsatisfiability and true on satisfiability. A sufficiently complex SAT problem may take a very long time (this solver currently doesn't allow time budgeting).
Assignments() can be called after Solve() returns true to get the assigned values for a solution.
func (*Solver) AddClause ¶
AddClause adds a Clause to solve to the solver.
This can only be called before Solve() is called.
func (*Solver) AddFormula ¶
AddFormula adds the given formula to the solver.
This can only be called before Solve() is called.
func (*Solver) Assignments ¶
Assignments returns the assigned variables and their value (true or false). This is only valid if Solve returned true, in which case this is the solution.
type Tracer ¶
type Tracer interface {
Printf(format string, v ...interface{})
}
Tracer is the implementation for a tracer to use with Solver.
The Go stdlib Logger implements this interface. However, this interface lets you slide in anything that adheres to this making it simple to use a different log package.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
Package cnf contains a representation of a boolean formula in conjunctive normal form.
|
Package cnf contains a representation of a boolean formula in conjunctive normal form. |
Package dimacs parses the DIMACS CNF format.
|
Package dimacs parses the DIMACS CNF format. |