measure_performance(1, "ac3_sudoku_problem", ac3_sudoku_problem, "heuristic_backtracking_search", inference=csp.forward_check, with_history=True, read_only_variables=read_only_variables) measure_performance(1, "ac3_sudoku_problem", ac3_sudoku_problem, "naive_cycle_cutset", with_history=True, read_only_variables=read_only_variables) measure_performance(2, "ac3_sudoku_problem", ac3_sudoku_problem, "min_conflicts", 100000, with_history=True, read_only_variables=read_only_variables) measure_performance(2, "ac3_sudoku_problem", ac3_sudoku_problem, "constraints_weighting", 10000, with_history=True, read_only_variables=read_only_variables) general_genetic_ac3_sudoku_problem = csp.GeneralGeneticConstraintProblem(ac3_sudoku_problem, 0.1) measure_performance(2, "general_genetic_ac3_magic_square_problem", general_genetic_ac3_sudoku_problem, "genetic_local_search", 1000, 100, 0.1, read_only_variables=read_only_variables) ac4_start_time = time.process_time() ac4_is_arc_consistent = csp.ac4(ac4_sudoku_problem) ac4_end_time = time.process_time() if ac4_is_arc_consistent: print() print() print("-" * 145) print("using ac4 as a preprocessing stage which took", ac4_end_time - ac4_start_time, "seconds") print("-" * 145) measure_performance(1, "ac4_sudoku_problem", ac4_sudoku_problem, "heuristic_backtracking_search", with_history=True, read_only_variables=read_only_variables) measure_performance(1, "ac4_sudoku_problem", ac4_sudoku_problem, "heuristic_backtracking_search", inference=csp.forward_check, with_history=True, read_only_variables=read_only_variables) measure_performance(1, "ac4_sudoku_problem", ac4_sudoku_problem, "naive_cycle_cutset", with_history=True, read_only_variables=read_only_variables) measure_performance(2, "ac4_sudoku_problem", ac4_sudoku_problem,
with_history=True) measure_performance(2, "ac3_n_queens_problem", ac3_n_queens_problem, "simulated_annealing", 100000, 0.5, 0.99999) measure_performance(2, "ac3_n_queens_problem", ac3_n_queens_problem, "random_restart_first_choice_hill_climbing", 100, 100, 10) general_genetic_n_queens_problem = csp.GeneralGeneticConstraintProblem( ac3_n_queens_problem, 0.1) measure_performance(2, "ac3_n_queens_problem", general_genetic_n_queens_problem, "genetic_local_search", 100, 100, 0.1) ac4_n_queens_problem = copy.deepcopy(n_queens_problem) ac4_n_queens_problem.unassign_all_variables() ac4_start_time = time.process_time() ac4_is_arc_consistent = csp.ac4(ac4_n_queens_problem) ac4_end_time = time.process_time() if ac4_is_arc_consistent: print() print() print("-" * 145) print("using ac4 as a preprocessing stage which took", ac4_end_time - ac4_start_time, "seconds") print("-" * 145) measure_performance(1, "ac4_n_queens_problem", ac4_n_queens_problem, "backtracking_search", with_history=True) measure_performance(1, "ac4_n_queens_problem",
ac3_car_assembly_problem, "simulated_annealing", 100000, 0.5, 0.99999) measure_performance(2, "ac3_car_assembly_problem", ac3_car_assembly_problem, "random_restart_first_choice_hill_climbing", 10, 10, 10) general_genetic_car_assembly_problem = csp.GeneralGeneticConstraintProblem( ac3_car_assembly_problem, 0.1) measure_performance(2, "ac3_car_assembly_problem", general_genetic_car_assembly_problem, "genetic_local_search", 100, 100, 0.1) ac4_car_assembly_problem = copy.deepcopy(car_assembly_problem) ac4_car_assembly_problem.unassign_all_variables() ac4_start_time = time.process_time() ac4_is_arc_consistent = csp.ac4(ac4_car_assembly_problem) ac4_end_time = time.process_time() if ac4_is_arc_consistent: print() print() print("-" * 145) print("using ac4 as a preprocessing stage which took", ac4_end_time - ac4_start_time, "seconds") print("-" * 145) measure_performance(1, "ac4_car_assembly_problem", ac4_car_assembly_problem, "backtracking_search", with_history=True) measure_performance(1, "ac4_car_assembly_problem",
ac3_verbal_arithmetic_problem, "simulated_annealing", 100000, 0.5, 0.99999) measure_performance(2, "ac3_verbal_arithmetic_problem", ac3_verbal_arithmetic_problem, "random_restart_first_choice_hill_climbing", 100, 100, 10) general_genetic_verbal_arithmetic_problem = csp.GeneralGeneticConstraintProblem( ac3_verbal_arithmetic_problem, 0.1) measure_performance(2, "ac3_verbal_arithmetic_problem", general_genetic_verbal_arithmetic_problem, "genetic_local_search", 100, 100, 0.1) ac4_verbal_arithmetic_problem = copy.deepcopy(verbal_arithmetic_problem) ac4_verbal_arithmetic_problem.unassign_all_variables() ac4_start_time = time.process_time() ac4_is_arc_consistent = csp.ac4(ac4_verbal_arithmetic_problem) ac4_end_time = time.process_time() if ac4_is_arc_consistent: print() print() print("-" * 145) print("using ac4 as a preprocessing stage which took", ac4_end_time - ac4_start_time, "seconds") print("-" * 145) measure_performance(1, "ac4_verbal_arithmetic_problem", ac4_verbal_arithmetic_problem, "backtracking_search", with_history=True) measure_performance(1, "ac4_verbal_arithmetic_problem",
ac3_map_coloring_problem, "simulated_annealing", 100000, 0.5, 0.99999) measure_performance(2, "ac3_map_coloring_problem", ac3_map_coloring_problem, "random_restart_first_choice_hill_climbing", 100, 100, 10) general_genetic_map_coloring_problem = csp.GeneralGeneticConstraintProblem( ac3_map_coloring_problem, 0.1) measure_performance(2, "ac3_map_coloring_problem", general_genetic_map_coloring_problem, "genetic_local_search", 100, 100, 0.1) ac4_map_coloring_problem = copy.deepcopy(map_coloring_problem) ac4_map_coloring_problem.unassign_all_variables() ac4_start_time = time.process_time() ac4_is_arc_consistent = csp.ac4(ac4_map_coloring_problem) ac4_end_time = time.process_time() if ac4_is_arc_consistent: print() print() print("-" * 145) print("using ac4 as a preprocessing stage which took", ac4_end_time - ac4_start_time, "seconds") print("-" * 145) measure_performance(1, "ac4_map_coloring_problem", ac4_map_coloring_problem, "backtracking_search", with_history=True) measure_performance(1, "ac4_map_coloring_problem",
def test_ac4_one(self): self.const_problem1.unassign_all_variables() res = csp.ac4(self.const_problem1) self.assertTrue(res)
def test_ac4_three(self): res = csp.ac4(self.const_problem3) self.assertTrue(res) wanted_reduced_domains = [[1, 2], [2, 3]] for var in self.const_problem3.get_variables(): self.assertIn(var.domain, wanted_reduced_domains)
with_history=True) measure_performance(2, "ac3_einstein_problem", ac3_einstein_problem, "simulated_annealing", 100000, 0.5, 0.99999) measure_performance(2, "ac3_einstein_problem", ac3_einstein_problem, "random_restart_first_choice_hill_climbing", 100, 100, 10) general_genetic_ac3_einstein_problem = csp.GeneralGeneticConstraintProblem( ac3_einstein_problem, 0.1) measure_performance(2, "ac3_einstein_problem", general_genetic_ac3_einstein_problem, "genetic_local_search", 100, 100, 0.1) ac4_einstein_problem = copy.deepcopy(einstein_problem) ac4_einstein_problem.unassign_all_variables() ac4_start_time = time.process_time() ac4_is_arc_consistent = csp.ac4(ac4_einstein_problem) ac4_end_time = time.process_time() if ac4_is_arc_consistent: print() print() print("-" * 145) print("using ac4 as a preprocessing stage which took", ac4_end_time - ac4_start_time, "seconds") print("-" * 145) measure_performance(1, "ac4_einstein_problem", ac4_einstein_problem, "heuristic_backtracking_search", with_history=True) measure_performance(1, "ac4_einstein_problem",
measure_performance(2, "ac3_magic_square_problem", ac3_magic_square_problem, "min_conflicts", 100000, with_history=True) measure_performance(2, "ac3_magic_square_problem", ac3_magic_square_problem, "constraints_weighting", 10000, with_history=True) measure_performance(2, "ac3_magic_square_problem", ac3_magic_square_problem, "simulated_annealing", 100000, 0.5, 0.99999) measure_performance(2, "ac3_magic_square_problem", ac3_magic_square_problem, "random_restart_first_choice_hill_climbing", 100, 100, 10) general_genetic_ac3_magic_square_problem = csp.GeneralGeneticConstraintProblem(ac3_magic_square_problem, 0.1) measure_performance(2, "general_genetic_ac3_magic_square_problem", general_genetic_ac3_magic_square_problem, "genetic_local_search", 1000, 100, 0.1) ac4_magic_square_problem = copy.deepcopy(magic_square_problem) ac4_magic_square_problem.unassign_all_variables() ac4_start_time = time.process_time() ac4_is_arc_consistent = csp.ac4(ac4_magic_square_problem) ac4_end_time = time.process_time() if ac4_is_arc_consistent: print() print() print("-" * 145) print("using ac4 as a preprocessing stage which took", ac4_end_time - ac4_start_time, "seconds") print("-" * 145) measure_performance(1, "ac4_magic_square_problem", ac4_magic_square_problem, "backtracking_search", with_history=True) measure_performance(1, "ac4_magic_square_problem", ac4_magic_square_problem, "backtracking_search", inference=csp.forward_check, with_history=True) measure_performance(1, "ac4_magic_square_problem", ac4_magic_square_problem, "heuristic_backtracking_search", with_history=True) measure_performance(1, "ac4_magic_square_problem", ac4_magic_square_problem, "heuristic_backtracking_search", inference=csp.forward_check, with_history=True)