edu.indiana.iucbrf.problem.differentiator
Class AbstractProblemDifferentiator

java.lang.Object
  extended by edu.indiana.iucbrf.problem.differentiator.AbstractProblemDifferentiator
All Implemented Interfaces:
ProblemDifferentiator, Differentiator, java.io.Serializable
Direct Known Subclasses:
AverageProblemDifferentiator, CountMismatchProblemDifferentiator, EuclideanProblemDifferentiator

public abstract class AbstractProblemDifferentiator
extends java.lang.Object
implements ProblemDifferentiator

An abstract implementation of the ProblemDifferentiator interface.

See Also:
Serialized Form

Field Summary
protected  java.util.HashSet defaultIndices
          The set of index keys (the problem features used in some types of case base organization).
protected  java.util.HashMap keyToFeatureDifferentiator
          A map from FeatureKey to FeatureDifferentiator, that will override the default FeatureDifferentiator (returned by the FeatureSpec's getDefaultFeatureDifferentiator()) for a Feature's variable type (defined in Feature.getDefaultVariableType()).
protected  DoubleCollection similarityWts
          Similarity weights indicate the relative importance of each problem feature in similarity comparisons.
protected  UnknownFeatureHandler unknownFeatureHandler
           
 
Constructor Summary
protected AbstractProblemDifferentiator()
           
  AbstractProblemDifferentiator(DoubleCollection similarityWts, java.util.HashSet defaultIndices, Domain domain)
          Creates a new instance of AbstractProblemDifferentiator
  AbstractProblemDifferentiator(DoubleCollection similarityWts, java.util.HashSet defaultIndices, UnknownFeatureHandler unknownFeatureHandler, Domain domain)
          Creates a new instance of AbstractProblemDifferentiator
 
Method Summary
 void addSimilarityWeight(FeatureKey featureKey, double similarityWeight)
           
 double calcDifference(java.lang.Object obj1, java.lang.Object obj2)
           
 double calcDifference(java.lang.Object obj1, java.lang.Object obj2, java.util.Collection indicesToUse)
           
protected abstract  double calcDifference(Problem p1, Problem p2, java.util.Collection indicesToUse)
           
 java.util.Iterator defaultIndicesIterator()
           
 boolean equals(java.lang.Object other)
           
 java.util.HashSet getDefaultIndices()
           
 FeatureDifferentiator getFeatureDifferentiator(FeatureKey key)
          Get the feature differentiator for the given feature.
 int getIndexCount()
           
 DoubleCollection getSimilarityWeights()
           
 UnknownFeatureHandler getUnknownFeatureHandler()
           
 int hashCode()
           
 boolean isIndex(FeatureKey key)
           
 void removeFeature(FeatureKey featureKey)
           
 void setIsIndex(FeatureKey key, boolean isIndex)
           
 void setOverridingFeatureDifferentiator(FeatureKey key, FeatureDifferentiator featureDifferentiator)
          Set the feature differentiator for a feature for this problem differentiator to be not the one based on the variable type (as defined in Feature.getDefaultVariableType()), but instead a customized one.
 void setToDefaultFeatureDifferentiator(Domain domain, FeatureKey key)
          Set the feature differentiator to the default for this feature type.
 void setToDefaultFeatureDifferentiator(FeatureSpec spec)
          Set the feature differentiator to the default for this feature type.
 void setUnknownFeatureHandler(UnknownFeatureHandler unknownFeatureHandler)
           
protected  void setupDefaultFeatureDifferentiators(Domain domain)
          Setup the default feature differentiators for any features already in the domain.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

unknownFeatureHandler

protected UnknownFeatureHandler unknownFeatureHandler

similarityWts

protected DoubleCollection similarityWts
Similarity weights indicate the relative importance of each problem feature in similarity comparisons.


defaultIndices

protected java.util.HashSet defaultIndices
The set of index keys (the problem features used in some types of case base organization).


keyToFeatureDifferentiator

protected java.util.HashMap keyToFeatureDifferentiator
A map from FeatureKey to FeatureDifferentiator, that will override the default FeatureDifferentiator (returned by the FeatureSpec's getDefaultFeatureDifferentiator()) for a Feature's variable type (defined in Feature.getDefaultVariableType()).

Constructor Detail

AbstractProblemDifferentiator

protected AbstractProblemDifferentiator()

AbstractProblemDifferentiator

public AbstractProblemDifferentiator(DoubleCollection similarityWts,
                                     java.util.HashSet defaultIndices,
                                     Domain domain)
Creates a new instance of AbstractProblemDifferentiator


AbstractProblemDifferentiator

public AbstractProblemDifferentiator(DoubleCollection similarityWts,
                                     java.util.HashSet defaultIndices,
                                     UnknownFeatureHandler unknownFeatureHandler,
                                     Domain domain)
Creates a new instance of AbstractProblemDifferentiator

Method Detail

setupDefaultFeatureDifferentiators

protected void setupDefaultFeatureDifferentiators(Domain domain)
Setup the default feature differentiators for any features already in the domain.


setIsIndex

public void setIsIndex(FeatureKey key,
                       boolean isIndex)
Specified by:
setIsIndex in interface ProblemDifferentiator

isIndex

public boolean isIndex(FeatureKey key)
Specified by:
isIndex in interface ProblemDifferentiator

removeFeature

public void removeFeature(FeatureKey featureKey)
Specified by:
removeFeature in interface ProblemDifferentiator

getSimilarityWeights

public DoubleCollection getSimilarityWeights()
Specified by:
getSimilarityWeights in interface ProblemDifferentiator

getDefaultIndices

public java.util.HashSet getDefaultIndices()
Specified by:
getDefaultIndices in interface ProblemDifferentiator

addSimilarityWeight

public void addSimilarityWeight(FeatureKey featureKey,
                                double similarityWeight)
Specified by:
addSimilarityWeight in interface ProblemDifferentiator

calcDifference

public double calcDifference(java.lang.Object obj1,
                             java.lang.Object obj2)
Specified by:
calcDifference in interface ProblemDifferentiator
Specified by:
calcDifference in interface Differentiator

calcDifference

public double calcDifference(java.lang.Object obj1,
                             java.lang.Object obj2,
                             java.util.Collection indicesToUse)
Specified by:
calcDifference in interface ProblemDifferentiator

calcDifference

protected abstract double calcDifference(Problem p1,
                                         Problem p2,
                                         java.util.Collection indicesToUse)

getIndexCount

public int getIndexCount()
Specified by:
getIndexCount in interface ProblemDifferentiator

defaultIndicesIterator

public java.util.Iterator defaultIndicesIterator()
Specified by:
defaultIndicesIterator in interface ProblemDifferentiator

setUnknownFeatureHandler

public void setUnknownFeatureHandler(UnknownFeatureHandler unknownFeatureHandler)
Specified by:
setUnknownFeatureHandler in interface ProblemDifferentiator

getUnknownFeatureHandler

public UnknownFeatureHandler getUnknownFeatureHandler()
Specified by:
getUnknownFeatureHandler in interface ProblemDifferentiator

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setToDefaultFeatureDifferentiator

public void setToDefaultFeatureDifferentiator(Domain domain,
                                              FeatureKey key)
Description copied from interface: ProblemDifferentiator
Set the feature differentiator to the default for this feature type. This is called automatically when a problem feature is added to the domain, and may also be called manually to cancel a call to setOverridingFeatureDifferentiator().

Specified by:
setToDefaultFeatureDifferentiator in interface ProblemDifferentiator

setToDefaultFeatureDifferentiator

public void setToDefaultFeatureDifferentiator(FeatureSpec spec)
Description copied from interface: ProblemDifferentiator
Set the feature differentiator to the default for this feature type. This is called automatically when a problem feature is added to the domain, and may also be called manually to cancel a call to setOverridingFeatureDifferentiator().

Specified by:
setToDefaultFeatureDifferentiator in interface ProblemDifferentiator

setOverridingFeatureDifferentiator

public void setOverridingFeatureDifferentiator(FeatureKey key,
                                               FeatureDifferentiator featureDifferentiator)
Description copied from interface: ProblemDifferentiator
Set the feature differentiator for a feature for this problem differentiator to be not the one based on the variable type (as defined in Feature.getDefaultVariableType()), but instead a customized one.

Specified by:
setOverridingFeatureDifferentiator in interface ProblemDifferentiator

getFeatureDifferentiator

public FeatureDifferentiator getFeatureDifferentiator(FeatureKey key)
Description copied from interface: ProblemDifferentiator
Get the feature differentiator for the given feature. If one has not been set using setOverridingFeatureDifferentiator, the default one defined in FeatureSpec.getDefaultFeatureDifferentiator() will be returned.

Specified by:
getFeatureDifferentiator in interface ProblemDifferentiator