de.dfki.mycbr.core.similarity
Class AdvancedFloatFct

java.lang.Object
  extended by java.util.Observable
      extended by de.dfki.mycbr.core.similarity.NumberFct
          extended by de.dfki.mycbr.core.similarity.AdvancedFloatFct
All Implemented Interfaces:
ISimFct, java.util.Observer

public class AdvancedFloatFct
extends NumberFct

Used for calculating similarities of FloatAttribute objects. This function can also be used for calculating similarity of ordered symbol attributes. The basis of this function is a simple graph. You can add additional points to this graph. The similarity function is then the interpolation of these points.

Author:
myCBR Team

Constructor Summary
AdvancedFloatFct(Project prj, FloatDesc desc, java.lang.String name)
          Initializes this with the given description.
 
Method Summary
 void addAdditionalPoint(java.lang.Double key, Similarity value)
          Adds the specified point to the list of additional points.
 Similarity calculateSimilarity(Attribute a1, Attribute a2)
          Calculates the similarity of the specified attributes using the interpolated function.
 Similarity calculateSimilarity(float q, float c)
           
 void clone(AttributeDesc descNEW, boolean active)
          Creates a new function which is the same function as this but with a different description, namely descNEW.
 boolean fitsDistance(double x)
           
 java.util.TreeMap<java.lang.Double,Similarity> getAdditionalPoints()
          Returns the map of additional point used to interpolate this function Points are pairs of a double value and a similarity
 double getDiff()
           
 double getMax()
           
 double getMaxForQuotient()
           
 double getMin()
           
 void setDistanceFct(DistanceConfig df)
          Sets the mode of this function to mode
 void setMaxForQuotient(double max)
           
 void update(java.util.Observable arg0, java.lang.Object arg1)
           
 
Methods inherited from class de.dfki.mycbr.core.similarity.NumberFct
getDesc, getDistanceFct, getMultipleConfig, getName, getProject, isSymmetric, setMultipleConfig, setName, setSymmetric
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdvancedFloatFct

public AdvancedFloatFct(Project prj,
                        FloatDesc desc,
                        java.lang.String name)
Initializes this with the given description. This function can only be applied to attributes with this description. The points used for interpolating this function are initialized with standard values.

Parameters:
desc - the description of the attributes to be compared
Method Detail

calculateSimilarity

public Similarity calculateSimilarity(Attribute a1,
                                      Attribute a2)
                               throws java.lang.Exception
Calculates the similarity of the specified attributes using the interpolated function. If the attributes do not have the given description, an invalid similarity is returned.

Parameters:
a1 - the first value
a2 - the second value
Returns:
the similarity of the given attributes or an invalid similarity if an error occurs
Throws:
java.lang.Exception

calculateSimilarity

public Similarity calculateSimilarity(float q,
                                      float c)
                               throws java.lang.Exception
Throws:
java.lang.Exception

getAdditionalPoints

public java.util.TreeMap<java.lang.Double,Similarity> getAdditionalPoints()
Returns the map of additional point used to interpolate this function Points are pairs of a double value and a similarity

Returns:
the map of additional points

addAdditionalPoint

public void addAdditionalPoint(java.lang.Double key,
                               Similarity value)
Adds the specified point to the list of additional points.

Parameters:
key - Double, the distance describing the first coordinate of the new point
value - Similarity used as the value for the second coordinate

getMin

public double getMin()

getMax

public double getMax()

getDiff

public double getDiff()

setDistanceFct

public void setDistanceFct(DistanceConfig df)
Description copied from class: NumberFct
Sets the mode of this function to mode

Overrides:
setDistanceFct in class NumberFct
Parameters:
df - the new mode of this function

clone

public void clone(AttributeDesc descNEW,
                  boolean active)
Description copied from interface: ISimFct
Creates a new function which is the same function as this but with a different description, namely descNEW. Assumption: this function fits the description of descNEW.


update

public void update(java.util.Observable arg0,
                   java.lang.Object arg1)

fitsDistance

public boolean fitsDistance(double x)
Parameters:
x - a value to be checked
Returns:
true, if x is still in the domain defined by desc wrt to the given distance function

getMaxForQuotient

public double getMaxForQuotient()

setMaxForQuotient

public void setMaxForQuotient(double max)