de.dfki.mycbr.core.similarity
Class AmalgamationFct

java.lang.Object
  extended by java.util.Observable
      extended by de.dfki.mycbr.core.similarity.AmalgamationFct
All Implemented Interfaces:
java.util.Observer

public class AmalgamationFct
extends java.util.Observable
implements java.util.Observer

This function is used to compute similarity of to ConceptAttribute objects. First the similarity of the attributes of the concepts is computed and then these values are amalgamated using this function. Possible types of amalgamation functions are enumerated in AmalgamationConfig.

Author:
myCBR Team

Constructor Summary
AmalgamationFct(AmalgamationConfig type, Concept c, java.lang.String name)
          Initializes this with the given type, description and inheritance similarity.
 
Method Summary
 Similarity calculateSimilarity(Attribute value1, Attribute value2)
          Returns the similarity of the given SimpleAttribute objects.
 java.lang.Object getActiveFct(AttributeDesc att)
          Gets the active similarity function for this attribute description.
 Concept getConcept()
           
 java.lang.String getName()
          Returns the name of this function.
 Project getProject()
           
 AmalgamationConfig getType()
          The type for the amalgamation.
 java.lang.Number getWeight(AttributeDesc desc)
           
 java.lang.Boolean isActive(AttributeDesc att)
          Attributes may be inactive, meaning that they appear in the model but should not be used for similarity computations.
 void remove(AttributeDesc desc)
           
 void setActive(AttributeDesc att, boolean active)
          Sets this attribute to active or inactive.
 void setActiveFct(AttributeDesc att, java.lang.Object activeSim)
          Sets the active similarity function for this attribute description to activeSim.
 void setName(java.lang.String name)
          Sets the name of this function to name.
 void setType(AmalgamationConfig type)
          Sets the type of this function to type.
 void setWeight(AttributeDesc attDesc, java.lang.Number weight)
          Sets the weight of the given attribute to weight.
 void setWeight(java.lang.String name, java.lang.Number weight)
          Sets the weight of the given attribute to weight.
 void update(java.util.Observable arg0, java.lang.Object arg1)
           
 
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

AmalgamationFct

public AmalgamationFct(AmalgamationConfig type,
                       Concept c,
                       java.lang.String name)
Initializes this with the given type, description and inheritance similarity. Sets the weights of the c's attributes to 1.00. Accessible from inside this package because only the FunctionContainer instance should create AmalgamationFct objects.

Parameters:
type - the amalgamation type (e.g. minimum, maximum, euclidean or weighted sum)
c - the concept to which this function can be applied.
name - the name of this function
Method Detail

getConcept

public Concept getConcept()

calculateSimilarity

public Similarity calculateSimilarity(Attribute value1,
                                      Attribute value2)
                               throws java.lang.Exception
Returns the similarity of the given SimpleAttribute objects. These attributes are assumed to be instance of ConceptAttribute and should have the given description, else an invalid similarity is returned. Currently, there are four amalgamation types supported by this method.

Parameters:
value1 - the query attribute
value2 - the case attribute
Returns:
similarity of the given attributes according to the amalgamation type, invalid similarity if an error occurs
Throws:
java.lang.Exception

getType

public AmalgamationConfig getType()
The type for the amalgamation. At the moment the common and supported types are: Minimum, Maximum, Euclidean and Weighted Sum.

Returns:
the amalgamation type of this function
See Also:
AmalgamationConfig

setType

public void setType(AmalgamationConfig type)
Sets the type of this function to type. Type can be one of: Minimum, Maximum, Euclidean and Weighted Sum.

Parameters:
type -
See Also:
AmalgamationConfig

getName

public java.lang.String getName()
Returns the name of this function.

Returns:
the name of this function.

setName

public void setName(java.lang.String name)
Sets the name of this function to name. Does nothing if there is another function with the given name.

Parameters:
name - the new name of this function.

setWeight

public void setWeight(AttributeDesc attDesc,
                      java.lang.Number weight)
Sets the weight of the given attribute to weight. For some configurations of this function global weights can be used.

Parameters:
attDesc - the description of the attribute whose weight should be set
weight - the new weight of the attribute

setWeight

public void setWeight(java.lang.String name,
                      java.lang.Number weight)
Sets the weight of the given attribute to weight. For some configurations of this function global weights can be used.

Parameters:
name - the name of the attribute description whose weight should be set
weight - the new weight of the attribute

getProject

public Project getProject()

isActive

public java.lang.Boolean isActive(AttributeDesc att)
Attributes may be inactive, meaning that they appear in the model but should not be used for similarity computations. A typical example is the attribute ID to identify an object. It usually does not make sense to define a similarity function for this attribute.

Returns:
true, if this attribute is used for similarity computations, false otherwise

setActive

public void setActive(AttributeDesc att,
                      boolean active)
Sets this attribute to active or inactive. Attributes may be inactive, meaning that they appear in the model but should not be used for similarity computations. A typical example is the attribute ID to identify an object. It usually does not make sense to define a similarity function for this attribute.

Parameters:
active - true, if this attribute is used for similarity computations, false otherwise

setActiveFct

public void setActiveFct(AttributeDesc att,
                         java.lang.Object activeSim)
Sets the active similarity function for this attribute description to activeSim. There may be several similarity functions for this description . However, there is one similarity that is currently used to compute similarities between values of this description. This similarity function is called active similarity function. The attribute (value) itself knows its description and therefore knows how to compute its similarity to other values of the same description.

Parameters:
activeSim - the activeSim to set

getActiveFct

public java.lang.Object getActiveFct(AttributeDesc att)
Gets the active similarity function for this attribute description. There may be several similarity functions for this description maintained by . However, there is one similarity that is currently used to compute similarities between values of this description. This similarity function is called active similarity function. The attribute (value) itself knows its description and therefore knows how to compute its similarity to other values of the same description.

Returns:
the active similarity function currently used to compute similarities between values of this description

remove

public void remove(AttributeDesc desc)

getWeight

public java.lang.Number getWeight(AttributeDesc desc)

update

public void update(java.util.Observable arg0,
                   java.lang.Object arg1)
Specified by:
update in interface java.util.Observer