edu.indiana.iucbrf.domain
Class Domain

java.lang.Object
  extended by edu.indiana.iucbrf.domain.Domain
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CCBRDomain, QuadrantDomain, QuadrantDomainRDB

public class Domain
extends java.lang.Object
implements java.io.Serializable

An Instance of this class is a specification of a domain in which a particular CBR system will be working. Two key components of the Domain are the problem FeatureSpecCollection and solution FeatureSpecCollection, which define the FeatureSpecs for problems and solutions, respectively.

See Also:
Serialized Form

Field Summary
protected  double booleanSolutionCutoff
          Applies only to single-feature solutions, where that feature is boolean.
protected  java.lang.String caseTitleBase
           
protected  ComponentFactory componentFactory
           
protected  DBInfo dbInfo
           
protected  FeatureKeyFactory featureKeyFactory
           
protected  java.lang.String filename
          The filename to save this domain to (optional).
protected  boolean haveBooleanSolutionCutoff
          Applies only to single-feature solutions, where that feature is boolean.
protected  boolean haveReferenceSolution
          True if a reference solution is available, false otherwise.
protected  double minAcceptableQuality
          The minimum "quality" (between 0 and 1 inclusive) that a solution must be judged in order to be called "successful."
protected  ProblemDifferentiator problemDifferentiator
          Similarity weights indicate the relative importance of each problem feature in similarity comparisons.
protected  java.util.LinkedList problemEquivalenceClasses
          The equivalence classes associated with the reference solution (if available).
protected  FeatureSpecCollection problemFeatureSpecCollection
          The set of Feature types
protected  ProblemGenerator problemSpace
          This ProblemGenerator generates a Problem according to the "real-life" distributions of problems.
protected  java.lang.String problemTitle
           
protected  RDBCollectionIDFactory rdbCollectionIDFactory
           
protected  java.lang.String retrievedCasesTitle
           
protected  FeatureSpecCollection solutionFeatureSpecCollection
          The Solution type
protected  java.lang.String solutionTitle
           
protected  java.lang.String title
          The title of this domain (optional).
 
Constructor Summary
Domain()
           
Domain(DBInfo dbInfo, FeatureSpecRDBInfo problemSpecInfo, FeatureSpecRDBInfo solutionSpecInfo, RDBCollectionInfo collectionInfo)
          Construct a domain that will use a database for storage, rather than structures existing in memory.
Domain(DBInfo dbInfo, FeatureSpecRDBInfo problemSpecInfo, FeatureSpecRDBInfo solutionSpecInfo, RDBCollectionInfo collectionInfo, ComponentFactory componentFactory)
          Construct a domain that will use a database for storage, rather than structures existing in memory.
Domain(DBInfo dbInfo, FeatureSpecRDBInfo problemSpecInfo, FeatureSpecRDBInfo solutionSpecInfo, RDBCollectionInfo collectionInfo, ComponentFactory componentFactory, FeatureKeyFactory featureKeyFactory)
          Construct a domain that will use a database for storage, rather than structures existing in memory.
Domain(DBInfo dbInfo, FeatureSpecRDBInfo problemSpecInfo, FeatureSpecRDBInfo solutionSpecInfo, RDBCollectionInfo collectionInfo, FeatureKeyFactory featureKeyFactory)
          Construct a domain that will use a database for storage, rather than structures existing in memory.
Domain(double minAcceptableQuality)
           
Domain(double minAcceptableQuality, ComponentFactory componentFactory)
           
Domain(double minAcceptableQuality, ComponentFactory componentFactory, FeatureKeyFactory featureKeyFactory)
           
Domain(double minAcceptableQuality, FeatureKeyFactory featureKeyFactory)
           
 
Method Summary
 FeatureKey addDisplayMapFeature(java.lang.String featureDescription, java.util.HashMap valueToDisplayMap, int collectionType, double similarityWeight, boolean isIndex)
          A convenience method for adding a DisplayMapFeature.
protected  FeatureKey addFeature(FeatureSpecCollection fsc, java.lang.String featureDescription, java.lang.String featureTypeName)
           
