Ejemplo n.º 1
0
# for name in name_to_variable_map:
#    print(name, ":", name_to_variable_map[name].value)
#
# 0 : 3
# 1 : 6
# 2 : 2
# 3 : 7
# 4 : 1
# 5 : 4
# 6 : 0
# 7 : 5
# /////////////////////////////////////////////////////////////////////////////////////////////////////////////

measure_performance(1,
                    "n_queens_problem",
                    n_queens_problem,
                    "backtracking_search",
                    with_history=True)
measure_performance(1,
                    "n_queens_problem",
                    n_queens_problem,
                    "backtracking_search",
                    inference=csp.forward_check,
                    with_history=True)
measure_performance(1,
                    "n_queens_problem",
                    n_queens_problem,
                    "heuristic_backtracking_search",
                    with_history=True)
measure_performance(1,
                    "n_queens_problem",
Ejemplo n.º 2
0
# -  -  -  -  -  + -  -  -  -  -  + -  -  -  -  -  + -  -  -  -  -  + -  -  -  -  -
#  3 24  7  9 16 |  4  1 12 19 21 | 14  2  6 10  5 | 11  8 18 20 23 | 15 22 17 25 13
# 22 15 21 14  4 | 18  3 17 16 11 | 19 13  7 23 20 | 10 25 12  9  1 |  8 24  5  6  2
# 13  6  5 20 25 | 22 23  9 15 10 |  8 18  3 21 17 |  7  2 24 14  4 | 12  1 11 16 19
#  2 23 12 19 10 | 24  7 20  5  8 |  9 25  1 16 11 | 22 15 13 17  6 |  4 14  3 18 21
# 18 17  1  8 11 |  6 25  2 14 13 | 12 15 24 22  4 | 21 19  5 16  3 | 20  9 23  7 10
# -  -  -  -  -  + -  -  -  -  -  + -  -  -  -  -  + -  -  -  -  -  + -  -  -  -  -
# 23 13 11  1  5 |  8 18 10  6 25 |  4 20 21 14 22 |  3  9 17  2  7 | 19 12 15 24 16
#  6 16 14 25 21 | 19 11  4  7 24 |  2 17  8 18 10 | 12 23 20 13 15 |  1  3  9  5 22
#  7  8 17  2 20 |  1 16  3  9 12 | 15  5 13 19 24 | 18 14 22 25 11 | 10  4  6 21 23
#  9 12 19 18  3 | 23 22 14  2 15 |  6 11 16  1 25 |  5 24  4 10 21 |  7 13 20 17  8
# 24 10 15  4 22 | 17 13 21 20  5 |  7  9 12  3 23 |  6  1 19  8 16 | 11 25  2 14 18
# /////////////////////////////////////////////////////////////////////////////////////////////////////////////


measure_performance(1, "sudoku_problem", sudoku_problem,
                    "heuristic_backtracking_search", with_history=True, read_only_variables=read_only_variables)
measure_performance(1, "sudoku_problem", sudoku_problem,
                    "heuristic_backtracking_search", inference=csp.forward_check, with_history=True,
                    read_only_variables=read_only_variables)
measure_performance(1, "sudoku_problem", sudoku_problem,
                    "naive_cycle_cutset", with_history=True, read_only_variables=read_only_variables)
measure_performance(2, "sudoku_problem", sudoku_problem,
                    "min_conflicts", 100, tabu_size, with_history=True, read_only_variables=read_only_variables)
measure_performance(2, "sudoku_problem", sudoku_problem,
                    "constraints_weighting", 100, with_history=True, read_only_variables=read_only_variables)
measure_performance(2, "sudoku_problem", sudoku_problem,
                    "simulated_annealing", 100000, 0.5, 0.99999, sudoku_start_state_generator,
                    sudoku_successor_generator, sudoku_score_calculator, read_only_variables=read_only_variables)
measure_performance(2, "sudoku_problem", sudoku_problem,
                    "random_restart_first_choice_hill_climbing", 100, 10, 10, sudoku_start_state_generator,
                    sudoku_successor_generator, sudoku_score_calculator, read_only_variables=read_only_variables)