Class CachedDistanceMeasure<T>
java.lang.Object
org.moeaframework.util.clustering.CachedDistanceMeasure<T>
- Type Parameters:
T
- the type of object being stored
- All Implemented Interfaces:
DistanceMeasure<T>
Wraps a
DistanceMeasure
to cache or memoize the calculations in memory. This is similar to using a
precomputed distance matrix, except the distance calculations are performed lazily.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.moeaframework.util.clustering.DistanceMeasure
DistanceMeasure.ApacheDistanceMeasure<T extends org.apache.commons.math3.ml.clustering.Clusterable>
-
Constructor Summary
ConstructorDescriptionCachedDistanceMeasure
(DistanceMeasure<T> distanceMeasure, boolean isSymmetric) Wraps the provided distance measure with a cached version. -
Method Summary
-
Constructor Details
-
CachedDistanceMeasure
Wraps the provided distance measure with a cached version.- Parameters:
distanceMeasure
- the uncached distance measureisSymmetric
-true
if the distance measure is symmetric; seeCachedDistanceMeasure
for the definition of symmetry.
-
-
Method Details
-
compute
Description copied from interface:DistanceMeasure
Returns the distance between the two objects.- Specified by:
compute
in interfaceDistanceMeasure<T>
- Parameters:
first
- the first objectsecond
- the second object- Returns:
- the distance
-