fsmvis.engine
Class InterpolateSampleModel

java.lang.Object
  |
  +--fsmvis.engine.SpringModel
        |
        +--fsmvis.engine.NeighbourAndSampleModel
              |
              +--fsmvis.engine.SubsetNeighbourAndSampleModel
                    |
                    +--fsmvis.engine.InterpolateSampleModel

public class InterpolateSampleModel
extends SubsetNeighbourAndSampleModel

See Also:
Serialized Form

Field Summary
protected  boolean bKmeans
           
protected  boolean bKMeansInterpFinished
           
protected  boolean bStable
           
protected static java.lang.String CIRCUMF_SAMPLES
           
protected  int circumfSamples
           
protected  int currentInterp
           
protected static java.lang.String DATA_SAMPLE_SIZE
           
protected  int dataSampleSize
           
protected  EndCriteria endC
           
protected  int increaseInSize
           
protected  int interpCount
           
protected  java.util.ArrayList interpSubset
           
protected  java.util.HashSet interpSubsetContents
           
protected  java.util.ArrayList interpSubsetNums
           
protected  int interpSubsetSize
           
protected  boolean isInterpolating
           
protected  int iterationsSubTotal
           
protected static java.lang.String LOW_ERROR
           
protected static java.lang.String LOW_VELOCITY
           
protected  double lowError
           
protected static java.lang.String MAX_ITERATIONS
           
protected  double nnDist
           
protected  boolean notAfters
           
protected  java.util.ArrayList origSubset
           
protected  boolean subOfSub
           
protected  java.util.ArrayList subsetToInterp
           
protected  long time
           
protected static java.lang.String VECTOR_ITERATIONS
           
protected static java.lang.String VECTOR_SAMPLES
           
protected  int vectorIterations
           
protected  int vectorSamples
           
 
Fields inherited from class fsmvis.engine.SubsetNeighbourAndSampleModel
kmeans, numbers, ROOT_N_FACTOR, rootNFactor, subset, subsetContents, subsetSize
 
Fields inherited from class fsmvis.engine.NeighbourAndSampleModel
NEIGHBOUR_SIZE, neighbours, neighbourSize, SAMPLE_SIZE, samples, sampleSize
 
Fields inherited from class fsmvis.engine.SpringModel
dampingFactor, dataItems, dataSizeFactor, deltaTime, endC, force, freeness, gravityDampingForce, gravityForce, kMeansTime, layoutBounds, numIterations, position, properties, rangeHi, rangeLo, runningTime, springForce, startTime, timeDampingForce, timeForce, unrelatedDist, velocity, viewParent
 
Constructor Summary
InterpolateSampleModel(DataItemCollection dataItems, EndCriteria ec, Viewer v)
          constructor:
 
Method Summary
protected  double bestForcePos(int index, Coordinate p, Vect fIn, java.util.ArrayList sample)
          Determine the the position along a vector (scale by [0, 1]) that minimises the distance to all other sample points.
protected  int binSearch(double lB, double hB, Coordinate pos, double radi, int index, java.util.ArrayList sample)
           
protected  Coordinate cPoint(double angleIn, double radi, Coordinate posIn)
          Returns a coordinate of a point on the circumference of a circle.
 void doIteration()
          Method to perform one iteration of the layout algorithm for this layout model
 void doNormalise()
          Instruction to normalise data for spring model
 DataItem getDataItem(int index)
          Returns the data item at index index.
 java.util.List getDisplayableItems()
          Returns the indices of the items which are displayable.
protected  double getDistFromVect(double scaleValue, int index, Coordinate p, Vect fIn, java.util.ArrayList sample)
           
 void initValues()
          Initialises the values for this class, over rides the method in Spring model.
protected  void interpolateDataItem()
          Method to interpolate all of the points not in the subset, does this by finding the closest object in the subset and placing it somewhere near it
protected  void interpolateToKmeans()
          Method to interpolate all of the points not in the subset, does this by finding the closest kmeans centroid in the subset and placing it somewhere near it.
 boolean isAfters()
          Has the execution finished interpolation?
 boolean isInterpolating()
          Is the execution currently interpolating?
 void loadProperties()
          Initialises the properties for this object to be the properties held for this object