protected  FeatureKey addFeature(FeatureSpecCollection fsc, java.lang.String featureDescription, java.lang.String featureTypeName, FeatureKey featureKey)
           
 void addIndex(FeatureKey key)
           
 FeatureKey addProblemFeature(java.lang.String featureDescription, java.lang.String featureTypeName, double similarityWeight, boolean isIndex)
          Add a problem feature to this domain, after the existing features.
 FeatureKey addProblemFeature(java.lang.String featureDescription, java.lang.String featureTypeName, double similarityWeight, boolean isIndex, FeatureKey featureKey)
          Add a problem feature to this domain, after the existing features.
 void addSimilarityWeight(FeatureKey featureKey, double similarityWeight)
           
 FeatureKey addSolutionFeature(java.lang.String featureDescription, java.lang.String featureTypeName)
           
 FeatureKey addSolutionFeature(java.lang.String featureDescription, java.lang.String featureTypeName, FeatureKey featureKey)
           
 FeatureKey addTableFeature(java.lang.String tableDescription, FeatureKey[] rows, int collectionType, double similarityWeight, boolean isIndex)
          A convenience method for adding a TableFeature
 double calcDifference(Problem p1, Problem p2)
          Determine the difference between two problems in this domain, using this domain's similarity measure.
 void close()
           
 SolutionQuality determineSolutionQuality(Problem p, Solution s, Solution expectedSolution)
          Judge how good a solution is.
protected  boolean equalEquivalenceClasses(Domain otherDomain)
          Determine if this domain and another have the same equivalence classes.
 boolean equals(java.lang.Object obj)
          Determine if two domains are equal.
protected  ProblemEquivalenceClass findNearestEquivalenceClass(Problem p)
          Determine which of this domain's equivalence classes the given problem belongs in.
