class TestWithUI(unittest.TestCase): def test_calc_init_generation(self): with open("./input_data/harder", "r") as f: self.input_data = InputBuilderFromJson.build(f.read()) self.path_finder = PathFinder(self.input_data, size_generation=50) self.path_finder.init_first_generation() save_object(self.path_finder, "path_finder_harder_50") def test_smth(self): self.path_finder = open_object("path_finder_harder_50") start_gui_with_pf(self.path_finder)
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()
class TestGA(unittest.TestCase): def setUp(self): with open("./input_data/harder", "r") as f: self.input_data = InputBuilderFromJson.build(f.read()) self.path_finder = PathFinder(self.input_data, size_generation=20) self.path_finder.init_first_generation() def test_mutation(self): for path in self.path_finder.paths: path.mutation() def test_crossingover(self): self.path_finder.reproduction() pass def test_selection(self): self.path_finder.selection() for i in range(self.path_finder.size_generation): print(self.path_finder.fitness_function(self.path_finder.paths[i]), end=" ") print()
def start_gui_with_id(input_data, size_generation = 50): path_finder = PathFinder(input_data, size_generation=size_generation) start_gui_with_pf(path_finder) gui.start()
def test_calc_init_generation(self): with open("./input_data/harder", "r") as f: self.input_data = InputBuilderFromJson.build(f.read()) self.path_finder = PathFinder(self.input_data, size_generation=50) self.path_finder.init_first_generation() save_object(self.path_finder, "path_finder_harder_50")
def setUp(self): with open("./input_data/harder", "r") as f: self.input_data = InputBuilderFromJson.build(f.read()) self.path_finder = PathFinder(self.input_data, size_generation=20) self.path_finder.init_first_generation()
def test_path_finder(self): path_finder = PathFinder(self.input_data, size_generation=10) path_finder.init_first_generation()
def test_path(self): path_finder = PathFinder(self.input_data, size_generation=10) for x in path_finder.generate_path(): break