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


Python SAT_solver.solve方法代码示例

本文整理汇总了Python中sat.SAT_solver.solve方法的典型用法代码示例。如果您正苦于以下问题:Python SAT_solver.solve方法的具体用法?Python SAT_solver.solve怎么用?Python SAT_solver.solve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sat.SAT_solver的用法示例。


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

示例1: test_CustomGraphOneTwoCollors

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    def test_CustomGraphOneTwoCollors(self):
        solver = SAT_solver()
        graph = [[0, 1, 1, 1, 1], [1, 0, 1, 1, 0], [1, 1, 0, 1, 0], [1, 1, 1, 0, 1], [1, 0, 0, 1, 0]]

        colors = 2
        formula = graph_coloring(graph, colors)
        solution = solver.solve(formula)
        self.assertFalse(solution[0])
开发者ID:urska19,项目名称:LVR-sat,代码行数:10,代码来源:test_sat.py

示例2: test_completeGraphTwoCollors

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    def test_completeGraphTwoCollors(self):
        solver = SAT_solver()

        graph = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
        colors = 2
        formula = graph_coloring(graph, colors)
        solution = solver.solve(formula)
        self.assertFalse(solution[0])
开发者ID:urska19,项目名称:LVR-sat,代码行数:10,代码来源:test_sat.py

示例3: test_CustomGraphOneFourCollors

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    def test_CustomGraphOneFourCollors(self):
        solver = SAT_solver()
        graph = [[0, 1, 1, 1, 1], [1, 0, 1, 1, 0], [1, 1, 0, 1, 0], [1, 1, 1, 0, 1], [1, 0, 0, 1, 0]]

        colors = 4
        formula = graph_coloring(graph, colors)
        solution = solver.solve(formula)
        self.assertTrue(solution[0])
        self.assertEqual("true", formula.nnf().cnf().evaluate(solution[1]).__class__.__name__)
开发者ID:urska19,项目名称:LVR-sat,代码行数:11,代码来源:test_sat.py

示例4: test_completeGraphThreeCollors

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    def test_completeGraphThreeCollors(self):
        solver = SAT_solver()

        graph = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

        colors = 3
        formula = graph_coloring(graph, colors)
        solution = solver.solve(formula)
        self.assertTrue(solution[0])
        self.assertEqual("true", formula.nnf().cnf().evaluate(solution[1]).__class__.__name__)
开发者ID:urska19,项目名称:LVR-sat,代码行数:12,代码来源:test_sat.py

示例5: test_OddCicleGraphTwoCollors

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    def test_OddCicleGraphTwoCollors(self):
        solver = SAT_solver()

        graph = [
            [0, 1, 1],
            [1, 0, 1],
            [1, 1, 0],
        ]

        colors = 2
        formula = graph_coloring(graph, colors)
        solution = solver.solve(FlatCNF(formula))
        self.assertFalse(solution[0])
开发者ID:urska19,项目名称:LVR-sat,代码行数:15,代码来源:test_sat_flat.py

示例6: test_EvenCicleGraphTwoCollors

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    def test_EvenCicleGraphTwoCollors(self):
        solver = SAT_solver()

        graph = [
            [0, 1, 0, 1],
            [1, 0, 1, 0],
            [0, 1, 0, 1],
            [1, 0, 1, 0],
        ]

        colors = 2
        formula = graph_coloring(graph, colors)
        solution = solver.solve(FlatCNF(formula))
        self.assertTrue(solution[0])
        self.assertEqual("true", formula.nnf().cnf().evaluate(solution[1]).__class__.__name__)
开发者ID:urska19,项目名称:LVR-sat,代码行数:17,代码来源:test_sat_flat.py

示例7: test_SudokuCustom

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    def test_SudokuCustom(self):

        solver = SAT_solver()
        board=[[4, 8, None, 1, 6, None, None, None, 7],
         [1, None, 7, 4, None, 3, 6, None, None],
         [3, None, None, 5, None, None, 4, 2, None],
         [None, 9, None, None, 3, 2, 7, None, 4],
         [None, None, None, None, None, None, None, None, None],
         [2, None, 4, 8, 1, None, None, 6, None],
         [None, 4, 1, None, None, 8, None, None, 6],
         [None, None, 6, 7, None, 1, 9, None, 3],
         [7, None, None, None, 9, 6, None, 4, None]]

        formula = sudoku(board)
        solution = solver.solve(formula,True)

        self.assertTrue(solution[0])
        self.assertEqual("true", formula.nnf().cnf().evaluate(solution[1]).__class__.__name__)
开发者ID:urska19,项目名称:LVR-sat,代码行数:20,代码来源:test_sat_mt.py