protected  int nearestNeighbour(int centroidIndex, int memberIndex)
          Returns the nearest neightbour of the given point within the kMeans cluster.
protected  void placeDataItem(int index, int parent, java.util.ArrayList pdiSample)
          Places the data Item index onto the layout (finds it initial coords) uses parent as the most similar object to it and tries to place it near to parent.
protected  void placeNearToNearestNeighbour(int index, int parent, java.util.ArrayList sample)
          Places the point close to its nearest neighbour.
 void setSizes(int v, int s)
           
protected  double sumDistToSample(int index, Coordinate p, java.util.ArrayList sample)
          Returns the sum of the difference between the desired distance and the actual distance from object index, to all of the points held in the arrayList sample
protected  Vect sumForcesToSample(int index, java.util.ArrayList sample)
          Calculates the sum of the forces from the object index to all of the points in the sample
 
Methods inherited from class fsmvis.engine.SubsetNeighbourAndSampleModel
getApproxError, getApproxVelocity, getAvgError, getAvgVelocity, getStress, getSubsetSize, iterateFullSet, randomizeSample, setSubset, setSubsetSize
 
Methods inherited from class fsmvis.engine.NeighbourAndSampleModel
calcForces, findNewNeighbours, randomizeSample
 
Methods inherited from class fsmvis.engine.SpringModel
addForces, calcGravityForce, calcTimeForce, getDataItemCollection, getExecutionTime, getNumIterations, getPosition, getProperties, init, integrateChanges, randomizePositions, resetIterations, setDataItemCollection, updateValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

origSubset

protected java.util.ArrayList origSubset

interpSubset

protected java.util.ArrayList interpSubset

interpSubsetSize

protected int interpSubsetSize

interpSubsetContents

protected java.util.HashSet interpSubsetContents

interpSubsetNums

protected java.util.ArrayList interpSubsetNums

subOfSub

protected boolean subOfSub

dataSampleSize

protected int dataSampleSize

circumfSamples

protected int circumfSamples

vectorIterations

protected int vectorIterations

vectorSamples

protected int vectorSamples

lowError

protected double lowError

endC

protected EndCriteria endC

time

protected long time

bStable

protected boolean bStable

bKmeans

protected boolean bKmeans

notAfters

protected boolean notAfters

interpCount

protected int interpCount

increaseInSize

protected int increaseInSize

isInterpolating

protected boolean isInterpolating

iterationsSubTotal

protected int iterationsSubTotal

subsetToInterp

protected java.util.ArrayList subsetToInterp

currentInterp

protected int currentInterp

DATA_SAMPLE_SIZE

protected static final java.lang.String DATA_SAMPLE_SIZE

CIRCUMF_SAMPLES

protected static final java.lang.String CIRCUMF_SAMPLES

VECTOR_ITERATIONS

protected static final java.lang.String VECTOR_ITERATIONS

VECTOR_SAMPLES

protected static final java.lang.String VECTOR_SAMPLES

MAX_ITERATIONS

protected static final java.lang.String MAX_ITERATIONS

LOW_VELOCITY

protected static final java.lang.String LOW_VELOCITY

LOW_ERROR

protected static final java.lang.String LOW_ERROR

nnDist

protected double nnDist

bKMeansInterpFinished

protected boolean bKMeansInterpFinished
Constructor Detail

InterpolateSampleModel

public InterpolateSampleModel(DataItemCollection dataItems,
                              EndCriteria ec,
                              Viewer v)
constructor:
Parameters:
dataItems - The dataset to be used with this collection
Method Detail

loadProperties

public void loadProperties()
Initialises the properties for this object to be the properties held for this object
Overrides:
loadProperties in class SubsetNeighbourAndSampleModel

doNormalise

public void doNormalise()
Instruction to normalise data for spring model
Overrides:
doNormalise in class SubsetNeighbourAndSampleModel

initValues

public void initValues()
Initialises the values for this class, over rides the method in Spring model. Makes a call to super first.
Overrides:
initValues in class SubsetNeighbourAndSampleModel