protected  void finishProblemFeatureAddition(FeatureKey featureKey, double similarityWeight, boolean isIndex)
           
 Problem generateProblem()
          Generate a Problem according to "real-life" distributions specified via setProblemSpace().
 java.lang.String getCaseTitleBase()
           
 ComponentFactory getComponentFactory()
           
 DBInfo getDBInfo()
           
 java.util.LinkedList getEquivalenceClasses()
          Get the LinkedList of reference method equivalence classes for this domain.
 java.lang.String getFeatureDescription(FeatureKey featureKey)
           
 java.lang.String getFeatureDescriptionAsHTML(FeatureKey featureKey)
           
 FeatureInputPanel getFeatureInputPanel(FeatureKey featureKey, int collectionType, boolean allowUnknowns)
           
 FeatureInputPanel getFeatureInputPanel(int collectionType, FeatureKey featureKey, java.lang.Class featureType, boolean allowUnknowns)
           
 FeatureKeyFactory getFeatureKeyFactory()
           
 FeatureSpecCollection getFeatureSpecCollection(int collectionType)
           
 java.lang.String getFilename()
           
 double getMinAcceptableQuality()
          Get the minimum quality a solution must be to be judged "successful".
 int getNumberOfEquivalenceClasses()
          Get the number of reference method equivalence classes for this domain.
 ProblemDifferentiator getProblemDifferentiator()
           
 int getProblemFeatureCount()
          Get the number of features in this domain.
 FeatureInputPanel getProblemFeatureInputPanel(FeatureKey featureKey, boolean allowUnknowns)
           
 FeatureSpecCollection getProblemFeatureSpecCollection()
          Get the list of problem feature types for this domain.
 java.lang.Class getProblemFeatureType(FeatureKey featureKey)
          Get the problem feature class of this domain at the specified index.
 java.lang.String getProblemTitle()
           
 RDBCollectionIDFactory getRDBCollectionIDFactory()
           
 Solution getReferenceSolution(Problem p)
          Obtain a solution to a problem according to some reference technique.
 java.lang.String getRetrievedCasesTitle()
           
 int getSolutionFeatureCount()
          Get the number of features in a solution in this domain.
 FeatureInputPanel getSolutionFeatureInputPanel(FeatureKey featureKey, boolean allowUnknowns)
           
 FeatureSpecCollection getSolutionFeatureSpecCollection()
          Get the list of solution feature types for this domain.
 java.lang.Class getSolutionFeatureType(FeatureKey featureKey)
          Get the problem feature class of this domain at the specified index.
 java.lang.String getSolutionTitle()
           
 java.lang.reflect.Constructor getStandardConstructor(FeatureKey featureKey, int collectionType)
           
 java.lang.String getTitle()
           
 int hashCode()
          Calculate a hash code based on the problem Class, the feature classes, and the solution class.
 boolean haveReferenceSolution()
          Returns true if a reference solution has been specified for this domain, false otherwise.
 boolean isProblemSpaceSet()
          Returns true if a problem space has been specified for this domain, or false if not.
 void registerExtraFeatureSpecData(FeatureKey featureKey, java.lang.Object dataKey, java.lang.Object data, int collectionType)
           
 void removeProblemFeature(FeatureKey key)
           
 void removeSolutionFeature(FeatureKey key)
           
 void replaceFeature(FeatureSpecCollection fsc, FeatureSpec newSpec)
          Replaces the FeatureSpec with key newSpec.getFeatureKey() with newSpec.
 void replaceFeature(FeatureSpecCollection fsc, FeatureSpec newSpec, boolean newIsIndex)
          Replaces the FeatureSpec with key newSpec.getFeatureKey() with newSpec.
 void replaceFeature(FeatureSpecCollection fsc, FeatureSpec newSpec, double newSimWeight)
          Replaces the FeatureSpec with key newSpec.getFeatureKey() with newSpec.
 void replaceFeature(FeatureSpecCollection fsc, FeatureSpec newSpec, double simWeight, boolean isIndex)
          Replaces the FeatureSpec with key newSpec.getFeatureKey() with newSpec.
 void setBooleanSolutionCutoff(double booleanSolutionCutoff)
          Applies only to single-feature solutions, where that feature is boolean.
 void setCaseTitleBase(java.lang.String caseTitleBase)
           
 void setDBInfo(DBInfo dbInfo)
           
 void setEquivalenceClasses(java.util.LinkedList problemEquivalenceClasses)
          Assign the equivalence classes for this domain's getReferenceSolution().
 void setEquivalenceClasses(java.util.LinkedList problemEquivalenceClasses, double booleanSolutionCutoff)
           
 void setFeatureValueFormat(FeatureKey featureKey, FeatureValueFormat format, int collectionType)
           
 void setFilename(java.lang.String filename)
          The name of the file for saving this domain.
 void setMinAcceptableQuality(double minAcceptableQuality)
           
 void setProblemDifferentiator(ProblemDifferentiator problemDifferentiator)
           
 void setProblemSpace(ProblemGenerator pg)
          Define the problem space for this domain.
 void setProblemTitle(java.lang.String problemTitle)
           
 void setRetrievedCasesTitle(java.lang.String retrievedCasesTitle)
           
 void setSolutionTitle(java.lang.String solutionTitle)
           
 void setStandardConstructor(FeatureKey featureKey, int collectionType, java.lang.String[] argTypes)
           
 void setTitle(java.lang.String title)
          Set the title of this domain.
protected  void standardInit(DBInfo dbInfo, RDBCollectionInfo collectionInfo, double minAcceptableQuality, double[] givenSimilarityWts, java.util.HashSet indexKeys)
           
protected  void standardInit(double minAcceptableQuality, double[] givenSimilarityWts, java.util.HashSet indexKeys)
           
 java.lang.String toString()
          Get a String representation of this domain.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

problemFeatureSpecCollection

protected FeatureSpecCollection problemFeatureSpecCollection
The set of Feature types


solutionFeatureSpecCollection

protected FeatureSpecCollection solutionFeatureSpecCollection
The Solution type


problemEquivalenceClasses

protected java.util.LinkedList problemEquivalenceClasses
The equivalence classes associated with the reference solution (if available).


minAcceptableQuality

protected double minAcceptableQuality
The minimum "quality" (between 0 and 1 inclusive) that a solution must be judged in order to be called "successful."


haveReferenceSolution

