コード例 #1
0
        self.view_grid._grid = self.current_solution._grid.copy()
        print(f"Minimum score: {self.current_min}")

    def stop(self):
        self._stop = True
        self._handle.join()


if __name__ == "__main__":
    grid_size = (5, 5)
    netlists = ["A", "B"]

    grid = Grid(grid_size[0], grid_size[1], netlists)
    grid.assign_node(0, 0, "A")
    grid.assign_node(0, 3, "B")
    grid.lock = threading.Lock()
    print(grid)

    requirement_nodes = [(3, 4, "A"), (3, 3, "B")]

    algorithm = Algoritm(grid, requirement_nodes)
    algorithm.run(copy.copy(grid))

    renderer = Render(grid_size)
    renderer.bind("<q>", lambda _: algorithm.stop())
    renderer.draw_loop(grid)

    print(f"Solution Score {algorithm.current_min}")
    print(algorithm.current_solution)
    algorithm.stop()