-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (35 loc) · 1.09 KB
/
main.py
File metadata and controls
49 lines (35 loc) · 1.09 KB
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
46
47
48
49
import cProfile
import dynamic_rod_cutting
import n_queen
import timelog
from min_heap import MinHeap
def test_min_heap():
heap = MinHeap()
print(heap)
heap.build_heap()
print(f"{heap} (Final heap)")
heap.extract_min()
heap.insert(2)
def test_rod_cutting():
length = 8
revenue = dynamic_rod_cutting.find_max_revenue(length)
print(revenue)
dynamic_rod_cutting.print_best_cuts(length)
def test_n_queen():
n = pow(10, 6)
n_queen_solver = n_queen.NQueen(n)
timelog.start()
n_queen_solver.preprocess_starting_position()
timelog.mid("Starting position created")
# Solve
timelog.IS_QUIET = True
n_queen_solver.solve_min_conflict_hill_climbing_no_backtrack()
timelog.end()
if __name__ == '__main__':
# test_min_heap()
# test_rod_cutting()
test_n_queen()
timelog.IS_QUIET = True
# n_queen_solver = n_queen.NQueen(pow(10, 5))
# cProfile.run('n_queen_solver.preprocess_starting_position()', sort="cumulative")
# cProfile.run('n_queen_solver.solve_min_conflict_hill_climbing_no_backtrack()', sort="cumulative")