protected boolean haveReferenceSolution
True if a reference solution is available, false otherwise.


problemDifferentiator

protected ProblemDifferentiator problemDifferentiator
Similarity weights indicate the relative importance of each problem feature in similarity comparisons.


componentFactory

protected ComponentFactory componentFactory

featureKeyFactory

protected FeatureKeyFactory featureKeyFactory

rdbCollectionIDFactory

protected RDBCollectionIDFactory rdbCollectionIDFactory

title

protected java.lang.String title
The title of this domain (optional).


problemTitle

protected java.lang.String problemTitle

solutionTitle

protected java.lang.String solutionTitle

retrievedCasesTitle

protected java.lang.String retrievedCasesTitle

caseTitleBase

protected java.lang.String caseTitleBase

filename

protected java.lang.String filename
The filename to save this domain to (optional).


problemSpace

protected ProblemGenerator problemSpace
This ProblemGenerator generates a Problem according to the "real-life" distributions of problems. It is optionally specified via setProblemSpace(). This instance variable and associated methods were suggested in part by Peter Siniakov.


dbInfo

protected DBInfo dbInfo

booleanSolutionCutoff

protected double booleanSolutionCutoff
Applies only to single-feature solutions, where that feature is boolean.


haveBooleanSolutionCutoff

protected boolean haveBooleanSolutionCutoff
Applies only to single-feature solutions, where that feature is boolean.

Constructor Detail

Domain

public Domain()

Domain

public Domain(double minAcceptableQuality)

Domain

public Domain(double minAcceptableQuality,
              FeatureKeyFactory featureKeyFactory)

Domain

public Domain(double minAcceptableQuality,
              ComponentFactory componentFactory)

Domain

public Domain(double minAcceptableQuality,
              ComponentFactory componentFactory,
              FeatureKeyFactory featureKeyFactory)

Domain

public Domain(DBInfo dbInfo,
              FeatureSpecRDBInfo problemSpecInfo,
              FeatureSpecRDBInfo solutionSpecInfo,
              RDBCollectionInfo collectionInfo)
Construct a domain that will use a database for storage, rather than structures existing in memory.


Domain

public Domain(DBInfo dbInfo,
              FeatureSpecRDBInfo problemSpecInfo,
              FeatureSpecRDBInfo solutionSpecInfo,
              RDBCollectionInfo collectionInfo,
              ComponentFactory componentFactory)
Construct a domain that will use a database for storage, rather than structures existing in memory.


Domain

public Domain(DBInfo dbInfo,
              FeatureSpecRDBInfo problemSpecInfo,
              FeatureSpecRDBInfo solutionSpecInfo,
              RDBCollectionInfo collectionInfo,
              FeatureKeyFactory featureKeyFactory)
Construct a domain that will use a database for storage, rather than structures existing in memory.


Domain

public Domain(DBInfo dbInfo,
              FeatureSpecRDBInfo problemSpecInfo,
              FeatureSpecRDBInfo solutionSpecInfo,
              RDBCollectionInfo collectionInfo,
              ComponentFactory componentFactory,
              FeatureKeyFactory featureKeyFactory)
Construct a domain that will use a database for storage, rather than structures existing in memory.

Method Detail

standardInit

protected void standardInit(double minAcceptableQuality,
                            double[] givenSimilarityWts,
                            java.util.HashSet indexKeys)

standardInit

protected void standardInit(DBInfo dbInfo,
                            RDBCollectionInfo collectionInfo,
                            double minAcceptableQuality,
                            double[] givenSimilarityWts,
                            java.util.HashSet indexKeys)

close

public void close()

getComponentFactory

public ComponentFactory getComponentFactory()

setProblemDifferentiator

public void setProblemDifferentiator(ProblemDifferentiator problemDifferentiator)

getProblemDifferentiator

public ProblemDifferentiator getProblemDifferentiator()

setDBInfo

public void setDBInfo(DBInfo dbInfo)

getDBInfo

public DBInfo getDBInfo()

removeProblemFeature

public void removeProblemFeature(FeatureKey key)

replaceFeature

