jcreek.reasoning
Class ReuseResult

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

public class ReuseResult
extends CBRReasoningStep

Title: ReuseResult

Description: Uses the cases retrieved by a RetrieveResult object to select a solultion. This class uses the kNN algorithm, using the distance as votes for k nearest neighbours.

Version:
1.0
Author:
Frode Sørmo

Field Summary
protected  boolean defaultK
           
protected  int k
           
protected  RetrieveResult retrieve
           
static int REUSE_STEP
          The ID for the Reuse step.
protected  Entity[] solutions
           
protected  java.util.Hashtable solutionStrength
           
 
Fields inherited from class jcreek.reasoning.CBRReasoningStep
ACTIVATED_STATE, counter, counterMax, EXPLAINED_STATE, FOCUSED_STATE, INITIAL_STATE, km, state, updateListeners
 
Constructor Summary
ReuseResult(RetrieveResult retrieve)
          Creates a new ReuseResult object, using the the focused cases of the RetrieveResult to vote on a solution.
ReuseResult(RetrieveResult retrieve, int k)
          Creates a new ReuseResult object, using k first cases of the RetrieveResult to vote on a solution.
ReuseResult(RetrieveResult retrieve, int k, boolean automatic)
          Creates a new ReuseResult object, using k first cases of the RetrieveResult to vote on a solution.
 
Method Summary
 void activate()
          Activate: Retrieves the solution of the k best cases and vote
 void explain()
          Explain step: Currently does nothing.
 void focus()
          Focus step: Currently does nothing.
 Case getCase(int i)
          Returns the matched cases used to vote on the solution.
 Case[] getCasesForSolution(int solutionNumber)
          Returns the cases supporting the given solution.
 double getCaseStrength(int i)
           
 SubModel getCausalModel(int solutionNumber)
          Returns a SubModel that contains all findings of the input case and all relations that is included in an explanation path for any inherited causal relation to the solution, as well as the solution itself.
 Case getInputCase()
          Returns the input case (problem description).
 int getK()
          Returns how many of the cases are used to vote on the solution.
 RetrieveResult getRetrieveResult()
          Returns the RetrieveResult object used as a prerequisite for this ReuseResult object.
 Entity getSolution()
          Returns the solution selected.
 Entity getSolution(int i)
          Returns the i best solution found.
 double getSolutionStrength(Entity ent)
          Returns the (non-normalized) strength of the votes solution ent have recieved.
 double getSolutionStrength(int i)
          Returns the (non-normalized) strength of the votes solution no i have recieved.
 void reset()
          Resets to the initial state.
 int size()
           
 java.lang.String toString()
          Returns a string saying what solution is chosen.
 void update()
          Updates the solutions (e.g. 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

retrieve

protected RetrieveResult retrieve

k

protected int k

defaultK

protected boolean defaultK

solutionStrength

protected java.util.Hashtable solutionStrength

solutions

protected Entity[] solutions

REUSE_STEP

public static final int REUSE_STEP
The ID for the Reuse step.

See Also:
Constant Field Values
Constructor Detail

ReuseResult

public ReuseResult(RetrieveResult retrieve,
                   int k,
                   boolean automatic)
Creates a new ReuseResult object, using k first cases of the RetrieveResult to vote on a solution.

Parameters:
retrieve - The retrieved set of cases to reuse.
k - How many of the best retrieved cases to use when selecting a solution.
automatic - If true, activate, explain and focus is automatically run when constructed.

ReuseResult

public ReuseResult(RetrieveResult retrieve,
                   int k)
Creates a new ReuseResult object, using k first cases of the RetrieveResult to vote on a solution. This constructor automatically calls activate, explain and focus.

Parameters:
retrieve - The retrieved set of cases to reuse.
k - How many of the best retrieved cases to use when selecting a solution.

ReuseResult

public ReuseResult(RetrieveResult retrieve)
Creates a new ReuseResult object, using the the focused cases of the RetrieveResult to vote on a solution. This constructor automatically calls activate, explain and focus.

Method Detail

getRetrieveResult

public RetrieveResult getRetrieveResult()
Returns the RetrieveResult object used as a prerequisite for this ReuseResult object.


getK

public int getK()
Returns how many of the cases are used to vote on the solution.


getInputCase

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


getCase

public Case getCase(int i)
Returns the matched cases used to vote on the solution.


getCaseStrength

public double getCaseStrength(int i)

reset

public void reset()
Resets to the initial state.

Specified by:
reset in class CBRReasoningStep

activate

public void activate()
Activate: Retrieves the solution of the k best cases and vote

Specified by:
activate in class CBRReasoningStep

explain

public void explain()
Explain step: Currently does nothing.

Specified by:
explain in class CBRReasoningStep

focus

public void focus()
Focus step: Currently does nothing.

Specified by:
focus in class CBRReasoningStep

update

public void update()
Updates the solutions (e.g. if any changes are done in the knowledgemodel).

Overrides:
update in class CBRReasoningStep

getCasesForSolution

public Case[] getCasesForSolution(int solutionNumber)
Returns the cases supporting the given solution.

Parameters:
solutionNumber - The solution number
Returns:
Case[]

getSolution

public Entity getSolution()
Returns the solution selected.

Returns:
An entity representing the solution.

getSolution

public Entity getSolution(int i)
Returns the i best solution found.

Parameters:
i - The number solution (i.e. no 1 is the best, 2 is second best etc.)
Returns:
The entity representing the solution.

getSolutionStrength

public double getSolutionStrength(int i)
Returns the (non-normalized) strength of the votes solution no i have recieved.

Parameters:
i - The ith solution (from the best to the worst).
Returns:
The non-normalized votes recieved by this solution.

getSolutionStrength

public double getSolutionStrength(Entity ent)
Returns the (non-normalized) strength of the votes solution ent have recieved.

Parameters:
ent - The Entity representing the solution.
Returns:
The non-normalized votes recieved by this solution.

size

public int size()

getCausalModel

public SubModel getCausalModel(int solutionNumber)
Returns a SubModel that contains all findings of the input case and all relations that is included in an explanation path for any inherited causal relation to the solution, as well as the solution itself.

Parameters:
solutionNumber - The solution number to provide a causal model for
Returns:
SubModel

toString

public java.lang.String toString()
Returns a string saying what solution is chosen.



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