de.unibi.techfak.jpredictor.clustering
Class RelationMeasure

java.lang.Object
  extended by de.unibi.techfak.jpredictor.clustering.RelationMeasure
All Implemented Interfaces:
Computable, java.lang.Comparable
Direct Known Subclasses:
MatrixRelationMeasure, MotifAlignment, VectorRelationMeasure

public abstract class RelationMeasure
extends java.lang.Object
implements java.lang.Comparable, Computable

This class is designed to act as a wrapper for any relation between two or more objects. This relation must be expressable as a number, e.g. as a computable result. In this class the result is stored and can be compared to other results.


Field Summary
(package private)  double computationResult
          The result of the computation is stored here.
 
Fields inherited from interface de.unibi.techfak.jpredictor.clustering.Computable
COMPUTATION_FAILED, COMPUTATION_PENDING, COMPUTATION_SUCCESS, COMPUTATION_WAITING
 
Constructor Summary
RelationMeasure()
           
 
Method Summary
abstract  double atomicCombine(double rel0, double rel1)
           Two relations measures are combined to one result, which is not stored but returned.
 double atomicCombine(java.lang.Object rm)
           Two relations measures are combined to one result, which is not stored but returned.
abstract  double atomicNormalize(double rel, double norm)
           A relations measures is normalized by a certain amount.
 int compareTo(java.lang.Object arg0)
          Compares this results to the result of the given object.
abstract  RelationMeasure newInstance()
          Creates a copy of this relation measure as if it was newly instantiated through a call to the constructor.
abstract  int optimum(double rel0, double rel1)
           Compares two relation measure results.
 int optimum(java.lang.Object rm)
           Compares two result of the given object to the result of this RelationMeasure.
 double result()
          After computation is done the result can be obtained through this method.
abstract  java.lang.String toString()
          Creates a short string of this relation measure and maybe some results if available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.unibi.techfak.jpredictor.clustering.Computable
compute
 

Field Detail

computationResult

double computationResult
The result of the computation is stored here. Its default value is Double.NaN.

Constructor Detail

RelationMeasure

public RelationMeasure()
Method Detail

result

public double result()
After computation is done the result can be obtained through this method. If the result was not computed yet, the compute()-method will be invoked.

Returns:
The result of the computation, if its Double.NaN , the computation is not yet finished.

compareTo

public int compareTo(java.lang.Object arg0)
Compares this results to the result of the given object. The object can either be a RelationsMeasure or a Number. Throws a ClassCastException if it is neither. Returns zero, if both results are Double.NaN. If this result is Double.NaN, but not the given one, -1 is returned. In case of the other way round, 1 is returned. Thus, for ordering of results Double.NaNs are smaller than Double.NEGATIVE_INFINITY.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
arg0 - The result this one is compared to, which must be either another RelationsMeasure or a Number.
Returns:
-1, if this result is smaller, 0 if both are equal and 1, if this result is greater than the given one.
See Also:
Comparable.compareTo(java.lang.Object), Number, Double.isNaN(double), Double.isInfinite(double), Double.NEGATIVE_INFINITY

optimum

public int optimum(java.lang.Object rm)

Compares two result of the given object to the result of this RelationMeasure. The given result can be either a RelationMeasure or a Number-value. Returns -1, zero or 1, if this result is worse, equal, or better than the given one. The terms worse and better depend on the implementation of this RelationMeasure. Usually, when dealing with distances, the lower the better. On the other side, when dealing with likelihoods the higher the better.

Note, that it is possible to mix up optimization of, e.g. distances and likelihoods, since this method works on any RelationMeasure defined.

Parameters:
rm - The result this one is compared to, which must be either another RelationsMeasure or a Number.
Returns:
-1, zero or 1 in case this result is worse, equal or better than the given one.
See Also:
Number

optimum

public abstract int optimum(double rel0,
                            double rel1)

Compares two relation measure results. Returns -1, zero or 1, if the first (rel0) measure is worse, equal, or better than the second one (rel1). The terms worse and better depend on the implementation of the RelationMeasure inheriting this method. Usually, when dealing with distances, the lower the better. On the other side, when dealing with likelihoods the higher the better.

Note, that it is possible to mix up optimization of different relation measures, e.g. distances and likelihoods, since this method works on any numbers.

Parameters:
rel0 - The first relation measure to be compared to the second.
rel1 - The second relation measure to be compared to the first.
Returns:
-1, zero or 1 in case the first result is worse, equal or better than the second one.

atomicCombine

public double atomicCombine(java.lang.Object rm)

Two relations measures are combined to one result, which is not stored but returned. This method provides a way to calculate the combined result, when the way how to do this is not known. For instance, distance relation measures normally sum up over single results while likelihood/probabilities are multiplied.

The given result can be either a RelationMeasure or a Number-value. If this result or the given one evaluates to Double.NaN not-a-number is returned as well. Note, that it is possible to mix up relation measures of, e.g. distances and likelihoods, since this method works on any RelationMeasure defined.

Parameters:
rm - The result this one is combined with, which must be either another RelationsMeasure or a Number.
Returns:
The result of combining two relation measures, e.g. through adding them up, or multiplying them or such.

atomicCombine

public abstract double atomicCombine(double rel0,
                                     double rel1)

Two relations measures are combined to one result, which is not stored but returned. This method provides a way to calculate the combined result, when the way how to do this is not known. For instance, distance relation measures normally sum up over single results while likelihood/probabilities are multiplied.

Note, that it is possible to mix up optimization of different relation measures, e.g. distances and likelihoods, since this method works on any numbers.

Parameters:
rel0 - The first relation measure to be compared to the second.
rel1 - The second relation measure to be compared to the first.
Returns:
The result of combining two relation measures, e.g. through adding them up, or multiplying them or such.

atomicNormalize

public abstract double atomicNormalize(double rel,
                                       double norm)

A relations measures is normalized by a certain amount. This method provides a way to normalize a relation measure after numbers of them were combined. For instance, distance relation measures normally are normalized by dividing through the count, while likelihoods are rooted.

Note, that it is possible to mix up optimization of different relation measures, e.g. distances and likelihoods, since this method works on any numbers.

Parameters:
rel - The relation measure to be normalized.
norm - The normalization value.
Returns:
The result of normalizing a relation measures. Or Double.NaN in case of error.

newInstance

public abstract RelationMeasure newInstance()
Creates a copy of this relation measure as if it was newly instantiated through a call to the constructor. Note: if a class relies on really unique relation measures that are never shared with other instances it should call this method in the constructor. This might be the case, if a class uses a relation measures to store results of partially results.

Returns:
A copy of the relation measure as if it was newly instantiated.

toString

public abstract java.lang.String toString()
Creates a short string of this relation measure and maybe some results if available.

Overrides:
toString in class java.lang.Object
Returns:
A string with a short description of the class.