doIteration

public void doIteration()
                 throws TooManyIterationsException
Method to perform one iteration of the layout algorithm for this layout model
Overrides:
doIteration in class SubsetNeighbourAndSampleModel

interpolateDataItem

protected void interpolateDataItem()
Method to interpolate all of the points not in the subset, does this by finding the closest object in the subset and placing it somewhere near it

placeDataItem

protected void placeDataItem(int index,
                             int parent,
                             java.util.ArrayList pdiSample)
Places the data Item index onto the layout (finds it initial coords) uses parent as the most similar object to it and tries to place it near to parent. Then does vector stuff
Parameters:
index - The data item that is being placed
parent - The data item that is closest to this point

sumDistToSample

protected double sumDistToSample(int index,
                                 Coordinate p,
                                 java.util.ArrayList sample)
Returns the sum of the difference between the desired distance and the actual distance from object index, to all of the points held in the arrayList sample
Parameters:
index - The index of the object which all dists are measured from
p - The new coordinate that is being evaluated for index
sample - The arrayList of indices to measure dists to
Returns:
The sum of the desired distances

sumForcesToSample

protected Vect sumForcesToSample(int index,
                                 java.util.ArrayList sample)
Calculates the sum of the forces from the object index to all of the points in the sample
Parameters:
index -  
sample -  
Returns:
The resultant force from the object to the sample

getDisplayableItems

public java.util.List getDisplayableItems()
Returns the indices of the items which are displayable. By default this returns null. However, if it was required to only display a portion of the data set at a time this method could be overriden. Anyone interested in viewing the items should call this method, if it returns null then they can use all available indices
Returns:
The indices of the displayable data items
Overrides:
getDisplayableItems in class SpringModel

getDataItem

public DataItem getDataItem(int index)
Returns the data item at index index. Overrides the method in SpringModel, returns the data item with index of the subset item with index.
Parameters:
index - The index of the data item wanted
Returns:
The data item that was at this index
Overrides:
getDataItem in class SpringModel

isInterpolating

public boolean isInterpolating()
Is the execution currently interpolating?
Returns:
whether or not currently interpolating

isAfters

public boolean isAfters()
Has the execution finished interpolation?
Returns:
whether or not afters

setSizes

public void setSizes(int v,
                     int s)
Overrides:
setSizes in class NeighbourAndSampleModel

interpolateToKmeans

protected void interpolateToKmeans()
Method to interpolate all of the points not in the subset, does this by finding the closest kmeans centroid in the subset and placing it somewhere near it.

nearestNeighbour

protected int nearestNeighbour(int centroidIndex,
                               int memberIndex)
Returns the nearest neightbour of the given point within the kMeans cluster.
Parameters:
centroidIndex - The data item that is surrogate for the kmeans centroid.
memberIndex - The data item that is being placed.

placeNearToNearestNeighbour

protected void placeNearToNearestNeighbour(int index,
                                           int parent,
                                           java.util.ArrayList sample)
Places the point close to its nearest neighbour.
Parameters:
nnIndex - Index of the (probable) nearest neighbour.
memberIndex - Index of the item being placed.
centroidIndex - Index of the surrogate kmeans centroid.

bestForcePos

protected double bestForcePos(int index,
                              Coordinate p,
                              Vect fIn,
                              java.util.ArrayList sample)
Determine the the position along a vector (scale by [0, 1]) that minimises the distance to all other sample points.

getDistFromVect

protected double getDistFromVect(double scaleValue,
                                 int index,
                                 Coordinate p,
                                 Vect fIn,
                                 java.util.ArrayList sample)

cPoint

protected Coordinate cPoint(double angleIn,
                            double radi,
                            Coordinate posIn)
Returns a coordinate of a point on the circumference of a circle.
Parameters:
angleIn - The angle to the circle's centre.
radi - The radius of the circle.
posIn - the position of the centre of the circle.

binSearch

protected int binSearch(double lB,
                        double hB,
                        Coordinate pos,
                        double radi,
                        int index,
                        java.util.ArrayList sample)