[2] сделал замеры алгоритмов
This commit is contained in:
parent
c19eb1a1f6
commit
5b68540615
46
raskatovia/docs/data/task2/results.csv
Normal file
46
raskatovia/docs/data/task2/results.csv
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
map,algorithm,try,time,visited,length
|
||||
simple.txt,BFS,1,2.6000008801929653e-05,9,5
|
||||
simple.txt,BFS,2,1.4800010831095278e-05,9,5
|
||||
simple.txt,BFS,3,1.2799995602108538e-05,9,5
|
||||
simple.txt,BFS,4,1.1600001016631722e-05,9,5
|
||||
simple.txt,BFS,5,1.1399999493733048e-05,9,5
|
||||
simple.txt,DFS,1,9.60000033956021e-06,5,5
|
||||
simple.txt,DFS,2,7.199996616691351e-06,5,5
|
||||
simple.txt,DFS,3,6.300004315562546e-06,5,5
|
||||
simple.txt,DFS,4,6.200003554113209e-06,5,5
|
||||
simple.txt,DFS,5,6.200003554113209e-06,5,5
|
||||
simple.txt,A*,1,1.4599994756281376e-05,5,5
|
||||
simple.txt,A*,2,9.499999578110874e-06,5,5
|
||||
simple.txt,A*,3,8.29999044071883e-06,5,5
|
||||
simple.txt,A*,4,8.300004992634058e-06,5,5
|
||||
simple.txt,A*,5,2.4499997380189598e-05,5,5
|
||||
medium.txt,BFS,1,4.0400002035312355e-05,29,29
|
||||
medium.txt,BFS,2,3.700000524986535e-05,29,29
|
||||
medium.txt,BFS,3,3.670000296551734e-05,29,29
|
||||
medium.txt,BFS,4,3.470000228844583e-05,29,29
|
||||
medium.txt,BFS,5,3.370000922586769e-05,29,29
|
||||
medium.txt,DFS,1,3.4199998481199145e-05,29,29
|
||||
medium.txt,DFS,2,3.369999467395246e-05,29,29
|
||||
medium.txt,DFS,3,3.329999162815511e-05,29,29
|
||||
medium.txt,DFS,4,3.309999010525644e-05,29,29
|
||||
medium.txt,DFS,5,3.300000389572233e-05,29,29
|
||||
medium.txt,A*,1,4.470000567380339e-05,29,29
|
||||
medium.txt,A*,2,4.549999721348286e-05,29,29
|
||||
medium.txt,A*,3,4.259998968336731e-05,29,29
|
||||
medium.txt,A*,4,4.260000423528254e-05,29,29
|
||||
medium.txt,A*,5,4.1799998143687844e-05,29,29
|
||||
hard.txt,BFS,1,4.680000711232424e-05,38,19
|
||||
hard.txt,BFS,2,4.390001413412392e-05,38,19
|
||||
hard.txt,BFS,3,4.4200001866556704e-05,38,19
|
||||
hard.txt,BFS,4,4.2100000428035855e-05,38,19
|
||||
hard.txt,BFS,5,4.389999958220869e-05,38,19
|
||||
hard.txt,DFS,1,2.570000651758164e-05,19,19
|
||||
hard.txt,DFS,2,2.1800005924887955e-05,19,19
|
||||
hard.txt,DFS,3,2.19999928958714e-05,19,19
|
||||
hard.txt,DFS,4,2.1799991372972727e-05,19,19
|
||||
hard.txt,DFS,5,2.1799991372972727e-05,19,19
|
||||
hard.txt,A*,1,4.149999585933983e-05,25,19
|
||||
hard.txt,A*,2,3.7699996028095484e-05,25,19
|
||||
hard.txt,A*,3,3.6999990697950125e-05,25,19
|
||||
hard.txt,A*,4,3.680000372696668e-05,25,19
|
||||
hard.txt,A*,5,3.720000677276403e-05,25,19
|
||||
|
40
raskatovia/docs/data/task2/zamery.py
Normal file
40
raskatovia/docs/data/task2/zamery.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import csv
|
||||
import time
|
||||
from maze import MazeBuilder
|
||||
from solver import BfsStrategy, DfsStrategy, AstarStrategy, MazeSolver
|
||||
|
||||
MAPS = ["simple.txt", "medium.txt", "hard.txt"]
|
||||
REPEATS = 5
|
||||
|
||||
def run_one(filename, strategy):
|
||||
maze = MazeBuilder().from_file("raskatovia/docs/data/task2/maps/" + filename).build()
|
||||
solver = MazeSolver(strategy)
|
||||
start = time.perf_counter()
|
||||
result = solver.solve(maze)
|
||||
work_time = time.perf_counter() - start
|
||||
return result, work_time
|
||||
|
||||
def main():
|
||||
rows = [["map", "algorithm", "try", "time", "visited", "length"]]
|
||||
strategies = [BfsStrategy(), DfsStrategy(), AstarStrategy()]
|
||||
|
||||
for filename in MAPS:
|
||||
for strategy in strategies:
|
||||
for number in range(1, REPEATS + 1):
|
||||
result, work_time = run_one(filename, strategy)
|
||||
rows.append([
|
||||
filename,
|
||||
result["name"],
|
||||
number,
|
||||
work_time,
|
||||
result["visited"],
|
||||
result["length"]
|
||||
])
|
||||
|
||||
with open("raskatovia/docs/data/task2/results.csv", "w", newline="", encoding="utf-8") as file:
|
||||
writer = csv.writer(file)
|
||||
writer.writerows(rows)
|
||||
|
||||
print("results saved")
|
||||
|
||||
main()
|
||||
Loading…
Reference in New Issue
Block a user