Skip to content

Commit

Permalink
(doh!) fix inc solve flow bug for Marvin Stenger
Browse files Browse the repository at this point in the history
  • Loading branch information
wsc1 committed Sep 8, 2018
1 parent 2a92729 commit 58be5e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
5 changes: 4 additions & 1 deletion internal/xo/s.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ func (s *S) Solve() int {
s.assumptLevel = 0
s.assumes = s.assumes[:0]
}()
trail := s.Trail
if r := s.solveInit(); r != 0 {
return r
}
trail := s.Trail
vars := s.Vars
guess := s.Guess
guess.nextRestart(s.restartStopwatch)
Expand Down Expand Up @@ -480,6 +480,9 @@ func (s *S) Add(m z.Lit) {
//s.lock()
//defer s.unlock()
s.ensureLitCap(m)
if m == z.LitNull {
s.Trail.Back(s.endTestLevel)
}
loc, u := s.Cdb.Add(m)
if u != z.LitNull {
s.Trail.Assign(u, loc)
Expand Down
25 changes: 23 additions & 2 deletions internal/xo/s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
package xo

import (
"github.com/irifrance/gini/gen"
"github.com/irifrance/gini/z"
"log"
"math/rand"
"testing"
"time"

"github.com/irifrance/gini/gen"
"github.com/irifrance/gini/z"
)

func TestSRand3Cnf(t *testing.T) {
Expand Down Expand Up @@ -380,3 +381,23 @@ func TestCopyPause(t *testing.T) {
}
t.Errorf("giving up, couldn't pause\n")
}

// Doh! from Marvin Stenger; thanks!
func TestIncAdd(t *testing.T) {
s := NewS()
in, out, x := s.Lit(), s.Lit(), s.Lit()
s.Add(in.Not())
s.Add(out)
s.Add(0)
s.Add(in.Not())
s.Add(x)
s.Add(0)
s.Solve()
s.Add(in)
s.Add(0)
s.Add(out)
s.Add(0)
if s.Solve() != 1 {
t.Errorf("unsat")
}
}

0 comments on commit 58be5e2

Please sign in to comment.