edu.indiana.iucbrf.casepackage
Class Case

java.lang.Object
  extended by edu.indiana.iucbrf.casepackage.Case
All Implemented Interfaces:
SwingRepresentableWithDomain, SwingRepresentable, java.io.Serializable, java.lang.Comparable
Direct Known Subclasses:
CaseDifferencePairImpl, KeyIndicesPair, Marker

public class Case
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable, SwingRepresentableWithDomain

A case consists of a problem description and a solution. Consequently, the Case component package is simply a wrapper for a Problem object and a Solution object. Essentially all functionality is deferred to these objects. This base component class is not abstract and should fit the needs of many CBR systems without modification.
Note: Any extension must implement Serializable, if case base file save and load functionality is desired.

See Also:
Serialized Form

Field Summary
static long CASE_KEY_NOT_SET
           
protected  long caseKey
           
protected  java.util.HashSet inactiveContexts
          The set of contexts in which this case is inactive, and should not be retrieved.
protected  Problem p
          The object representing the problem that this case solves.
protected  double problemCountAtAddition
          The number of problems the system had seen when this case was added.
protected  Solution s
          The object representing the solution that this case solves.
protected  CaseSource source
          The source of this case.
protected  int successfulUseCount
          number of times this case has been used, and that use has lead to a "successful" solution
protected  int useCount
          number of times this case has been used (sent for adaptation, perhaps along with other cases)
 
Fields inherited from interface edu.indiana.util.swing.SwingRepresentable
TITLE_FONT
 
Constructor Summary
protected Case()
           
  Case(Problem p, Solution s)
          Creates new Case This constructor can be used to create a new case when the problem and solution are already known.
  Case(Problem p, Solution s, CaseSource source, int useCount, int successfulUseCount, double problemCountAtAddition, java.util.HashSet inactiveContexts)
           
  Case(Problem p, Solution s, double problemCount)
          Creates new Case This constructor can be used to create a new case when the problem and solution are already known.
  Case(Problem p, Solution s, double problemCount, CaseSource source)
          Creates new Case This constructor can be used to create a new case when the problem and solution are already known.
 
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 otherCase)
          Compare two cases, by comparing the problem.
 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)
           
 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.
 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 setInactive(Context context)
          Make this case inactive for the given context.
 void setInactiveContexts(java.util.HashSet inactiveContexts)
           
 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()
          Convert this case to a string representation.
 java.lang.String toString(Domain domain)
           
protected  java.lang.String toString(java.lang.String title, java.lang.String source, java.lang.String problem, java.lang.String solution)
           
 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 problemAsSwing, javax.swing.JComponent solutionAsSwing)
           
 java.lang.String toXML(Domain domain)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CASE_KEY_NOT_SET

public static final long CASE_KEY_NOT_SET
See Also:
Constant Field Values

p

protected Problem p
The object representing the problem that this case solves.


s

protected Solution s
The object representing the solution that this case solves.


inactiveContexts

protected java.util.HashSet inactiveContexts
The set of contexts in which this case is inactive, and should not be retrieved.


useCount

protected int useCount
number of times this case has been used (sent for adaptation, perhaps along with other cases)


successfulUseCount

protected int successfulUseCount
number of times this case has been used, and that use has lead to a "successful" solution


problemCountAtAddition

protected double problemCountAtAddition
The number of problems the system had seen when this case was added. (Used to count how many problems the system has seen since this case was added.)


source

protected CaseSource source
The source of this case.


caseKey

protected long caseKey
Constructor Detail

Case

protected Case()

Case

public Case(Problem p,
            Solution s)
Creates new Case This constructor can be used to create a new case when the problem and solution are already known. This is useful when adding new cases to a case base.

Parameters:
p - The Problem for this case.
s - The Solution to the problem.

Case

public Case(Problem p,
            Solution s,
            double problemCount)
Creates new Case This constructor can be used to create a new case when the problem and solution are already known. This is useful when adding new cases to a case base.

Parameters:
p - The Problem for this case.
s - The Solution to the problem.
problemCount - The number of problems the system had seen when this case was added.

Case

public Case(Problem p,
            Solution s,
            double problemCount,
            CaseSource source)
Creates new Case This constructor can be used to create a new case when the problem and solution are already known. This is useful when adding new cases to a case base.

Parameters:
p - The Problem for this case.
s - The Solution to the problem.

Case

public Case(Problem p,
            Solution s,
            CaseSource source,
            int useCount,
            int successfulUseCount,
            double problemCountAtAddition,
            java.util.HashSet inactiveContexts)
Method Detail

setCaseKey

public void setCaseKey(long caseKey)

getCaseKey

public long getCaseKey()

hasCaseKey

public boolean hasCaseKey()

constructIndices

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


getTitle

public java.lang.String getTitle()
Get the title of this case. The default title is the empty String.


setTitle

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


setActive

public void setActive(Context context)
Make this case active for the given context.


setInactive

public void setInactive(Context context)
Make this case inactive for the given context.


isActive

public boolean isActive(Context context)
Determine if this case is active for the given context.


getCaseSource

public CaseSource getCaseSource()
Get the source of this case.


setCaseSource

public void setCaseSource(CaseSource source)
Set the source of this case.


markCaseUsed

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


markCaseUsedSuccessfully

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


getUseCount

public int getUseCount()
For performance monitoring purposes, get the number of times this case has been used.


getSuccessfulUseCount

public int getSuccessfulUseCount()
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.


getCaseAge

public 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. This could be considered the case's "age".

Parameters:
monitor - The performance monitor for this CBR system.
Returns:
The case's age

resetCounts

public void resetCounts()
Reset the use, successful use, and problemCountAtAddition trackers for this case, to 0.


toString

public java.lang.String toString()
Convert this case to a string representation.

Overrides:
toString in class java.lang.Object
Returns:
A String representing the problem and solution.

toString

public java.lang.String toString(Domain domain)

toString

protected java.lang.String toString(java.lang.String title,
                                    java.lang.String source,
                                    java.lang.String problem,
                                    java.lang.String solution)

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

toSwing

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

toSwing

protected javax.swing.JComponent toSwing(javax.swing.JComponent problemAsSwing,
                                         javax.swing.JComponent solutionAsSwing)

miscToSwing

public javax.swing.JComponent miscToSwing()

toXML

public java.lang.String toXML(Domain domain)

fromXML

public void fromXML(java.lang.String XMLString)

hasSolution

public boolean hasSolution()
Report if this case has a solution.

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()
Get the Problem object for this case.


setProblem

public void setProblem(Problem newProblem)
Set the problem of this case.


getSolution

public Solution getSolution()
Get the Solution object for this case.


setSolution

public void setSolution(Solution newSolution)
Set the solution of this case.


compareTo

public int compareTo(java.lang.Object otherCase)
Compare two cases, by comparing the problem. If the problems are equal, return the comparison of the solution.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
otherCase - 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

equals

public boolean equals(java.lang.Object other)
Returns true if this case equals the given case; false otherwise.

Overrides:
equals in class java.lang.Object

applyFeatureNoise

public void applyFeatureNoise(FeatureKey featureKey,
                              Distribution distribution)
Apply noise, according to the given distribution, to the given feature.


applySolutionNoise

public void applySolutionNoise(Distribution distribution)
Apply noise, according to the given distribution, to the solution of this case.


getProblemCountAtAddition

public double getProblemCountAtAddition()

getInactiveContexts

public java.util.HashSet getInactiveContexts()
Method getInactiveContexts

Returns:
a HashSet

setInactiveContexts

public void setInactiveContexts(java.util.HashSet inactiveContexts)