本文整理汇总了Golang中dpll/assignment.Assignment.Guess方法的典型用法代码示例。如果您正苦于以下问题:Golang Assignment.Guess方法的具体用法?Golang Assignment.Guess怎么用?Golang Assignment.Guess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dpll/assignment.Assignment
的用法示例。
在下文中一共展示了Assignment.Guess方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: moms
// We'll use a modified MOMS rule that only looks at binary clauses
func moms(db *db.DB, a *assignment.Assignment) (l *cnf.Lit) {
var (
counts = make([]int, a.Guess().Len())
eCount int
vals [2]uint
g = a.Guess()
biggest = 0
biggestI = -1
)
// Count up the total lits in binary clauses
for e := db.Learned; e != nil; e = e.Next {
eCount = 0
for _, l := range e.Clause.Lits {
if v, _ := g.Get(l.Val); v == guess.Unassigned {
eCount++
if eCount > 2 {
break
}
vals[eCount-1] = l.Val
}
}
if eCount <= 2 {
for i := 0; i < eCount; i++ {
counts[vals[i]-1]++
}
}
}
// Search for the biggest
for i, v := range counts {
if v > biggest {
biggest = v
biggestI = i
}
}
if biggestI == -1 {
return random(db, a)
} else {
return &cnf.Lit{uint(biggestI + 1), byte((rand.Int() % 2) + 1)}
}
panic("MOMS is broken")
}
示例2: DpllTimeout
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: vsids
func vsids(db *db.DB, a *assignment.Assignment) (l *cnf.Lit) {
l = db.Counts.Max(a.Guess())
return
}