Documentation
¶
Overview ¶
The solver package contains the BaseCDCLSolver
Index ¶
- func ConstructBaseClause(d types.Disjunction, learnt bool) types.Clause
- func ConstructMapClause(d types.Disjunction, learnt bool) types.Clause
- func ResolveBaseClause(d1, d2 types.Disjunction, lit types.Literal, atomCount uint) types.Clause
- func ResolveMapClause(d1, d2 types.Disjunction, lit types.Literal, atomCount uint) types.Clause
- type BaseCDCLSolver
- func (solver *BaseCDCLSolver) AnalyseConflict(clause types.Clause) (types.Clause, error)
- func (solver *BaseCDCLSolver) Decide(clause types.Clause) error
- func (solver *BaseCDCLSolver) ResolveConflict(clause types.Clause) (err error)
- func (solver BaseCDCLSolver) Solve() (types.Solution, error)
- func (solver *BaseCDCLSolver) UIP(lit types.Literal, clause types.Clause) bool
- func (solver *BaseCDCLSolver) UnitPropagate(clause types.Clause) error
- type BaseClause
- func (c BaseClause) Apply(l types.Literal) types.Clause
- func (c BaseClause) Contains(l types.Literal) bool
- func (c BaseClause) Disjunction() types.Disjunction
- func (c BaseClause) IsLearnt() bool
- func (c BaseClause) IsSolved() bool
- func (c BaseClause) Original() types.Disjunction
- func (c BaseClause) Reset() types.Clause
- func (c BaseClause) Type() types.ClauseType
- func (c BaseClause) Undo(l types.Literal) types.Clause
- type BaseFormula
- func (f BaseFormula) Assign(l types.Literal) types.Formula
- func (f BaseFormula) Learn(c types.Clause) types.Formula
- func (f BaseFormula) NextClause() types.Clause
- func (f BaseFormula) Print() string
- func (f BaseFormula) Restart() types.Formula
- func (f BaseFormula) Unassign(l types.Literal) types.Formula
- type LiteralState
- type MapClause
- func (c MapClause) Apply(lit types.Literal) types.Clause
- func (c MapClause) Contains(lit types.Literal) bool
- func (c MapClause) Disjunction() types.Disjunction
- func (c MapClause) IsLearnt() bool
- func (c MapClause) IsSolved() bool
- func (c MapClause) Original() types.Disjunction
- func (c MapClause) Reset() types.Clause
- func (c MapClause) Type() types.ClauseType
- func (c MapClause) Undo(lit types.Literal) types.Clause
- type ModelElement
- type ModelList
- type PQFormula
- type PriorityQueue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructBaseClause ¶
func ConstructBaseClause(d types.Disjunction, learnt bool) types.Clause
Constructs an instance of BaseClause from a Disjunction
func ConstructMapClause ¶
func ConstructMapClause(d types.Disjunction, learnt bool) types.Clause
func ResolveBaseClause ¶
func ResolveMapClause ¶
Types ¶
type BaseCDCLSolver ¶
type BaseCDCLSolver struct { Model ModelList // Model is stored in a customized LinkedList. Refer `model.go` Check []*ModelElement // Check is used to check is an Atom has been included in the Model AtomCount uint // No of Atoms DecisionCount uint // No of decisions made F types.Formula // Formula of clause to solve satisfiability problem /* Construct wraps Disjunctions into Clauses. This is overwritten on initialization to support modularity. */ Construct func(types.Disjunction, bool) types.Clause // a Clause Construction function which is overwritten on initialization to support modularity }
The BaseCDCLSolver is a close implementation of SAT Solver v3 from http://poincare.matf.bg.ac.rs/~filip/phd/sat-tutorial.pdf
func InitializeBaseSolver ¶
func InitializeBaseSolver(satfile types.SATFile, experimental bool) (solver BaseCDCLSolver, err error)
Intializes all the BaseCDCLSolver fields based on SATFile and CLI Flags
func (*BaseCDCLSolver) AnalyseConflict ¶
AnalyseConflict finds a resolvent clause by continously resolving the conflict clause with the reason of last literal of conflict clause to get a new conflict clause till we reach unique implication point
func (*BaseCDCLSolver) Decide ¶
func (solver *BaseCDCLSolver) Decide(clause types.Clause) error
Decide selects the first unassigned literal from the selected clause
[TODO] Random Selection of Decide variable
func (*BaseCDCLSolver) ResolveConflict ¶
func (solver *BaseCDCLSolver) ResolveConflict(clause types.Clause) (err error)
ResolveConflict works in 3 steps
- Calls AnalyseConflict to learn new clause
- Find the last literal in Model that makes new clause true when we negate it
- Find decision level to which we want to BackJump
func (*BaseCDCLSolver) UnitPropagate ¶
func (solver *BaseCDCLSolver) UnitPropagate(clause types.Clause) error
UnitPropgate takes the only literal and appends that to our model
type BaseClause ¶
type BaseClause struct {
// contains filtered or unexported fields
}
Implements the Clause interface defined in `pkg/types/types.go`
func (BaseClause) Disjunction ¶
func (c BaseClause) Disjunction() types.Disjunction
func (BaseClause) IsLearnt ¶
func (c BaseClause) IsLearnt() bool
func (BaseClause) IsSolved ¶
func (c BaseClause) IsSolved() bool
func (BaseClause) Original ¶
func (c BaseClause) Original() types.Disjunction
func (BaseClause) Reset ¶
func (c BaseClause) Reset() types.Clause
func (BaseClause) Type ¶
func (c BaseClause) Type() types.ClauseType
type BaseFormula ¶
func (BaseFormula) NextClause ¶
func (f BaseFormula) NextClause() types.Clause
func (BaseFormula) Print ¶
func (f BaseFormula) Print() string
func (BaseFormula) Restart ¶
func (f BaseFormula) Restart() types.Formula
type MapClause ¶
type MapClause struct {
// contains filtered or unexported fields
}
func (MapClause) Disjunction ¶
func (c MapClause) Disjunction() types.Disjunction
func (MapClause) Original ¶
func (c MapClause) Original() types.Disjunction
func (MapClause) Type ¶
func (c MapClause) Type() types.ClauseType
type ModelElement ¶
type ModelElement struct { Literal types.Literal // The Literal Assigned in the Model Reason types.Clause // The reason for assignment. Used for conflict resolution and unit propagation Decision bool // True if this is a decision literal DecisionLevel uint // No of decision literal present in model before this literal counting itself Next *ModelElement // The Next Pointer for ModelElement Prev *ModelElement // The Prev Pointer for ModelElement }
ModelElement is the Node of the ModelList. It represents a literal assignment in the Model
type ModelList ¶
type ModelList struct { Head *ModelElement // Head of the List Tail *ModelElement // Tail of the List DecisionLevel uint // Number of decision literals in list Size uint // Size of list }
ModelList is the LinkedList implementation of the Model Insertion and Deletion is more effecient in Linkedlist so that is why it has been preferred over arrays
func (*ModelList) PopBack ¶
func (modelList *ModelList) PopBack() (ModelElement, error)
Pop last element of List
func (*ModelList) PopTillLevel ¶
func (modelList *ModelList) PopTillLevel(level uint) (ModelElement, error)
Pop element of list till a given decision level
func (*ModelList) Pushback ¶
func (modelList *ModelList) Pushback(m *ModelElement)
Pushing Literal assignment to the Model
func (*ModelList) SearchLastLiteral ¶
func (modelList *ModelList) SearchLastLiteral(clause types.Clause) (ModelElement, error)
Finding Last Literal that refutes given Clause. Used for conflict resolution
type PQFormula ¶
type PQFormula struct {
Clauses PriorityQueue
}
func ConstructHeap ¶
func (PQFormula) NextClause ¶
type PriorityQueue ¶
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() any
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x any)
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)