public void replaceFeature(FeatureSpecCollection fsc,
                           FeatureSpec newSpec)
Replaces the FeatureSpec with key newSpec.getFeatureKey() with newSpec.


replaceFeature

public void replaceFeature(FeatureSpecCollection fsc,
                           FeatureSpec newSpec,
                           double newSimWeight)
Replaces the FeatureSpec with key newSpec.getFeatureKey() with newSpec.


replaceFeature

public void replaceFeature(FeatureSpecCollection fsc,
                           FeatureSpec newSpec,
                           boolean newIsIndex)
Replaces the FeatureSpec with key newSpec.getFeatureKey() with newSpec.


replaceFeature

public void replaceFeature(FeatureSpecCollection fsc,
                           FeatureSpec newSpec,
                           double simWeight,
                           boolean isIndex)
Replaces the FeatureSpec with key newSpec.getFeatureKey() with newSpec.


removeSolutionFeature

public void removeSolutionFeature(FeatureKey key)

registerExtraFeatureSpecData

public void registerExtraFeatureSpecData(FeatureKey featureKey,
                                         java.lang.Object dataKey,
                                         java.lang.Object data,
                                         int collectionType)

addDisplayMapFeature

public FeatureKey addDisplayMapFeature(java.lang.String featureDescription,
                                       java.util.HashMap valueToDisplayMap,
                                       int collectionType,
                                       double similarityWeight,
                                       boolean isIndex)
A convenience method for adding a DisplayMapFeature. If it is being added to a solution feature collection, then similarityWeight and isIndex are ignored.


addTableFeature

public FeatureKey addTableFeature(java.lang.String tableDescription,
                                  FeatureKey[] rows,
                                  int collectionType,
                                  double similarityWeight,
                                  boolean isIndex)
A convenience method for adding a TableFeature


addProblemFeature

public FeatureKey addProblemFeature(java.lang.String featureDescription,
                                    java.lang.String featureTypeName,
                                    double similarityWeight,
                                    boolean isIndex)
Add a problem feature to this domain, after the existing features. Does not update any existing problemSpace, nor the problem equivalence classes for the reference solution.

Returns:
the FeatureKey assigned to the new feature.

addProblemFeature

public FeatureKey addProblemFeature(java.lang.String featureDescription,
                                    java.lang.String featureTypeName,
                                    double similarityWeight,
                                    boolean isIndex,
                                    FeatureKey featureKey)
Add a problem feature to this domain, after the existing features. Does not update any existing problemSpace, nor the problem equivalence classes for the reference solution. This method should be used when a FeatureKey is already available, and the FeatureKeyFactory should not be used. Note that the FeatureKey must be unique!

Parameters:
featureValueFormat - may be null if no special formatting is required
Returns:
the FeatureKey assigned to the new feature.

finishProblemFeatureAddition

protected void finishProblemFeatureAddition(FeatureKey featureKey,
                                            double similarityWeight,
                                            boolean isIndex)

addFeature

protected FeatureKey addFeature(FeatureSpecCollection fsc,
                                java.lang.String featureDescription,
                                java.lang.String featureTypeName)

addFeature

protected FeatureKey addFeature(FeatureSpecCollection fsc,
                                java.lang.String featureDescription,
                                java.lang.String featureTypeName,
                                FeatureKey featureKey)

addSolutionFeature

public FeatureKey addSolutionFeature(java.lang.String featureDescription,
                                     java.lang.String featureTypeName,
                                     FeatureKey featureKey)

addSolutionFeature

public FeatureKey addSolutionFeature(java.lang.String featureDescription,
                                     java.lang.String featureTypeName)

setFeatureValueFormat

public void setFeatureValueFormat(FeatureKey featureKey,
                                  FeatureValueFormat format,
                                  int collectionType)

setTitle

public void setTitle(java.lang.String title)
Set the title of this domain.


getTitle

public java.lang.String getTitle()

setSolutionTitle

public void setSolutionTitle(java.lang.String solutionTitle)

getSolutionTitle

public java.lang.String getSolutionTitle()

setProblemTitle

public void setProblemTitle(java.lang.String problemTitle)