示例8: test_SudokuMedium

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    def test_SudokuMedium(self):

        solver = SAT_solver()
        board=[[None, None, 9, None, 6, 4, None, None, 1],
         [None, None, None, None, 5, None, None, None, None],
         [4, 6, None, 1, None, 7, None, None, 8],
         [None, None, None, None, None, None, None, 9, None],
         [None, None, None, None, 3, None, None, 1, None],
         [3, None, None, None, None, None, None, 4, None],
         [None, 4, 8, None, None, None, 2, None, None],
         [2, None, 7, None, 4, 5, None, 8, 6],
         [5, None, None, None, None, None, None, None, None]]

        formula = sudoku(board)
        solution = solver.solve(FlatCNF(formula))

        self.assertTrue(solution[0])
        self.assertEqual("true", formula.nnf().cnf().evaluate(solution[1]).__class__.__name__)
开发者ID:urska19,项目名称:LVR-sat,代码行数:20,代码来源:test_sat_flat.py

示例9: test_SudokuEasy

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    def test_SudokuEasy(self):

        solver = SAT_solver()
        board=[[None, None, None, 4, None, None, None, 5, None],
         [None, None, None, None, 1, None, 3, 6, None],
         [None, None, 8, None, None, 6, 9, 4, 7],
         [1, None, 2, None, None, None, None, 9, 5],
         [None, 9, None, 2, None, 1, None, None, None],
         [None, None, None, 5, 9, 3, None, None, None],
         [4, None, None, None, None, None, 1, 7, 9],
         [7, 2, None, 1, None, None, None, None, None],
         [None, 8, None, None, None, 9, None, 2, None]]

        formula = sudoku(board)
        solution = solver.solve(FlatCNF(formula))

        self.assertTrue(solution[0])
        self.assertEqual("true", formula.nnf().cnf().evaluate(solution[1]).__class__.__name__)
开发者ID:urska19,项目名称:LVR-sat,代码行数:20,代码来源:test_sat_flat.py

示例10: printSudoku

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
    [None, None, None, None, None, None, None, None, None],
    [2, None, 4, 8, 1, None, None, 6, None],
    [None, 4, 1, None, None, 8, None, None, 6],
    [None, None, 6, 7, None, 1, 9, None, 3],
    [7, None, None, None, 9, 6, None, 4, None],
]

# print sudoku from board definition.
print "Lab exercise:"
print printSudoku(board)

# construct logical formula from board definition.
formula = sudoku(board)

# solve formula using SAT solver(singlethreaded)
result = solver.solve(formula)

print "Solution:"
# process and print result of sat solver.
print printSudoku(processResult(result[1]))

medium_board = [
    [None, None, 5, None, 6, 3, 1, 2, None],
    [None, None, 9, None, None, 1, None, 5, None],
    [1, None, None, None, None, 8, 9, None, 6],
    [None, None, None, None, 5, None, 8, None, 2],
    [None, 5, None, None, None, None, None, 1, None],
    [6, None, 1, None, 9, None, None, None, None],
    [9, None, 6, 2, None, None, None, None, 1],
    [None, 1, None, 6, None, None, 4, None, None],
    [None, 4, 7, 3, 1, None, 2, None, None],
开发者ID:urska19,项目名称:LVR-sat,代码行数:33,代码来源:sudoku_example.py

示例11: test_contradiction

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
 def test_contradiction(self):
     solver = SAT_solver()
     formula = And([Var("A"), Not(Var("A"))])
     result = solver.solve(formula)
     self.assertFalse(result[0])
开发者ID:urska19,项目名称:LVR-sat,代码行数:7,代码来源:test_sat.py

示例12: test_Or

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
 def test_Or(self):
     solver = SAT_solver()
     formula = Or([Var("A"), Var("B")])
     result = solver.solve(formula)
     self.assertTrue(result[0])
     self.assertEqual("true", formula.nnf().cnf().evaluate(result[1]).__class__.__name__)
开发者ID:urska19,项目名称:LVR-sat,代码行数:8,代码来源:test_sat.py

示例13: test_variableNegation

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
 def test_variableNegation(self):
     solver = SAT_solver()
     formula = Not(Var("A"))
     result = solver.solve(formula)
     self.assertTrue(result[0])
     self.assertEqual("true", formula.nnf().cnf().evaluate(result[1]).__class__.__name__)
开发者ID:urska19,项目名称:LVR-sat,代码行数:8,代码来源:test_sat.py

示例14: test_false

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
 def test_false(self):
     solver = SAT_solver()
     self.assertFalse(solver.solve(false())[0])
开发者ID:urska19,项目名称:LVR-sat,代码行数:5,代码来源:test_sat.py

示例15: test_true

# 需要导入模块: from sat import SAT_solver [as 别名]
# 或者: from sat.SAT_solver import solve [as 别名]
 def test_true(self):
     solver = SAT_solver()
     self.assertTrue(solver.solve(true())[0])
开发者ID:urska19,项目名称:LVR-sat,代码行数:5,代码来源:test_sat.py


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