Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance.distancefunction
Class RepresentationSelectingDistanceFunction<O extends DatabaseObject,M extends MultiRepresentedObject<O>,D extends Distance<D>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
          extended by de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction<O,D>
              extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDistanceFunction<M,D>
                  extended by de.lmu.ifi.dbs.elki.distance.distancefunction.RepresentationSelectingDistanceFunction<O,M,D>
Type Parameters:
M - the type of MultiRepresentedObject to compute the distances in between
O - the type of represented DatabaseObjects
D - the type of Distance used
All Implemented Interfaces:
DistanceFunction<M,D>, MeasurementFunction<M,D>, Parameterizable

public class RepresentationSelectingDistanceFunction<O extends DatabaseObject,M extends MultiRepresentedObject<O>,D extends Distance<D>>
extends AbstractDistanceFunction<M,D>

Distance function for multirepresented objects that selects one representation and computes the distances only within the selected representation.

Author:
Elke Achtert

Field Summary
private  int currentRepresentationIndex
          The index of the current representation.
static String DEFAULT_DISTANCE_FUNCTION
          The default distance function.
private  DistanceFunction<O,D> defaultDistanceFunction
          The default distance function.
static OptionID DISTANCE_FUNCTIONS_ID
          OptionID for DISTANCE_FUNCTIONS_PARAM
private  ClassListParameter<DistanceFunction<O,D>> DISTANCE_FUNCTIONS_PARAM
          Parameter to specify the distance functions
private  List<DistanceFunction<O,D>> distanceFunctions
          The list of distance functions for each representation.
static Pattern SPLIT
          A pattern defining a comma.
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction
INFINITY_PATTERN
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
optionHandler
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug, logger
 
Constructor Summary
RepresentationSelectingDistanceFunction()
          Provides a Distance function for multirepresented objects that selects one representation and computes the distances only within the selected representation.
 
Method Summary
 D distance(M o1, M o2)
          Computes the distance between two given DatabaseObjects according to this distance function.
private  DistanceFunction<O,D> getDistanceFunctionForCurrentRepresentation()
          Returns the distance function for the currently selected representation.
 D infiniteDistance()
          Provides an infinite distance.
 D nullDistance()
          Provides a null distance.
 void setCurrentRepresentationIndex(int index)
          Sets the currently selected representation for which the distances will be computed.
 List<String> setParameters(List<String> args)
          Grabs all specified options from the option handler.
 String shortDescription()
          Returns the required input pattern.
 D undefinedDistance()
          Provides an undefined distance.
 D valueOf(String pattern)
          Provides a measurement suitable to this measurement function based on the given pattern.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDistanceFunction
distance, distance, isInfiniteDistance, isNullDistance, isUndefinedDistance
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction
getDatabase, matches, requiredInputPattern, setDatabase, setRequiredInputPattern
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, addParameterizable, addParameterizable, checkGlobalParameterConstraints, collectOptions, getAttributeSettings, getParameters, rememberParametersExcept, removeOption, removeParameterizable
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.MeasurementFunction
requiredInputPattern, setDatabase
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, collectOptions, getParameters
 

Field Detail

SPLIT

public static final Pattern SPLIT
A pattern defining a comma.


DEFAULT_DISTANCE_FUNCTION

public static final String DEFAULT_DISTANCE_FUNCTION
The default distance function.


DISTANCE_FUNCTIONS_ID

public static final OptionID DISTANCE_FUNCTIONS_ID
OptionID for DISTANCE_FUNCTIONS_PARAM


DISTANCE_FUNCTIONS_PARAM

private final ClassListParameter<DistanceFunction<O extends DatabaseObject,D extends Distance<D>>> DISTANCE_FUNCTIONS_PARAM
Parameter to specify the distance functions


currentRepresentationIndex

private int currentRepresentationIndex
The index of the current representation.


distanceFunctions

private List<DistanceFunction<O extends DatabaseObject,D extends Distance<D>>> distanceFunctions
The list of distance functions for each representation.


defaultDistanceFunction

private DistanceFunction<O extends DatabaseObject,D extends Distance<D>> defaultDistanceFunction
The default distance function.

Constructor Detail

RepresentationSelectingDistanceFunction

public RepresentationSelectingDistanceFunction()
Provides a Distance function for multirepresented objects that selects one representation and computes the distances only within the selected representation.

Method Detail

setCurrentRepresentationIndex

public void setCurrentRepresentationIndex(int index)
Sets the currently selected representation for which the distances will be computed.

Parameters:
index - the index of the representation to be selected

valueOf

public D valueOf(String pattern)
                              throws IllegalArgumentException
Description copied from interface: MeasurementFunction
Provides a measurement suitable to this measurement function based on the given pattern.

Parameters:
pattern - a pattern defining a similarity suitable to this measurement function
Returns:
a measurement suitable to this measurement function based on the given pattern
Throws:
IllegalArgumentException - if the given pattern is not compatible with the requirements of this measurement function

infiniteDistance

public D infiniteDistance()
Description copied from interface: MeasurementFunction
Provides an infinite distance.

Returns:
an infinite distance

nullDistance

public D nullDistance()
Description copied from interface: MeasurementFunction
Provides a null distance.

Returns:
a null distance

undefinedDistance

public D undefinedDistance()
Description copied from interface: MeasurementFunction
Provides an undefined distance.

Returns:
an undefined distance

distance

public D distance(M o1,
                  M o2)
Description copied from interface: DistanceFunction
Computes the distance between two given DatabaseObjects according to this distance function.

Parameters:
o1 - first DatabaseObject
o2 - second DatabaseObject
Returns:
the distance between two given DatabaseObjects according to this distance function

shortDescription

public String shortDescription()
Description copied from class: AbstractMeasurementFunction
Returns the required input pattern.

Specified by:
shortDescription in interface Parameterizable
Overrides:
shortDescription in class AbstractMeasurementFunction<M extends MultiRepresentedObject<O>,D extends Distance<D>>
Returns:
Description of the class

setParameters

public List<String> setParameters(List<String> args)
                           throws ParameterException
Description copied from class: AbstractParameterizable
Grabs all specified options from the option handler. Any extending class should call this method first and return the returned array without further changes, but after setting further required parameters. An example for overwriting this method taking advantage from the previously (in superclasses) defined options would be:

 {
   List remainingParameters = super.setParameters(args);
   // set parameters for your class
   // for example like this:
   if(isSet(MY_PARAM_VALUE_PARAM))
   {
      myParamValue = getParameterValue(MY_PARAM_VALUE_PARAM);
   }
   .
   .
   .
   return remainingParameters;
   // or in case of attributes requesting parameters themselves
   // return parameterizableAttribbute.setParameters(remainingParameters);
 }
 

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
a list containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting

getDistanceFunctionForCurrentRepresentation

private DistanceFunction<O,D> getDistanceFunctionForCurrentRepresentation()
Returns the distance function for the currently selected representation.

Returns:
the distance function for the currently selected representation

Release 0.2.1 (2009-07-13_1605)