edu.indiana.iucbrf.retrieval
Class kNN

java.lang.Object
  extended by edu.indiana.iucbrf.retrieval.AbstractRetrieval
      extended by edu.indiana.iucbrf.retrieval.kNN
All Implemented Interfaces:
Retrieval, java.io.Serializable

public class kNN
extends AbstractRetrieval

kNN implements k-Nearest Neighbor. According to a domain-specific similarity criteria, the k nearest cases are returned, in order. These can subsequently be sent to an adaptation technique.

See Also:
Serialized Form

Field Summary
protected  int k
          k is the number of cases that are retrieved.
 
Fields inherited from class edu.indiana.iucbrf.retrieval.AbstractRetrieval
conditionsChecker, debugMode, problemDifferentiator
 
Constructor Summary
protected kNN()
           
  kNN(Domain domain, int k)
          Creates new kNN.
  kNN(ProblemDifferentiator problemDifferentiator, int k)
          Creates new kNN.
 
Method Summary
 int getK()
          Get the value of k.
 RetrievalResults getNearest(java.util.Iterator caseIter, Problem p, Context currentContext, java.util.Collection specialIndices)
          Get the k cases in the case base nearest to a problem.
 void setParams(java.lang.Object[] params)
           
 
Methods inherited from class edu.indiana.iucbrf.retrieval.AbstractRetrieval
getConditionsChecker, getDebugMode, getNearest, getNearest, getNearest, getProblemDifferentiator, handleDebugMode, setConditionsChecker, setDebugMode, setProblemDifferentiator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

k

protected int k
k is the number of cases that are retrieved.

Constructor Detail

kNN

protected kNN()

kNN

public kNN(Domain domain,
           int k)
Creates new kNN.

Parameters:
k - The number of cases to retrieve.

kNN

public kNN(ProblemDifferentiator problemDifferentiator,
           int k)
Creates new kNN.

Parameters:
k - The number of cases to retrieve.
Method Detail

setParams

public void setParams(java.lang.Object[] params)

getK

public int getK()
Get the value of k. k is the number of cases that are retrieved.


getNearest

public RetrievalResults getNearest(java.util.Iterator caseIter,
                                   Problem p,
                                   Context currentContext,
                                   java.util.Collection specialIndices)
Get the k cases in the case base nearest to a problem. If a case is inactive in the current context, it is not considered for retrieval.

Specified by:
getNearest in interface Retrieval
Overrides:
getNearest in class AbstractRetrieval
Parameters:
caseIter - An iterator on the case base (or set of cases to be considered).
p - The current problem
Returns:
A sorted ArrayList of the k closest cases, with the closest first.