edu.indiana.iucbrf.casebase
Class PartitionedCaseBase

java.lang.Object
  extended by edu.indiana.iucbrf.casebase.AbstractCaseBase
      extended by edu.indiana.iucbrf.casebase.PartitionedCaseBase
All Implemented Interfaces:
CaseBase, SwingRepresentableWithDomain, SwingRepresentable, java.io.Serializable

public class PartitionedCaseBase
extends AbstractCaseBase

A partitioned case base is one in which the cases are partitioned into equivalence classes, for example as a result of k-medoid clustering.

See Also:
Serialized Form

Nested Class Summary
protected  class PartitionedCaseBase.CBArrayIterator
           
 
Field Summary
protected  CaseBase[] caseBases
           
protected  ProblemDifferentiator differentiator
           
protected  Case[] prototypes
           
 
Fields inherited from class edu.indiana.iucbrf.casebase.AbstractCaseBase
caseClass, debugMode, DEFAULT_INITIAL_CAPACITY, domain, listeners, prototype
 
Fields inherited from interface edu.indiana.util.swing.SwingRepresentable
TITLE_FONT
 
Constructor Summary
PartitionedCaseBase(CaseBase allCaseCB, int k, ProblemDifferentiator differentiator)
           
PartitionedCaseBase(CaseBase allCaseCB, java.lang.String baseFilename, int numEqClasses, ProblemDifferentiator differentiator)
           
PartitionedCaseBase(Partition partition)
          Creates a new instance of PartitionedCaseBase
 
Method Summary
protected  long addCaseImpl(Case caseToAdd)
          Implement this method to add a case to the case base, assuming that class and event issues are already handled by addCase().
protected  double calcAvgDist(int classID, Problem p)
          Finds nearest eq class, not by simply comparing to prototypes, but by a Bayesian process.
protected  int calcNumConsistentInClass(int classID, Problem p, ProblemDifferentiator pd)
           
protected  void customReadPartitionFromFile(CaseBase allCaseCB, java.lang.String baseFilename, int cbIndex)
           
 void customWriteToFile(java.lang.String baseFilename)
          The first entry in each file is the prototype
 void ensureCapacity(int minimumCapacity)
          Prepare the case base to be able to hold at least minCapacity cases.
 int findBayesianNearestCaseEqClass(Case c, ProblemDifferentiator pd)
          Finds nearest eq class, not by simply comparing to prototypes, but by a Bayesian process.
 int findBayesianNearestCaseEqClass(Problem p, ProblemDifferentiator pd)
          Finds nearest eq class, not by simply comparing to prototypes, but by a Bayesian process.
 int findNearestCaseEqClass(Case c)
           
 int findNearestCaseEqClass(Problem p)
           
 int getCaseCount()
          Gets the number of cases in this list
 CaseBase getCB(int classID)
           
 ProblemDifferentiator getDifferentiator()
           
 int getEqClassCount()
           
protected  void initializeCB(int initialCapacity)
           
 boolean isEmpty()
          Returns true if this case base is empty, false otherwise.
 java.util.Iterator iterator()
          Create an iterator on the case base.
protected  boolean removeCaseImpl(Case c)
           
 java.lang.String toString()
          Convert this case base to a string representation.
 
Methods inherited from class edu.indiana.iucbrf.casebase.AbstractCaseBase
addCase, addCaseBaseListener, addCases, addCases, addCases, buildCaseJList, checkCaseType, classMemberIterator, clearAllEstimates, close, fireCaseAdded, fireCaseClassChanged, fireCaseRemoved, fireCaseReplaced, fireCasesCleared, getCaseClass, getCasesMatching, getDomain, getPrototype, removeCase, removeCaseBaseListener, setBaseFileName, setCaseClass, setDebugMode, setDomain, toSwing, toSwing, toVerboseString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

differentiator

protected ProblemDifferentiator differentiator

prototypes

protected Case[] prototypes

caseBases

protected CaseBase[] caseBases
Constructor Detail

PartitionedCaseBase

