-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain_queens.py
45 lines (34 loc) · 899 Bytes
/
main_queens.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from search.Problems import *
from search.local_search import *
# formulate the problem
problem = EightQueensProblem()
# search algorithm
search = HillClimbing(problem=problem)
# run algorithm
result, state = search.run()
# display the solutions
print(search)
print(result)
print(problem.value(state))
print(state)
problem.print_chess(state)
# search algorithm
search = SimulatedAnnealing(problem=problem, max_time=1000, lam=0.01)
# run algorithm
result, state = search.run()
# display the solutions
print(search)
print(result)
print(problem.value(state))
print(state)
problem.print_chess(state)
# search algorithm
search = Genetic(problem=problem, population=50, generations=100, p_mutation=0.1, gene_pool=list(range(8)))
# run algorithm
result, state = search.run()
# display the solutions
print(search)
print(result)
print(problem.value(state))
print(state)
problem.print_chess(state)