mirror of
https://github.com/mudler/luet.git
synced 2025-09-10 03:29:16 +00:00
update vendor
This commit is contained in:
20
vendor/github.com/crillab/gophersat/solver/solver.go
generated
vendored
20
vendor/github.com/crillab/gophersat/solver/solver.go
generated
vendored
@@ -127,6 +127,25 @@ func New(problem *Problem) *Solver {
|
||||
return s
|
||||
}
|
||||
|
||||
// newVar is used to indicate a new variable must be added to the solver.
|
||||
// This can be used when new clauses are appended and these clauses contain vars that were unseen so far.
|
||||
// If the var already existed, nothing will happen.
|
||||
func (s *Solver) newVar(v Var) {
|
||||
if cnfVar := int(v.Int()); cnfVar > s.nbVars {
|
||||
// If the var already existed, do nothing
|
||||
for i := s.nbVars; i < cnfVar; i++ {
|
||||
s.model = append(s.model, 0)
|
||||
s.activity = append(s.activity, 0.)
|
||||
s.polarity = append(s.polarity, false)
|
||||
s.reason = append(s.reason, nil)
|
||||
s.trailBuf = append(s.trailBuf, 0)
|
||||
}
|
||||
s.varQueue = newQueue(s.activity)
|
||||
s.addVarWatcherList(v)
|
||||
s.nbVars = cnfVar
|
||||
}
|
||||
}
|
||||
|
||||
// sets initial activity for optimization variables, if any.
|
||||
func (s *Solver) initOptimActivity() {
|
||||
for i, lit := range s.minLits {
|
||||
@@ -682,6 +701,7 @@ func (s *Solver) AppendClause(clause *Clause) {
|
||||
i := 0
|
||||
for i < clause.Len() {
|
||||
lit := clause.Get(i)
|
||||
s.newVar(lit.Var())
|
||||
switch s.litStatus(lit) {
|
||||
case Sat:
|
||||
w := clause.Weight(i)
|
||||
|
5
vendor/github.com/crillab/gophersat/solver/types.go
generated
vendored
5
vendor/github.com/crillab/gophersat/solver/types.go
generated
vendored
@@ -71,6 +71,11 @@ func (v Var) Lit() Lit {
|
||||
return Lit(v * 2)
|
||||
}
|
||||
|
||||
// Int converts a Var to a CNF variable.
|
||||
func (v Var) Int() int32 {
|
||||
return int32(v + 1)
|
||||
}
|
||||
|
||||
// SignedLit returns the Lit associated to v, negated if 'signed', positive else.
|
||||
func (v Var) SignedLit(signed bool) Lit {
|
||||
if signed {
|
||||
|
10
vendor/github.com/crillab/gophersat/solver/watcher.go
generated
vendored
10
vendor/github.com/crillab/gophersat/solver/watcher.go
generated
vendored
@@ -39,6 +39,16 @@ func (s *Solver) initWatcherList(clauses []*Clause) {
|
||||
}
|
||||
}
|
||||
|
||||
// Should be called when new vars are added to the problem (see Solver.newVar)
|
||||
func (s *Solver) addVarWatcherList(v Var) {
|
||||
cnfVar := int(v.Int())
|
||||
for i := s.nbVars; i < cnfVar; i++ {
|
||||
s.wl.wlistBin = append(s.wl.wlistBin, nil, nil)
|
||||
s.wl.wlist = append(s.wl.wlist, nil, nil)
|
||||
s.wl.wlistPb = append(s.wl.wlistPb, nil, nil)
|
||||
}
|
||||
}
|
||||
|
||||
// appendClause appends the clause without checking whether the clause is already satisfiable, unit, or unsatisfiable.
|
||||
// To perform those checks, call s.AppendClause.
|
||||
// clause is supposed to be a problem clause, not a learned one.
|
||||
|
Reference in New Issue
Block a user