public PartitionedCaseBase(CaseBase allCaseCB,
                           java.lang.String baseFilename,
                           int numEqClasses,
                           ProblemDifferentiator differentiator)

PartitionedCaseBase

public PartitionedCaseBase(CaseBase allCaseCB,
                           int k,
                           ProblemDifferentiator differentiator)

PartitionedCaseBase

public PartitionedCaseBase(Partition partition)
Creates a new instance of PartitionedCaseBase

Method Detail

getDifferentiator

public ProblemDifferentiator getDifferentiator()

getCB

public CaseBase getCB(int classID)

getEqClassCount

public int getEqClassCount()

addCaseImpl

protected long addCaseImpl(Case caseToAdd)
Description copied from class: AbstractCaseBase
Implement this method to add a case to the case base, assuming that class and event issues are already handled by addCase().

Specified by:
addCaseImpl in class AbstractCaseBase
Returns:
-1 (a meaningless value)

ensureCapacity

public void ensureCapacity(int minimumCapacity)
Description copied from class: AbstractCaseBase
Prepare the case base to be able to hold at least minCapacity cases. Some CaseBase subclasses may not need to do anything in their implementations of this method. Used for efficiency reasons, analogous to java.util.ArrayList.ensureCapacity().

Specified by:
ensureCapacity in interface CaseBase
Specified by:
ensureCapacity in class AbstractCaseBase

getCaseCount

public int getCaseCount()
Gets the number of cases in this list


initializeCB

protected void initializeCB(int initialCapacity)
Specified by:
initializeCB in class AbstractCaseBase

isEmpty

public boolean isEmpty()
Returns true if this case base is empty, false otherwise.

Specified by:
isEmpty in interface CaseBase
Overrides:
isEmpty in class AbstractCaseBase

removeCaseImpl

protected boolean removeCaseImpl(Case c)
Specified by:
removeCaseImpl in class AbstractCaseBase

findNearestCaseEqClass

public int findNearestCaseEqClass(Case c)

findNearestCaseEqClass

public int findNearestCaseEqClass(Problem p)

findBayesianNearestCaseEqClass

public int findBayesianNearestCaseEqClass(Case c,
                                          ProblemDifferentiator pd)
Finds nearest eq class, not by simply comparing to prototypes, but by a Bayesian process.

Parameters:
c - Case
pd - ProblemDifferentiator The special pd to use for Bayesian calculations. Not forced to be same as this.differentiator.
Returns:
int

findBayesianNearestCaseEqClass

public int findBayesianNearestCaseEqClass(Problem p,
                                          ProblemDifferentiator pd)
Finds nearest eq class, not by simply comparing to prototypes, but by a Bayesian process.

Parameters:
p - Problem
pd - ProblemDifferentiator The special pd to use for Bayesian calculations. Not forced to be same as this.differentiator.
Returns:
int

calcAvgDist

protected double calcAvgDist(int classID,
                             Problem p)
Finds nearest eq class, not by simply comparing to prototypes, but by a Bayesian process.

Parameters:
p - Problem
pd - ProblemDifferentiator The special pd to use for Bayesian calculations. Not forced to be same as this.differentiator.
Returns:
int

calcNumConsistentInClass

protected int calcNumConsistentInClass(int classID,
                                       Problem p,
                                       ProblemDifferentiator pd)

iterator

public java.util.Iterator iterator()
                            throws java.lang.UnsupportedOperationException
Create an iterator on the case base.

Specified by:
iterator in interface CaseBase
Specified by:
iterator in class AbstractCaseBase
Throws:
java.lang.UnsupportedOperationException

toString

public java.lang.String toString()
Convert this case base to a string representation. Warning: naturally, the String representation will be quite large if there are many cases and/or the cases themselves have a large String representation.

Specified by:
toString in interface CaseBase
Overrides:
toString in class AbstractCaseBase

customWriteToFile

public void customWriteToFile(java.lang.String baseFilename)
The first entry in each file is the prototype


customReadPartitionFromFile

protected void customReadPartitionFromFile(CaseBase allCaseCB,
                                           java.lang.String baseFilename,
                                           int cbIndex)