getProblemTitle

public java.lang.String getProblemTitle()

setRetrievedCasesTitle

public void setRetrievedCasesTitle(java.lang.String retrievedCasesTitle)

getRetrievedCasesTitle

public java.lang.String getRetrievedCasesTitle()

setCaseTitleBase

public void setCaseTitleBase(java.lang.String caseTitleBase)

getCaseTitleBase

public java.lang.String getCaseTitleBase()

getFeatureKeyFactory

public FeatureKeyFactory getFeatureKeyFactory()

getRDBCollectionIDFactory

public RDBCollectionIDFactory getRDBCollectionIDFactory()

setFilename

public void setFilename(java.lang.String filename)
The name of the file for saving this domain. It is recommended that the file have the extension .dom


getFilename

public java.lang.String getFilename()

isProblemSpaceSet

public boolean isProblemSpaceSet()
Returns true if a problem space has been specified for this domain, or false if not.


setProblemSpace

public void setProblemSpace(ProblemGenerator pg)
Define the problem space for this domain. The problem space is a ProblemGenerator that generates a Problem according to the "real-life" distributions of problems. After this method is called, generateProblem() can be called as desired. This method and associated methods were suggested in part by Peter Siniakov.


generateProblem

public Problem generateProblem()
                        throws ProblemSpaceNotSpecifiedException
Generate a Problem according to "real-life" distributions specified via setProblemSpace(). Throws ProblemSpaceNotSpecifiedException if setProblemSpace() has not been called prior to this method.

Throws:
ProblemSpaceNotSpecifiedException

getProblemFeatureInputPanel

public FeatureInputPanel getProblemFeatureInputPanel(FeatureKey featureKey,
                                                     boolean allowUnknowns)

getSolutionFeatureInputPanel

public FeatureInputPanel getSolutionFeatureInputPanel(FeatureKey featureKey,
                                                      boolean allowUnknowns)

getFeatureInputPanel

public FeatureInputPanel getFeatureInputPanel(FeatureKey featureKey,
                                              int collectionType,
                                              boolean allowUnknowns)

getFeatureInputPanel

public FeatureInputPanel getFeatureInputPanel(int collectionType,
                                              FeatureKey featureKey,
                                              java.lang.Class featureType,
                                              boolean allowUnknowns)

getProblemFeatureType

public java.lang.Class getProblemFeatureType(FeatureKey featureKey)
Get the problem feature class of this domain at the specified index.


getProblemFeatureSpecCollection

public FeatureSpecCollection getProblemFeatureSpecCollection()
Get the list of problem feature types for this domain.


getSolutionFeatureType

public java.lang.Class getSolutionFeatureType(FeatureKey featureKey)
Get the problem feature class of this domain at the specified index.


getSolutionFeatureSpecCollection

public FeatureSpecCollection getSolutionFeatureSpecCollection()
Get the list of solution feature types for this domain.


getFeatureSpecCollection

public FeatureSpecCollection getFeatureSpecCollection(int collectionType)

getProblemFeatureCount

public int getProblemFeatureCount()
Get the number of features in this domain.


getSolutionFeatureCount

public int getSolutionFeatureCount()
Get the number of features in a solution in this domain.


setBooleanSolutionCutoff

public void setBooleanSolutionCutoff(double booleanSolutionCutoff)
Applies only to single-feature solutions, where that feature is boolean. When a solution as a double is obtained, any value less than booleanSolutionCutoff is deemed false, true otherwise.


getEquivalenceClasses

public java.util.LinkedList getEquivalenceClasses()
Get the LinkedList of reference method equivalence classes for this domain.


getNumberOfEquivalenceClasses

public int getNumberOfEquivalenceClasses()
Get the number of reference method equivalence classes for this domain.


getMinAcceptableQuality

public double getMinAcceptableQuality()
Get the minimum quality a solution must be to be judged "successful".


setMinAcceptableQuality

public void setMinAcceptableQuality(double minAcceptableQuality)

haveReferenceSolution

public boolean haveReferenceSolution()
Returns true if a reference solution has been specified for this domain, false otherwise.


