edu.indiana.iucbrf.retrieval
Class RetrievalResults

java.lang.Object
  extended by edu.indiana.iucbrf.retrieval.RetrievalResults
All Implemented Interfaces:
java.lang.Cloneable

public class RetrievalResults
extends java.lang.Object
implements java.lang.Cloneable

A container for an ArrayList of retrieved cases, and difference and rank information. (Note that this class replaces most older functionality related to CaseDifferencePair objects.)


Field Summary
protected  java.util.ArrayList caseList
          The list of retrieved Case objects.
protected  double[] differences
          differences[i] is the calculated difference between this.get(i) and the target problem.
static int FULL_DETAIL
           
static int HALF_DETAIL
           
protected  int indexOfEndOfBestTie
          The index marking the end of the tie of the best cases.
protected  int numDistinctDifferences
          A count of the number of differences in these retrieval results that are distinct.
protected  int[] ranks
          ranks[i] is the rank of the case at this.get(i).
 
Constructor Summary
RetrievalResults()
          Construct an empty list of retrieval results.
RetrievalResults(java.util.ArrayList CDPs)
          Behaves like the other constructors, but must break down the CaseDifferencePair objects first.
RetrievalResults(java.util.ArrayList cases, java.util.ArrayList differences)
           
RetrievalResults(java.util.ArrayList cases, double[] differences)
           
 
Method Summary
 boolean areTied(int index1, int index2)
           
protected  void calcRanks()
           
 java.lang.Object clone()
           
 Case getCase(int index)
           
 int getCaseCount()
           
 java.util.ArrayList getCaseList()
           
 double getDifference(int index)
           
 double[] getDifferences()
           
 int getIndexOfEndOfBestTie()
           
 int getNumCasesInThreshold(double threshold)
           
protected  int getNumCasesInThresholdBinarySearch(double threshold, int minID, int maxID)
           
 int getNumDistinctDifferences()
           
 int getRank(int index)
           
 int[] getRanks()
           
 java.util.Iterator iterator()
           
static void main(java.lang.String[] args)
           
 RetrievalResults makeSubResults(int fromIndex, int toIndex)
           
 void setDifference(int index, double value)
           
 java.lang.String toString()
           
 java.lang.String toString(int detailLevel)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FULL_DETAIL

public static final int FULL_DETAIL
See Also:
Constant Field Values

HALF_DETAIL

public static final int HALF_DETAIL
See Also:
Constant Field Values

caseList

protected java.util.ArrayList caseList
The list of retrieved Case objects.


differences

protected double[] differences
differences[i] is the calculated difference between this.get(i) and the target problem.


numDistinctDifferences

protected int numDistinctDifferences
A count of the number of differences in these retrieval results that are distinct. For example, distances [0.5, 0.6, 0.6, 0.7] would give 3 distinct differences.


ranks

protected int[] ranks
ranks[i] is the rank of the case at this.get(i). Rankings are 0-based (that is, 0 is the best rank, then 1, then 2, etc). Note that ranks[i] does not necessarily equal i. If two cases have the same difference from a target, they are given the same rank, and subsequent cases are ranked from that number, with a rank skipped in the event of a tie at the better rank. For example, if the ArrayList contains [c1, c2, c3, c4], with differences [0.5, 0.6, 0.6, 0.8], then ranks is [0, 1, 1, 3].


indexOfEndOfBestTie

protected int indexOfEndOfBestTie
The index marking the end of the tie of the best cases. For example, for ranks [0, 0, 0, 3, 3, 3, 3], indexOfEndOfBestTie = 2. For ranks [0, 1, 1, 1, 1], indexOfEndOfBestTie = 0.

Constructor Detail

RetrievalResults

public RetrievalResults()
Construct an empty list of retrieval results.


RetrievalResults

public RetrievalResults(java.util.ArrayList CDPs)
Behaves like the other constructors, but must break down the CaseDifferencePair objects first.

Parameters:
CDPs - An ArrayList of CaseDifferencePair objects.

RetrievalResults

public RetrievalResults(java.util.ArrayList cases,
                        java.util.ArrayList differences)

RetrievalResults

public RetrievalResults(java.util.ArrayList cases,
                        double[] differences)
Method Detail

calcRanks

protected void calcRanks()

areTied

public boolean areTied(int index1,
                       int index2)

getCaseCount

public int getCaseCount()

getCaseList

public java.util.ArrayList getCaseList()

iterator

public java.util.Iterator iterator()

makeSubResults

public RetrievalResults makeSubResults(int fromIndex,
                                       int toIndex)
Parameters:
fromIndex - int The starting index, inclusive
toIndex - int The ending index, exclusive
Returns:
RetrievalResults

getNumCasesInThreshold

public int getNumCasesInThreshold(double threshold)

getNumCasesInThresholdBinarySearch

protected int getNumCasesInThresholdBinarySearch(double threshold,
                                                 int minID,
                                                 int maxID)

getCase

public Case getCase(int index)

getDifferences

public double[] getDifferences()

getDifference

public double getDifference(int index)
Parameters:
index - The index of the case of interest
Returns:
The difference of the case at the given index from the target problem.

setDifference

public void setDifference(int index,
                          double value)

getRanks

public int[] getRanks()

getNumDistinctDifferences

public int getNumDistinctDifferences()

getIndexOfEndOfBestTie

public int getIndexOfEndOfBestTie()

getRank

public int getRank(int index)
Parameters:
index - The index of the case of interest
Returns:
The rank of the case at the given index.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(int detailLevel)

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

main

public static void main(java.lang.String[] args)