-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (24 loc) · 826 Bytes
/
main.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
import os
import sys
from genetic_algorithms import PathFinder
from input import InputBuilderFromJson
def f_calculations(file: str):
print()
print(file)
with open(os.path.join(path, file), "r") as f:
input_data = InputBuilderFromJson.build(f.read())
path_finder = PathFinder(input_data, size_generation=20)
path_finder.init_first_generation()
for paths in path_finder.evolute():
for i in range(5 if 5 <= path_finder.size_generation else path_finder.size_generation):
print(path_finder.fitness_function(paths[i]), end=" ")
print()
print()
#input("next?")
if __name__ == "__main__":
path = "./input_data/"
if len(sys.argv) == 1:
for file in os.listdir(path):
f_calculations(file)
else:
f_calculations(sys.argv[1])