jcreek.reasoning
Class RetrieveResult

java.lang.Object
  extended byjcreek.reasoning.CBRReasoningStep
      extended byjcreek.reasoning.RetrieveResult

public class RetrieveResult
extends CBRReasoningStep

Title: RetriveResult

Description: Runs the first step (activate) of the CBR Retrive process. When a new instance of this class is created, it creates an instance of CaseComparison between the input case (problem case) and the cases we want to compare this case to.

Version:
1.0
Author:
Frode Sørmo 2002, based on version by Martha Dørum Jæhre 2000.

Field Summary
protected  java.util.Vector caseComparisons
          Vector with a list of all the CaseComparisons.
protected  int caseComparisonSize
          The explain() and focus() steps operate on a subset of the caseComparisons vector.
static int DEFAULT_EXPLAIN_MAX_CASES
          DEFAULT_EXPLAIN_MAX_CASES - the default value of how many cases are explained.
static double DEFAULT_EXPLAIN_THRESHOLD
          DEFAULT_EXPLAIN_THRESHOLD - the default value of the activation strength threshold used by the explain() method to call the explain(int maxExplain, int explainThreshold) method, using this value as the value of explainThreshold.
static int DEFAULT_FOCUS_MAX_CASES
          DEFAULT_FOCUS_MAX_CASES - the default value for how many case-comparisons are kept after the focus() method is run.
static double DEFAULT_FOCUS_THRESHOLD
          DEFAULT_FOCUS_THRESHOLD - the default minimum strength a case-comparison must have in order to be kept when the focus() method is run.
protected  Entity[] findingList
           
protected  Case inputCase
          The input case (the problem case description).
protected  int lastExplainMax
           
protected  double lastExplainThreshold
           
protected  int lastFocusMax
           
protected  double lastFocusThreshold
           
static int RETRIEVE_STEP
          The ID for the Retrieve step.
 
Fields inherited from class jcreek.reasoning.CBRReasoningStep
ACTIVATED_STATE, counter, counterMax, EXPLAINED_STATE, FOCUSED_STATE, INITIAL_STATE, km, state, updateListeners
 
Constructor Summary
RetrieveResult(Case input)
          Creates a RetrieveResult comparing the input case to all the solved cases in the casebase, and automatically runs activate(), explain() and focus().
RetrieveResult(Case input, boolean auto)
          Creates a RetriveResult comparing the input case to all the solved cases in the casebase.
RetrieveResult(Case input, Case[] compares, boolean auto)
          Creates a new RetriveResult, comparing the input case to the set of cases given in the compares set.
 
Method Summary
 void activate()
          Runs the activate step of the Retrieve.
 void explain()
          Runs the explain step using default values for max cases and threshold.
 void explain(int maxExplain, double explainThreshold)
          Runs the activate step of the Retrieve.
 void focus()
          Shrinks the number of case-comparisons, using default values for the maximum number of cases to keep and for case-comparison threshold strength.
 void focus(int noCases, double threshold)
          Shrinks the number of case-comparisons.
 CaseComparison[] getAllComparisons()
          Gives all case-comparisons, including those comparisons which has not been through the explain and focus steps.
 Case getBestCase()
          Returns the case that is the best match for the input case.
 CaseComparison getBestComparison()
          Gives the CaseComparison object that represents the best match with a solved case.
 CaseComparison getComparison(int i)
          Gives the CaseComparison at the place specified.
 CaseComparison[] getComparisons()
          Gives the set of CaseComparisons for the current reasoning step.
 Case getInputCase()
          Returns the input case (problem case).
 int realsize()
          Returns the number of case-comparisons created originally - i.e. before the numbers are reduced by explain() and focus().
 void reset()
          Resets the state of this RetrieveResult to the initial state.
 int size()
          Returns the number of case-comparisons at this step in the Retrieve process.
protected  void sortComparisons()
          Sorts the caseComparisons vector.
 java.lang.String toString()
          Displays the RetrieveResult as a string.
 void update()
          Updates the CaseComparisons if any changes are done in the knowledgemodel.
 
Methods inherited from class jcreek.reasoning.CBRReasoningStep
abort, addReasoningUpdateListener, getIteration, getIterationMax, getKnowledgeModel, getState, isAborted, isActivated, isExplained, isFocused, removeReasoningUpdateListener, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inputCase

protected Case inputCase
The input case (the problem case description).


caseComparisons

protected java.util.Vector caseComparisons
Vector with a list of all the CaseComparisons.


caseComparisonSize

protected int caseComparisonSize
The explain() and focus() steps operate on a subset of the caseComparisons vector. This variable keeps track of the percieved size for these.


lastExplainMax

protected int lastExplainMax

lastExplainThreshold

protected double lastExplainThreshold

lastFocusMax

protected int lastFocusMax

