コード例 #1
0
ファイル: cp.py プロジェクト: barisdemirdelen/csp_sudoku
    def search(self):
        start = time.time()
        self.arcs = set()
        self.splits = 0
        self.backtracks = 0
        self.arc_generate_time = 0
        self.remove_inconsistency_time = 0
        self.runtime = 0
        for variable in self.variables:
            self.variables_to_constraints[variable.name] = []
        for constraint in self.constraints:
            for variable in constraint.variables:
                self.variables_to_constraints[variable.name].append(constraint)

        for variable1 in self.variables:
            self.generate_arcs(variable1, Assignment(), self.arcs)

        backtracking_search = BacktrackingSearch(self)
        assignment = backtracking_search.search()
        end = time.time()
        self.runtime = end - start
        return assignment
コード例 #2
0
 def search(self):
     backtracking_search = BacktrackingSearch(self)
     return backtracking_search.search()