コード例 #1
0
 def Ntest_solve(self):
     fg = pbool.FormulaGenerator(50, 8)
     fst = fg.formula(4)
     cnf = pbool.CNFFormula(fst)
     s = psat.Solver(cnf)
     for soln in s.minimal_solutions():
         print "SOLN1 " + str(soln)
コード例 #2
0
ファイル: benchmark.py プロジェクト: disorderlylabs/cally
def benchmark():
    print "depth, iteration, clauses, CNF clauses, variables, solutions, size of 1st SAT solution, size of 1st ILP solution, CNF time, SAT 1st, SAT minimal, ILP minimal"

    fg = pbool.FormulaGenerator(vocab, seed)
    for i in range(5, 15):
        for j in range(0, 50):
            yield do_experiment(fg, i, j)
コード例 #3
0
    def NNNtest_big_ilp(self):
        fg = pbool.FormulaGenerator(100, 8)
        fst = fg.formula(8)
        cnf = pbool.CNFFormula(fst)
        s = pilp.Solver(cnf)

        for soln in s.solutions():
            print "SOL: " + str(soln)
コード例 #4
0
    def test_size(self):
        fg = pbool.FormulaGenerator(10, 8)
        fst = fg.formula(10)
        snd = fg.formula(20)

        #nprint "snd " + str(len(snd.variables()))
        assert (snd.clauses() > fst.clauses())

        assert (snd.depth() == 20)
        assert (fst.depth() == 10)
        assert (len(snd.variables()) == 11)
コード例 #5
0
    def test_convert(self):
        fg = pbool.FormulaGenerator(10, 8)
        fst = fg.formula(7)
        c = pbool.CNFFormula(fst)
        cnf = c.formula
        assert (cnf.variables() == fst.variables())
        #assert(cnf.clauses() > fst.clauses())
        #assert(cnf.depth() > fst.depth())

        assert (not fst.isCNF())
        assert (cnf.isCNF())
        c = cnf.conjuncts()
コード例 #6
0
    def test_ilp_sat_equivalence(self):
        fg = pbool.FormulaGenerator(20, 8)
        fst = fg.formula(4)

        cnf = pbool.CNFFormula(fst)

        s = psat.Solver(cnf)
        i = pilp.Solver(cnf)

        ssols = sorted(list(s.solutions()))
        isols = sorted(list(i.solutions()))

        print "LENs " + str(len(ssols)) + " vs " + str(len(isols))
        print "SOLs " + str(ssols) + " vs " + str(isols)
コード例 #7
0
    def test_prob(self):
        fg = pbool.FormulaGenerator(20, 8)
        fst = fg.formula(4)

        cnf = pbool.CNFFormula(fst)
        i = pilp.Solver(cnf)
        p = pilp.ProbSolver(cnf, {})

        isols = list(i.solutions())
        psols = list(p.solutions())

        print("SOL1 " + str(isols))
        print("SOL2 " + str(psols))
        assert (isols == psols)
        p2 = pilp.ProbSolver(cnf, {
            "I2": 0.0001,
            "I9": 0.000001,
            "I4": 0.000000000001
        })
        p2sols = list(p2.solutions())
        print("SOL3 " + str(p2sols))