setStandardConstructor

public void setStandardConstructor(FeatureKey featureKey,
                                   int collectionType,
                                   java.lang.String[] argTypes)

getStandardConstructor

public java.lang.reflect.Constructor getStandardConstructor(FeatureKey featureKey,
                                                            int collectionType)

getReferenceSolution

public Solution getReferenceSolution(Problem p)
                              throws java.lang.UnsupportedOperationException
Obtain a solution to a problem according to some reference technique. This reference technique is specified by a set of ProblemEquivalenceClass objects. The general format is as follows: For a given problem, find which problem equivalence class it belongs to in the problem space, based on distance from equivalence class prototypes. Once an equivalence class membership is determined, apply a linear combination of that class' weights to the problem's feature vector to obtain a solution represented as a double. Then construct a solution based on that double, as specified in this domain.

The primary use of this method is in evaluation of generated domains and toy domains. In this case it can be useful for initial CB generation and for the final evaluation of the system's solution. Of course, in most real domains, such a method is not available. In that case, initial CB generation will need to occur in some other way (such as from case experience built up in the "real world"), and determineSolutionQuality() will need to be overridden to judge a solution in some other way.

If the reference solution has not been specified (that is, the problem equivalence classes have not been set), then invoking this method will result in an UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException

hashCode

public int hashCode()
Calculate a hash code based on the problem Class, the feature classes, and the solution class.

Note: Everytime a Class object is obtained from a String (using edu.indiana.util.ClassUtils.getClass(), or using Class.forName() directly), it is the very same Class object that is returned (not a copy). This means the returned Class object will always have the same hash code, which is crucial for the hashCode() implemented here. That is, two domains with the same Class objects will have the same hash codes.

When two domains have the same hash code, it means they might be the same domain (and only one of them should be present in a HashSet). If two domain hash codes are the same, the HashSet implementation then calls Domain.equals() (a more refined check) to determine if the domains are truly the same or not. If they are truly the same, then only one will be allowed in the set, as desired in the DomainSetGenerator implementation.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Determine if two domains are equal. This method may be used independently, but is also used in DomainSetGenerator by the HashSet implementation. See Domain.hashCode() for details. Two Domains are considered equal iff:
- Their feature vectors consist of the same feature types in the same order.
- They use the same Problem class
- They use the same Solution class
- Their lists of problem equivalence classes are equal
- Their similarity weights are equal

Overrides:
equals in class java.lang.Object

equalEquivalenceClasses

protected boolean equalEquivalenceClasses(Domain otherDomain)
Determine if this domain and another have the same equivalence classes.


determineSolutionQuality

public SolutionQuality determineSolutionQuality(Problem p,
                                                Solution s,
                                                Solution expectedSolution)
Judge how good a solution is. In this implementation, the found solution is compared to the expected solution, with differences penalized. 1.0 is a perfect rating. Lower ratings are worse, and negative ratings are possible, depending on the values of the found solution and expected solution.


setEquivalenceClasses

public void setEquivalenceClasses(java.util.LinkedList problemEquivalenceClasses)
Assign the equivalence classes for this domain's getReferenceSolution().


setEquivalenceClasses

public void setEquivalenceClasses(java.util.LinkedList problemEquivalenceClasses,
                                  double booleanSolutionCutoff)

findNearestEquivalenceClass

protected ProblemEquivalenceClass findNearestEquivalenceClass(Problem p)
Determine which of this domain's equivalence classes the given problem belongs in.


calcDifference

public double calcDifference(Problem p1,
                             Problem p2)
Determine the difference between two problems in this domain, using this domain's similarity measure.


getFeatureDescription

public java.lang.String getFeatureDescription(FeatureKey featureKey)

getFeatureDescriptionAsHTML

public java.lang.String getFeatureDescriptionAsHTML(FeatureKey featureKey)

toString

public java.lang.String toString()
Get a String representation of this domain.

Overrides:
toString in class java.lang.Object

addSimilarityWeight

public void addSimilarityWeight(FeatureKey featureKey,
                                double similarityWeight)

addIndex

public void addIndex(FeatureKey key)