Search code examples
algorithmartificial-intelligenceheuristicsplanning

Manhattan distance generalization


For a research I'm working on I'm trying to find a satisfying heuristic that is based on Manhattan distance which can work with any problem and domain as an input. Which is also known as domain-independent heuristic. For now, I know how to apply Manhattan distance on a grid based problems. Can someone give a tip how to generalize it to work on every domain and problem and not just grid based problems?


Solution

  • The generalization of Manhattan distance is simple. It is a metric which defines the distance between two multi-dimensional points as the sum of the distances along each dimension:

    md(A, B) = dist(a1, b1) + dist(a2, b2) + . . .
    

    The distances along each dimension are assumed to be simple to calculate. For numbers, the distance is the absolute value of the difference between the values.

    This can be extended to other domains as well. For instance, the distance between two strings could be taken as the Levenshtein distance -- and that would prove to be an interesting metric in conjunction with other dimensions.