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>
All Implemented Interfaces:
DistanceFunction<M,D>, MeasurementFunction<M,D>, Loggable, 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 String DISTANCE_FUNCTIONS_D
          Description for parameter distance functions.
static String DISTANCE_FUNCTIONS_P
          Parameter for 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
 
Constructor Summary
RepresentationSelectingDistanceFunction()
          Provides a Distance function for multirepresented objects that selects one represenation and computes the distances only within the selected representation.
 
Method Summary
 String description()
          Returns a description of the class and the required parameters.
 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.
 String[] setParameters(String[] args)
          Sets the attributes of the class accordingly to the given parameters.
 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, checkGlobalParameterConstraints, deleteOption, description, description, getAttributeSettings, getParameters, getParameterValue, getPossibleOptions, inlineDescription, isSet, setParameters
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, 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, getAttributeSettings, getParameters, getPossibleOptions, inlineDescription
 

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_P

public static final String DISTANCE_FUNCTIONS_P
Parameter for distance functions.

See Also:
Constant Field Values

DISTANCE_FUNCTIONS_D

public static final String DISTANCE_FUNCTIONS_D
Description for parameter 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 represenation 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
See Also:
MeasurementFunction.valueOf(String)

infiniteDistance

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

Returns:
an infinite distance
See Also:
MeasurementFunction.infiniteDistance()

nullDistance

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

Returns:
a null distance
See Also:
MeasurementFunction.nullDistance()

undefinedDistance

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

Returns:
an undefined distance
See Also:
MeasurementFunction.undefinedDistance()

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
See Also:
DistanceFunction.distance(DatabaseObject, DatabaseObject)

description

public String description()
Description copied from interface: Parameterizable
Returns a description of the class and the required parameters.

This description should be suitable for a usage description as for a standalone application.

Specified by:
description in interface Parameterizable
Overrides:
description in class AbstractParameterizable
Returns:
String a description of the class and the required parameters
See Also:
Parameterizable.description()

setParameters

public String[] setParameters(String[] args)
                       throws ParameterException
Description copied from interface: Parameterizable
Sets the attributes of the class accordingly to the given parameters. Returns a new String array containing those entries of the given array that are neither expected nor used by this Parameterizable.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
String[] an array containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting
See Also:
Parameterizable.setParameters(String[])

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.1 (2008-07-10_1838)