C# Class SharpNeat.DistanceMetrics.ManhattanDistanceMetric

Manhattan distance metric. The Manhattan distance is simply the sum total of all of the distances in each dimension. Also known as the taxicab distance, rectilinear distance, L1 distance or L1 norm. Use the default constructor for classical Manhattan Distance. Optionally the constructor can be provided with a two coefficients and a constant that can be used to modify/distort distance measures. These are: matchDistanceCoeff - When comparing two positions in the same dimension the distance between those two position is multiplied by this coefficient. mismatchDistanceCoeff, mismatchDistanceConstant - When comparing two coordinates where one describes a position in a given dimension and the other does not then the second coordinate is assumed to be at position zero in that dimension. However, the resulting distance is multiplied by this coefficient and mismatchDistanceConstant is added, therefore allowing matches and mismatches to be weighted differently, e.g. more emphasis can be placed on mismatches (and therefore network topology). If mismatchDistanceCoeff is zero and mismatchDistanceConstant is non-zero then the distance of mismatches is a fixed value. The two coefficients and constant allow the following schemes: 1) Classical Manhattan distance. 2) Topology only distance metric (ignore connections weights). 3) Equivalent of genome distance in Original NEAT (O-NEAT). This is actually a mix of (1) and (2).
Inheritance: IDistanceMetric
Datei anzeigen Open project: colgreen/sharpneat Class Usage Examples

Public Methods

Method Description
CalculateCentroid ( IList coordList ) : CoordinateVector

Calculates the centroid for the given set of points. The centroid is a central position within a set of points that minimizes the sum of the squared distance between each of those points and the centroid. As such it can also be thought of as being an exemplar for a set of points. The centroid calculation is dependent on the distance metric, hence this method is defined on IDistanceMetric. For some distance metrics the centroid may not be a unique point, in those cases one of the possible centroids is returned. A centroid is used in k-means clustering to define the center of a cluster.

CalculateCentroidParallel ( IList coordList ) : CoordinateVector

Parallelized version of CalculateCentroid().

ManhattanDistanceMetric ( ) : System

Constructs using default weightings for comparisons on matching and mismatching dimensions. Classical Manhattan Distance.

ManhattanDistanceMetric ( double matchDistanceCoeff, double mismatchDistanceCoeff, double mismatchDistanceConstant ) : System

Constructs using the provided weightings for comparisons on matching and mismatching dimensions.

MeasureDistance ( CoordinateVector p1, CoordinateVector p2, double threshold ) : bool

Tests if the distance between two positions is less than some threshold. A simple way of implementing this method would be to calculate the distance between the two coordinates and test if it is less than the threshold. However, that approach requires that all of the elements in both CoordinateVectors be fully compared. We can improve performance in the general case by testing if the threshold has been passed after each vector element comparison thus allowing an early exit from the method for many calls. Further to this, we can begin comparing from the ends of the vectors where differences are most likely to occur.

MeasureDistance ( CoordinateVector p1, CoordinateVector p2 ) : double

Measures the distance between two positions.

Method Details

CalculateCentroid() public method

Calculates the centroid for the given set of points. The centroid is a central position within a set of points that minimizes the sum of the squared distance between each of those points and the centroid. As such it can also be thought of as being an exemplar for a set of points. The centroid calculation is dependent on the distance metric, hence this method is defined on IDistanceMetric. For some distance metrics the centroid may not be a unique point, in those cases one of the possible centroids is returned. A centroid is used in k-means clustering to define the center of a cluster.
public CalculateCentroid ( IList coordList ) : CoordinateVector
coordList IList
return SharpNeat.Core.CoordinateVector

CalculateCentroidParallel() public method

Parallelized version of CalculateCentroid().
public CalculateCentroidParallel ( IList coordList ) : CoordinateVector
coordList IList
return SharpNeat.Core.CoordinateVector

ManhattanDistanceMetric() public method

Constructs using default weightings for comparisons on matching and mismatching dimensions. Classical Manhattan Distance.
public ManhattanDistanceMetric ( ) : System
return System

ManhattanDistanceMetric() public method

Constructs using the provided weightings for comparisons on matching and mismatching dimensions.
public ManhattanDistanceMetric ( double matchDistanceCoeff, double mismatchDistanceCoeff, double mismatchDistanceConstant ) : System
matchDistanceCoeff double A coefficient to applied to the distance obtained from two coordinates that both /// describe a position in a given dimension.
mismatchDistanceCoeff double A coefficient applied to the distance obtained from two coordinates where only one of the coordinates describes /// a position in a given dimension. The other point is taken to be at position zero in that dimension.
mismatchDistanceConstant double A constant that is added to the distance where only one of the coordinates describes a position in a given dimension. /// This adds extra emphasis to distance when comparing coordinates that exist in different dimensions.
return System

MeasureDistance() public method

Tests if the distance between two positions is less than some threshold. A simple way of implementing this method would be to calculate the distance between the two coordinates and test if it is less than the threshold. However, that approach requires that all of the elements in both CoordinateVectors be fully compared. We can improve performance in the general case by testing if the threshold has been passed after each vector element comparison thus allowing an early exit from the method for many calls. Further to this, we can begin comparing from the ends of the vectors where differences are most likely to occur.
public MeasureDistance ( CoordinateVector p1, CoordinateVector p2, double threshold ) : bool
p1 SharpNeat.Core.CoordinateVector
p2 SharpNeat.Core.CoordinateVector
threshold double
return bool

MeasureDistance() public method

Measures the distance between two positions.
public MeasureDistance ( CoordinateVector p1, CoordinateVector p2 ) : double
p1 SharpNeat.Core.CoordinateVector
p2 SharpNeat.Core.CoordinateVector
return double