net.sourceforge.cilib.problem.dataset
Class AssociatedPairDataSetBuilder

java.lang.Object
  extended by net.sourceforge.cilib.problem.dataset.DataSetBuilder
      extended by net.sourceforge.cilib.problem.dataset.AssociatedPairDataSetBuilder
All Implemented Interfaces:
Serializable, Iterable<DataSet>, ClusterableDataSet, Cloneable

public class AssociatedPairDataSetBuilder
extends DataSetBuilder
implements ClusterableDataSet

This class "collects" and holds all the patterns of the DataSets specified through the addDataSet(DataSet) method. The name is no longer relevant, because this class no longer keeps track of cluster assignments. That is now the job of the ClusteringUtils class. Therefore, this class' name will probably change to something like ClusterableDataSetBuilder.

Author:
Gary Pampara, Theuns Cloete
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sourceforge.cilib.problem.dataset.ClusterableDataSet
ClusterableDataSet.Pattern
 
Field Summary
protected  ArrayList<ClusterableDataSet.Pattern> patterns
           
 
Fields inherited from class net.sourceforge.cilib.problem.dataset.DataSetBuilder
dataSets
 
Constructor Summary
AssociatedPairDataSetBuilder()
          Initialise the patterns data structure and set the identifier to be blank.
AssociatedPairDataSetBuilder(AssociatedPairDataSetBuilder rhs)
           
 
Method Summary
 void addDataSet(DataSet ds)
          This method overrides DataSetBuilder.addDataSet(DataSet) because it works completely different than a normal DataSetBuilder.
 double getCachedDistance(int x, int y)
          Retrieve the cached distance between the given patterns.
 AssociatedPairDataSetBuilder getClone()
          Create a cloned copy of the current object and return it.
 String getIdentifier()
          Get the identifier that uniquely identifies this constructed/combined/built dataset.
 Vector getMean()
          Get the cached mean Vector.
 int getNumberOfPatterns()
          Determine how many patterns are in this constructed/combined/built dataset.
 ClusterableDataSet.Pattern getPattern(int i)
          Get the pattern that is represented by the given index.
 ArrayList<ClusterableDataSet.Pattern> getPatterns()
          Get all the patterns in this constructed/combined/built dataset.
 double getVariance()
          Get the cached variance (scalar).
 void initialise()
          By now, all the needed DataSets should have been parsed and added to patterns.
 
Methods inherited from class net.sourceforge.cilib.problem.dataset.DataSetBuilder
getDataSet, iterator, uninitialise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

patterns

protected ArrayList<ClusterableDataSet.Pattern> patterns
Constructor Detail

AssociatedPairDataSetBuilder

public AssociatedPairDataSetBuilder()
Initialise the patterns data structure and set the identifier to be blank.


AssociatedPairDataSetBuilder

public AssociatedPairDataSetBuilder(AssociatedPairDataSetBuilder rhs)
Method Detail

getClone

public AssociatedPairDataSetBuilder getClone()
Description copied from interface: Cloneable
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Cloneable
Specified by:
getClone in class DataSetBuilder
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

addDataSet

public void addDataSet(DataSet ds)
This method overrides DataSetBuilder.addDataSet(DataSet) because it works completely different than a normal DataSetBuilder. It takes the fact that datasets may already have been parsed by other simulations, problems or threads into account. It relies on the DataSetManager singleton to parse and/or retrieve the patterns of the given DataSet. Then it adds these retrieved patterns to the current patterns list. This method also builds up the identifier that uniquely identifies this dataset builder. This identifier is used by the DataSetManager to keep track of this built-up dataset, because it might be used by other Simulations, Problems or Threads as well.

Overrides:
addDataSet in class DataSetBuilder
Parameters:
ds - the DataSet that represents a dataset that should be used when building up the list of patterns that should be clustered
Throws:
IllegalArgumentException - when the given DataSet is not a LocalDataSet. This is only temporary, because I didn't want to change the more generic DataSet too much.
IllegalArgumentException - when the patterns that are currently being added have different dimensions than the patterns that have already been collected/built (those in patterns).

initialise

public void initialise()
By now, all the needed DataSets should have been parsed and added to patterns. All that needs to be done is to cache the mean, the variance and the distances between all patterns of this constructed/combined/built dataset.

Specified by:
initialise in interface ClusterableDataSet
Specified by:
initialise in class DataSetBuilder

getMean

public Vector getMean()
Get the cached mean Vector.

Specified by:
getMean in interface ClusterableDataSet
Returns:
the cachedMean

getVariance

public double getVariance()
Get the cached variance (scalar).

Specified by:
getVariance in interface ClusterableDataSet
Returns:
the cachedVariance

getCachedDistance

public double getCachedDistance(int x,
                                int y)
Retrieve the cached distance between the given patterns.

Specified by:
getCachedDistance in interface ClusterableDataSet
Parameters:
x - index of the one pattern
y - index of the other pattern
Returns:
the cached distance between the two given patterns
Throws:
IllegalArgumentException - when either x or y is negative.

getPatterns

public ArrayList<ClusterableDataSet.Pattern> getPatterns()
Get all the patterns in this constructed/combined/built dataset.

Specified by:
getPatterns in interface ClusterableDataSet
Returns:
the patterns list

getPattern

public ClusterableDataSet.Pattern getPattern(int i)
Get the pattern that is represented by the given index.

Specified by:
getPattern in interface ClusterableDataSet
Parameters:
i - the index representing a pattern in the patterns
Returns:
pattern i of patterns

getNumberOfPatterns

public int getNumberOfPatterns()
Determine how many patterns are in this constructed/combined/built dataset.

Specified by:
getNumberOfPatterns in interface ClusterableDataSet
Returns:
the number of patterns/elements in patterns

getIdentifier

public String getIdentifier()
Get the identifier that uniquely identifies this constructed/combined/built dataset.

Returns:
the identifier


Copyright © 2009 CIRG. All Rights Reserved.