diff --git a/exhaustive_search.py b/exhaustive_search.py index ec2042c..3584979 100644 --- a/exhaustive_search.py +++ b/exhaustive_search.py @@ -2,12 +2,13 @@ import time from itertools import permutations from typing import Tuple +import numpy as np import numpy.typing as npt from common import plot_plan, read_data -def exhaustive_search(distances: npt.NDArray) -> Tuple[float, Tuple]: +def exhaustive_search(distances: npt.NDArray) -> Tuple[float, npt.NDArray]: """An implementation of exhaustive search. This implementation takes a permutation iterator, then maps each @@ -25,11 +26,11 @@ def exhaustive_search(distances: npt.NDArray) -> Tuple[float, Tuple]: size = len(distances) - return min( # Find the smallest travel distance from the array - map( # Map the permutation array to contain tuples (distance, permutation) + return min( # Find the smallest travel distance from the array + map( # Map the permutation array to contain tuples (distance, permutation) lambda perm: ( sum([distances[perm[i - 1], perm[i]] for i in range(size)]), - perm, + np.array(perm) ), permutations(range(size)), ),