edu.indiana.iucbrf.casepackage
Class CaseDifferencePairImpl

java.lang.Object
  extended by edu.indiana.iucbrf.casepackage.Case
      extended by edu.indiana.iucbrf.casepackage.CaseDifferencePairImpl
All Implemented Interfaces:
CaseDifferencePair, SwingRepresentableWithDomain, SwingRepresentable, java.io.Serializable, java.lang.Comparable

public class CaseDifferencePairImpl
extends Case
implements CaseDifferencePair, java.io.Serializable

This is a container class, which holds a Case and the difference between that case and some problem.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.indiana.iucbrf.casepackage.Case
CASE_KEY_NOT_SET, caseKey, inactiveContexts, p, problemCountAtAddition, s, source, successfulUseCount, useCount
 
Fields inherited from interface edu.indiana.util.swing.SwingRepresentable
TITLE_FONT
 
Constructor Summary
protected CaseDifferencePairImpl()
           
  CaseDifferencePairImpl(Case c, double diff)
           
 
Method Summary
 void applyFeatureNoise(FeatureKey featureKey, Distribution distribution)
          Apply noise, according to the given distribution, to the given feature.
 void applySolutionNoise(Distribution distribution)
          Apply noise, according to the given distribution, to the solution of this case.
 int compareTo(java.lang.Object p1)
          Compare "this" with the parameter (a CaseDifferencePair).
 ProblemIndices constructIndices(Domain domain)
          Constructs a ProblemIndices object using an IndicesIterator.
 boolean equals(java.lang.Object other)
          Returns true if this case equals the given case; false otherwise.
 void fromXML(java.lang.String XMLString)
           
 Case getCase()
           
 double getCaseAge(PerformanceMonitor monitor)
          Returns the number of problem-solving episodes, since this case was added, that have been seen by the system monitored by the given monitor.
 long getCaseKey()
           
 CaseSource getCaseSource()
          Get the source of this case.
 double getDifference()
           
 java.util.HashSet getInactiveContexts()
          Method getInactiveContexts
 Problem getProblem()
          Get the Problem object for this case.
 double getProblemCountAtAddition()
           
 Solution getSolution()
          Get the Solution object for this case.
 int getSuccessfulUseCount()
          For performance monitoring purposes, get the number of times this case has been used successfully.
 java.lang.String getTitle()
          Get the title of this case.
 int getUseCount()
          For performance monitoring purposes, get the number of times this case has been used.
 boolean hasCaseKey()
           
 boolean hasSolution()
          Report if this case has a solution.
 boolean isActive(Context context)
          Determine if this case is active for the given context.
 void markCaseUsed()
          For performance monitoring purposes, indicate that this case has been used - sent for adaptation, perhaps along with other cases.
 void markCaseUsedSuccessfully()
          For performance monitoring purposes, indicate that this case has been used, and that use has lead to a "successful" solution.
 javax.swing.JComponent miscToSwing()
           
 void resetCounts()
          Reset the use, successful use, and problemCountAtAddition trackers for this case, to 0.
 void setActive(Context context)
          Make this case active for the given context.
 void setCaseKey(long caseKey)
           
 void setCaseSource(CaseSource source)
          Set the source of this case.
 void setDifference(double diff)
           
 void setInactive(Context context)
          Make this case inactive for the given context.
 void setProblem(Problem newProblem)
          Set the problem of this case.
 void setSolution(Solution newSolution)
          Set the solution of this case.
 void setTitle(java.lang.String title)
          Set the title of this case.
 java.lang.String toString()
          Get a string representation of this CaseDifferencePairImpl
 java.lang.String toString(Domain domain)
           
 javax.swing.JComponent toSwing(Domain domain)
           
 javax.swing.JComponent toSwing(int detailLevel)
          Detail level may be ignored by implementations.
protected  javax.swing.JComponent toSwing(javax.swing.JComponent caseAsSwing)
           
 java.lang.String toXML(Domain domain)
           
 
Methods inherited from class edu.indiana.iucbrf.casepackage.Case
setInactiveContexts, toString, toSwing
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CaseDifferencePairImpl

protected CaseDifferencePairImpl()

CaseDifferencePairImpl

public CaseDifferencePairImpl(Case c,
                              double diff)
Method Detail

setCaseKey

public void setCaseKey(long caseKey)
Overrides:
setCaseKey in class Case

getCaseKey

public long getCaseKey()
Overrides:
getCaseKey in class Case

hasCaseKey

public boolean hasCaseKey()
Overrides:
hasCaseKey in class Case

constructIndices

public ProblemIndices constructIndices(Domain domain)
Description copied from class: Case
Constructs a ProblemIndices object using an IndicesIterator. If only iteration of indices is desired, then use indicesIterator() instead, for slightly greater efficiency.

Overrides:
constructIndices in class Case

getTitle

public java.lang.String getTitle()
Description copied from class: Case
Get the title of this case. The default title is the empty String.

Overrides:
getTitle in class Case

setTitle

public void setTitle(java.lang.String title)
Description copied from class: Case
Set the title of this case.

Overrides:
setTitle in class Case

setActive

public void setActive(Context context)
Description copied from class: Case
Make this case active for the given context.

Overrides:
setActive in class Case

setInactive

public void setInactive(Context context)
Description copied from class: Case
Make this case inactive for the given context.

Overrides:
setInactive in class Case

isActive

public boolean isActive(Context context)
Description copied from class: Case
Determine if this case is active for the given context.

Overrides:
isActive in class Case

getCaseSource

public CaseSource getCaseSource()
Description copied from class: Case
Get the source of this case.

