示例#1
0
文件: main.go 项目: kopptr/harmonySAT
func printQuietResults(g *guess.Guess, cdb *db.DB) {
	if g == nil {
		fmt.Printf("UNSAT\n")
	} else if !cdb.Verify(g) {
		fmt.Printf("UNKNOWN\n")
	} else {
		fmt.Printf("SAT\n")
	}
}
示例#2
0
文件: dpll.go 项目: kopptr/harmonySAT
func DpllTimeout(cdb *db.DB, a *assignment.Assignment, b *Brancher, m *db.Manager, adapt *Adapter, timeout <-chan time.Time) *guess.Guess {

	nVar := a.Guess().Len()
	aStack := make([]dpllStackNode, nVar)
	top := -1

	for {

		top++
		aStack[top].l = b.Decide(cdb, a)
		aStack[top].Flipped = false
		a.PushAssign(aStack[top].l.Val, aStack[top].l.Pol)

		for {
			select {
			case <-timeout:
				return nil
			default:
			}

			status := cdb.Bcp(a.Guess(), *aStack[top].l, m)
			if status == db.Conflict {
				// BackTrack
				for aStack[top].Flipped == true {
					top--
					a.PopAssign()
				}
				if top < 0 {
					return nil
				}
				// Flip the assignment
				a.PopAssign()
				aStack[top].l.Flip()
				aStack[top].Flipped = true
				a.PushAssign(aStack[top].l.Val, aStack[top].l.Pol)
				// Reconfigure if neccessary
				if adapt != nil {
					adapt.Reconfigure(cdb, b, m)
				}

			} else if status == db.Sat {
				return a.Guess()
			} else {
				break
			}
		}
	}
	panic("Dpll is broken")
}
示例#3
0
文件: main.go 项目: kopptr/harmonySAT
func printVerboseResults(g *guess.Guess, cdb *db.DB, a *dpll.Adapter) {
	if g == nil {
		fmt.Printf("s UNSAT\n")
	} else if !cdb.Verify(g) {
		fmt.Printf("c ERROR: Solution could not be verified\n")
		fmt.Printf("s UNKNOWN\n")
		fmt.Printf("%s\n", g)
	} else {
		fmt.Printf("c Solution verified\n")
		if adaptive != "" {
			fmt.Printf("c Adaptive solver changed strategies %d times.\n", a.NChanges())
		}
		fmt.Printf("s SAT\n")
		fmt.Printf("s %s\n", g)
	}
}