lastFocusThreshold

protected double lastFocusThreshold

findingList

protected Entity[] findingList

RETRIEVE_STEP

public static final int RETRIEVE_STEP
The ID for the Retrieve step.

See Also:
Constant Field Values

DEFAULT_EXPLAIN_MAX_CASES

public static int DEFAULT_EXPLAIN_MAX_CASES
DEFAULT_EXPLAIN_MAX_CASES - the default value of how many cases are explained. This value is used by the explain() method to call the explain(int maxExplain, int explainThreshold) method as the value of maxExplain. This corresponds to the maximum number of case-comparisons the explain() step is executed on.


DEFAULT_EXPLAIN_THRESHOLD

public static double DEFAULT_EXPLAIN_THRESHOLD
DEFAULT_EXPLAIN_THRESHOLD - the default value of the activation strength threshold used by the explain() method to call the explain(int maxExplain, int explainThreshold) method, using this value as the value of explainThreshold. This corresponds to the minimum strength a case-comparison must have from the activate() step for the explain() step to be executed.


DEFAULT_FOCUS_MAX_CASES

public static int DEFAULT_FOCUS_MAX_CASES
DEFAULT_FOCUS_MAX_CASES - the default value for how many case-comparisons are kept after the focus() method is run.


DEFAULT_FOCUS_THRESHOLD

public static double DEFAULT_FOCUS_THRESHOLD
DEFAULT_FOCUS_THRESHOLD - the default minimum strength a case-comparison must have in order to be kept when the focus() method is run.

Constructor Detail

RetrieveResult

public RetrieveResult(Case input,
                      Case[] compares,
                      boolean auto)
Creates a new RetriveResult, comparing the input case to the set of cases given in the compares set.

Parameters:
input - The input case (the new problem case description).
compares - The set of cases to compare the input case to.
auto - If true, the activate(), explain() and focus() methods are automatically run with default values.

RetrieveResult

public RetrieveResult(Case input,
                      boolean auto)
Creates a RetriveResult comparing the input case to all the solved cases in the casebase.

Parameters:
input - The input case (the new problem case description).
auto - If true, the activate(), explain() and focus() methods are automatically run with default values.

RetrieveResult

public RetrieveResult(Case input)
Creates a RetrieveResult comparing the input case to all the solved cases in the casebase, and automatically runs activate(), explain() and focus().

Method Detail

reset

public void reset()
Resets the state of this RetrieveResult to the initial state.

Specified by:
reset in class CBRReasoningStep

update

public void update()
Updates the CaseComparisons if any changes are done in the knowledgemodel.

Overrides:
update in class CBRReasoningStep

sortComparisons

protected void sortComparisons()
Sorts the caseComparisons vector.


activate

public void activate()
Runs the activate step of the Retrieve. This runs a computationally inexpensive method to get a rough idea of what cases are more similar to the input case.

Specified by:
activate in class CBRReasoningStep

explain

public void explain(int maxExplain,
                    double explainThreshold)
Runs the activate step of the Retrieve. This runs a computationally inexpensive method to get a rough idea of what cases are more similar to the input case.

Parameters:
maxExplain - The maximum number of case-comparisons to run the explain step on. The case-comparisons with the highest strengths from the activate step is preferred.

explain

public void explain()
Runs the explain step using default values for max cases and threshold.

Specified by:
explain in class CBRReasoningStep

focus

public void focus(int noCases,
                  double threshold)
Shrinks the number of case-comparisons.

Parameters:
noCases - Max number of case-comparisons to keep.
threshold - All kept case-comparisons must have a strength of at least this value.

focus

public void focus()
Shrinks the number of case-comparisons, using default values for the maximum number of cases to keep and for case-comparison threshold strength.

Specified by:
focus in class CBRReasoningStep

getComparisons

public CaseComparison[] getComparisons()
Gives the set of CaseComparisons for the current reasoning step. After the explain and focus steps, this set may be smaller than the initial set.


getAllComparisons

public CaseComparison[] getAllComparisons()
Gives all case-comparisons, including those comparisons which has not been through the explain and focus steps.


getBestComparison

public CaseComparison getBestComparison()
Gives the CaseComparison object that represents the best match with a solved case.


getComparison

public CaseComparison getComparison(int i)
Gives the CaseComparison at the place specified.


getInputCase

public Case getInputCase()
Returns the input case (problem case).


getBestCase

public Case getBestCase()
Returns the case that is the best match for the input case.


size

public int size()
Returns the number of case-comparisons at this step in the Retrieve process.


realsize

public int realsize()
Returns the number of case-comparisons created originally - i.e. before the numbers are reduced by explain() and focus().


toString

public java.lang.String toString()
Displays the RetrieveResult as a string.



Created at IDI, NTNU by the Artificial Intelligence and Learning group