Ejemplo n.º 1
0
    def solution(self):
        result = backtracking_search(self.int_csp)
        sol = ""

        for i in range(0, len(result)):
            sol += self.variables[i] + ": " + self.domain[result[i]] + "\n"

        print(sol)
Ejemplo n.º 2
0
def test_5():
    print(
        'Test 5: Map Coloring CSP with all heuristics and inferencing.----------------------------'
    )
    mapColoringProblem = MapColoringProblem()
    print(mapColoringProblem)
    solution = backtracking_search(mapColoringProblem, mrv=True, lcv=True)
    print(solution)
Ejemplo n.º 3
0
def test_1():
    print(
        'Test 1: Map Coloring CSP with no heuristic or inferencing.----------------------------'
    )
    mapColoringProblem = MapColoringProblem()
    print(mapColoringProblem)
    solution = backtracking_search(mapColoringProblem)
    print(solution)
Ejemplo n.º 4
0
def test_2():
    print(
        'Test 2: Map Coloring CSP with inferencing.----------------------------'
    )
    mapColoringProblem = MapColoringProblem()
    print(mapColoringProblem)
    solution = backtracking_search(mapColoringProblem, mac=True)
    print(solution)
Ejemplo n.º 5
0
def test_1():
    print(
        'Test 1: Temporal CSP with no heuristic or inferencing.----------------------------'
    )
    tcsp = TemporalCSP()
    #print(tcsp)
    solution = backtracking_search(tcsp)
    print(solution)
Ejemplo n.º 6
0
def test_6():
    print(
        'Test 6: Circuit Board CSP with all heuristics and inferencing togther. ----------------'
    )
    csp = CircuitBoardProblem(cb, [circuit_a, circuit_b, circuit_c, circuit_e])

    #-- If you want to print the problem just uncomment below. There are lots of constraints tho so beware of the output.
    #print(csp)

    solution = backtracking_search(csp, mrv=True, lcv=True, mac=True)
    print(solution)
Ejemplo n.º 7
0
def test_3():
    print(
        'Test 3: Circuit Board CSP with MAC-3 Inferencing.--------------------------------------'
    )
    csp = CircuitBoardProblem(cb, [circuit_a, circuit_b, circuit_c, circuit_e])

    #-- If you want to print the problem just uncomment below. There are lots of constraints tho so beware of the output.
    #print(csp)

    solution = backtracking_search(csp, mrv=False, lcv=False, mac=True)
    print(solution)
Ejemplo n.º 8
0
def test_10():
    big_board = CircuitBoard(10, 6)
    print(
        'Test 10: Big Circuit Board CSP with all heuristics and inferencing.----------------------------'
    )
    csp = CircuitBoardProblem(big_board, [
        circuit_a, circuit_b, circuit_c, circuit_e, circuit_f, circuit_g,
        circuit_h, circuit_i
    ])

    #-- If you want to print the problem just uncomment below. There are lots of constraints tho so beware of the output.
    #print(csp)

    solution = backtracking_search(csp, mrv=True, lcv=True, mac=True)
    print(solution)
Ejemplo n.º 9
0
    def solution(self):
        result = backtracking_search(self.int_csp)

        board = [["."] * self.board_n for _ in range(self.board_m)]

        for piece in self.variables:
            cover = self.piece_coverage(piece,
                                        result[self.variables.index(piece)])
            for pos in cover:
                coordinates = self.convert_to_coordinates(pos)
                board[int(coordinates[0])][int(
                    coordinates[1])] = piece.getChar()

        str = "Solution Board: \n"

        for r in range(len(board) - 1, -1, -1):
            for c in range(len(board[0])):
                str += board[r][c]

            str += "\n"

        print(str)
Ejemplo n.º 10
0
def test_4():
    print('Test 4: Map Coloring CSP with LCV.----------------------------')
    mapColoringProblem = MapColoringProblem()
    print(mapColoringProblem)
    solution = backtracking_search(mapColoringProblem, lcv=True)
    print(solution)
Ejemplo n.º 11
0
def test_3():
    print('Test 3: Map Coloring CSP with MRV.----------------------------')
    mapColoringProblem = MapColoringProblem()
    print(mapColoringProblem)
    solution = backtracking_search(mapColoringProblem, mrv=True)
    print(solution)
Ejemplo n.º 12
0
def test_4():
    print('Test 4: Temporal CSP with LCV.----------------------------')
    tcsp = TemporalCSP()
    #print(tcsp)
    solution = backtracking_search(tcsp, mac=False, mrv=False, lcv=True)
    print(solution)
Ejemplo n.º 13
0
def test_2():
    print('Test 2: Temporal CSP with inferencing.----------------------------')
    tcsp = TemporalCSP()
    #print(tcsp)
    solution = backtracking_search(tcsp, mac=True, mrv=False, lcv=False)
    print(solution)