当前位置: 首页>>代码示例>>Golang>>正文


Golang assignment.Assignment类代码示例

本文整理汇总了Golang中dpll/assignment.Assignment的典型用法代码示例。如果您正苦于以下问题:Golang Assignment类的具体用法?Golang Assignment怎么用?Golang Assignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Assignment类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ordered

func ordered(db *db.DB, a *assignment.Assignment) (l *cnf.Lit) {
	// find the first in-order unassigned literal
	for i := uint(1); i <= a.Len(); i++ {
		if p, _ := a.Get(i); p == guess.Unassigned {
			return &cnf.Lit{i, cnf.Pos}
		}
	}
	return &cnf.Lit{0, 0}
}
开发者ID:kopptr,项目名称:harmonySAT,代码行数:9,代码来源:branch.go

示例2: GetNextVmtf

func (lc *LitCounts) GetNextVmtf(a *assignment.Assignment) (l *cnf.Lit) {
	var lit uint
	for i := range lc.vmtf {
		if lc.vmtf[i].lit < 0 {
			lit = uint(-1 * lc.vmtf[i].lit)
		} else {
			lit = uint(lc.vmtf[i].lit)
		}
		if val, err := a.Get(lit); val == guess.Unassigned && err == nil {
			if lc.vmtf[i].lit < 0 {
				return &cnf.Lit{uint(lc.vmtf[i].lit * -1), cnf.Pos}
			} else {
				return &cnf.Lit{uint(lc.vmtf[i].lit), cnf.Pos}
			}
		}
	}
	panic("getNextVmtf is broken")
}
开发者ID:kopptr,项目名称:harmonySAT,代码行数:18,代码来源:litCount.go

示例3: 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")
}
开发者ID:kopptr,项目名称:harmonySAT,代码行数:45,代码来源:branch.go

示例4: random

func random(db *db.DB, a *assignment.Assignment) (l *cnf.Lit) {
	sign := byte((rand.Int() % 2) + 1)
	val := uint((rand.Int() % int(a.Len())) + 1)
	for i := val; i <= a.Len(); i++ {
		if v, _ := a.Get(i); v == guess.Unassigned {
			return &cnf.Lit{i, sign}
		}
	}
	for i := uint(1); i < val; i++ {
		if v, _ := a.Get(i); v == guess.Unassigned {
			return &cnf.Lit{i, sign}
		}
	}
	return &cnf.Lit{0, 0}
}
开发者ID:kopptr,项目名称:harmonySAT,代码行数:15,代码来源:branch.go

示例5: 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")
}
开发者ID:kopptr,项目名称:harmonySAT,代码行数:49,代码来源:dpll.go

示例6: vsids

func vsids(db *db.DB, a *assignment.Assignment) (l *cnf.Lit) {
	l = db.Counts.Max(a.Guess())
	return
}
开发者ID:kopptr,项目名称:harmonySAT,代码行数:4,代码来源:branch.go


注:本文中的dpll/assignment.Assignment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。