Ejemplo n.º 1
0
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}
}
Ejemplo n.º 2
0
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}
}
Ejemplo n.º 3
0
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")
}