Overrides:
getCaseSource in class Case

setCaseSource

public void setCaseSource(CaseSource source)
Description copied from class: Case
Set the source of this case.

Overrides:
setCaseSource in class Case

markCaseUsed

public void markCaseUsed()
Description copied from class: Case
For performance monitoring purposes, indicate that this case has been used - sent for adaptation, perhaps along with other cases.

Overrides:
markCaseUsed in class Case

markCaseUsedSuccessfully

public void markCaseUsedSuccessfully()
Description copied from class: Case
For performance monitoring purposes, indicate that this case has been used, and that use has lead to a "successful" solution.

Overrides:
markCaseUsedSuccessfully in class Case

getUseCount

public int getUseCount()
Description copied from class: Case
For performance monitoring purposes, get the number of times this case has been used.

Overrides:
getUseCount in class Case

getSuccessfulUseCount

public int getSuccessfulUseCount()
Description copied from class: Case
For performance monitoring purposes, get the number of times this case has been used successfully. That is, the number of times this case has contributed to a solution that has been deemed of high quality, by a domain-dependent SolutionQuality subclass.

Overrides:
getSuccessfulUseCount in class Case

getCaseAge

public double getCaseAge(PerformanceMonitor monitor)
Description copied from class: Case
Returns the number of problem-solving episodes, since this case was added, that have been seen by the system monitored by the given monitor. This could be considered the case's "age".

Overrides:
getCaseAge in class Case
Parameters:
monitor - The performance monitor for this CBR system.
Returns:
The case's age

resetCounts

public void resetCounts()
Description copied from class: Case
Reset the use, successful use, and problemCountAtAddition trackers for this case, to 0.

Overrides:
resetCounts in class Case

miscToSwing

public javax.swing.JComponent miscToSwing()
Overrides:
miscToSwing in class Case

toXML

public java.lang.String toXML(Domain domain)
Overrides:
toXML in class Case

fromXML

public void fromXML(java.lang.String XMLString)
Overrides:
fromXML in class Case

hasSolution

public boolean hasSolution()
Description copied from class: Case
Report if this case has a solution.

Overrides:
hasSolution in class Case
Returns:
true if a solution is available for this case. false if there is no solution (this is a new problem)

getProblem

public Problem getProblem()
Description copied from class: Case
Get the Problem object for this case.

Overrides:
getProblem in class Case

setProblem

public void setProblem(Problem newProblem)
Description copied from class: Case
Set the problem of this case.

Overrides:
setProblem in class Case

getSolution

public Solution getSolution()
Description copied from class: Case
Get the Solution object for this case.

Overrides:
getSolution in class Case

setSolution

public void setSolution(Solution newSolution)
Description copied from class: Case
Set the solution of this case.

Overrides:
setSolution in class Case

applyFeatureNoise

public void applyFeatureNoise(FeatureKey featureKey,
                              Distribution distribution)
Description copied from class: Case
Apply noise, according to the given distribution, to the given feature.

Overrides:
applyFeatureNoise in class Case

applySolutionNoise

public void applySolutionNoise(Distribution distribution)
Description copied from class: Case
Apply noise, according to the given distribution, to the solution of this case.

Overrides:
applySolutionNoise in class Case

equals

public boolean equals(java.lang.Object other)
Description copied from class: Case
Returns true if this case equals the given case; false otherwise.

Overrides:
equals in class Case

getProblemCountAtAddition

public double getProblemCountAtAddition()
Overrides:
getProblemCountAtAddition in class Case

getInactiveContexts

public java.util.HashSet getInactiveContexts()
Description copied from class: Case
Method getInactiveContexts

Overrides:
getInactiveContexts in class Case
Returns:
a HashSet

getCase

public Case getCase()
Specified by:
getCase in interface CaseDifferencePair

getDifference

public double getDifference()
Specified by:
getDifference in interface CaseDifferencePair

setDifference

public void setDifference(double diff)
Specified by:
setDifference in interface CaseDifferencePair

compareTo

public int compareTo(java.lang.Object p1)
Compare "this" with the parameter (a CaseDifferencePair). TreeSet.add will add elements in ascending order, according to this compareTo() implementation. If this.diff is greater than p1.diff, then 1 is returned. If this.diff is less than p1.diff, then -1 is returned. If this.diff is equal to p1.diff, then Case.compareTo() is called.

Specified by:
compareTo in interface CaseDifferencePair
Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class Case
Parameters:
p1 - The other Case object, to compare to this.
Returns:
An int having the standard compareTo() meaning. That is:

if this < otherCase, return value < 0
if this == otherCase, return value == 0
if this > otherCase, return value > 0

toString

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

Specified by:
toString in interface CaseDifferencePair
Overrides:
toString in class Case
Returns:
A String representing the problem and solution.

toString

public java.lang.String toString(Domain domain)
Specified by:
toString in interface CaseDifferencePair
Overrides:
toString in class Case

toSwing

public javax.swing.JComponent toSwing(int detailLevel)
Description copied from interface: SwingRepresentable
Detail level may be ignored by implementations. If used, the standard is for detailLevel 0 to be least detail, with higher values growing more detailed. 0 is least detail, higher numbers are more

Specified by:
toSwing in interface SwingRepresentable
Overrides:
toSwing in class Case

toSwing

public javax.swing.JComponent toSwing(Domain domain)
Specified by:
toSwing in interface SwingRepresentableWithDomain
Overrides:
toSwing in class Case

toSwing

protected javax.swing.JComponent toSwing(javax.swing.JComponent caseAsSwing)