Interface TSPEdgeDistance

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface TSPEdgeDistance
    A functional interface for specifying a distance function between a pair of cities in a TSP instance.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      double distance​(double x1, double y1, double x2, double y2)
      Computes the distance between two cities in the TSP.
      default int distanceAsInt​(double x1, double y1, double x2, double y2)
      Computes the distance between two cities in the TSP as an integer.
    • Method Detail

      • distance

        double distance​(double x1,
                        double y1,
                        double x2,
                        double y2)
        Computes the distance between two cities in the TSP.
        Parameters:
        x1 - The x coordinate of the first city.
        y1 - The y coordinate of the first city.
        x2 - The x coordinate of the second city.
        y2 - The y coordinate of the second city.
        Returns:
        The distance between the two cities.
      • distanceAsInt

        default int distanceAsInt​(double x1,
                                  double y1,
                                  double x2,
                                  double y2)
        Computes the distance between two cities in the TSP as an integer. Some of the commonly used distance functions in TSP benchmark problem sets assume integer costs, such as Euclidean distance between the end points of an edge rounded to the nearest integer. The default implementation of this method rounds the result of a call to distance(i, j) to the nearest integer.
        Parameters:
        x1 - The x coordinate of the first city.
        y1 - The y coordinate of the first city.
        x2 - The x coordinate of the second city.
        y2 - The y coordinate of the second city.
        Returns:
        The distance between the two cities as an integer.