at.tuwien.ifs.somtoolbox.layers
Class ToroidLayer

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.layers.GrowingLayer
      extended by at.tuwien.ifs.somtoolbox.layers.ToroidLayer
All Implemented Interfaces:
Layer

public class ToroidLayer
extends GrowingLayer

Implementation of a toroid Self-Organizing Map layer, i.e. a "doughnut" shaped layer, whose left & right and upper & lower edges are interconnected. This class mainly adjusts distance functions.

Version:
$Id: ToroidLayer.java 3583 2010-05-21 10:07:41Z mayer $
Author:
Rudolf Mayer

Nested Class Summary
 
Nested classes/interfaces inherited from class at.tuwien.ifs.somtoolbox.layers.GrowingLayer
GrowingLayer.Flip, GrowingLayer.Rotation, GrowingLayer.UpdaterThread
 
Nested classes/interfaces inherited from interface at.tuwien.ifs.somtoolbox.layers.Layer
Layer.GridLayout, Layer.GridTopology
 
Field Summary
 
Fields inherited from class at.tuwien.ifs.somtoolbox.layers.GrowingLayer
dim, gridLayout, gridTopology, maxFeatureValues, metric, metricWeighted, minFeatureValues, ROTATIONS, skippedNonSelected, trainedNonSelected, unitDistanceMatrix, units, xSize, ySize, zSize
 
Constructor Summary
ToroidLayer(int xSize, int ySize, int zSize, String metricName, int dim, boolean normalize, boolean usePCA, long seed, InputData data)
           
ToroidLayer(int xSize, int ySize, String metricName, int dim, boolean normalize, boolean usePCA, long seed, InputData data)
           
ToroidLayer(int id, Unit su, int xSize, int ySize, int zSize, String metricName, int dim, boolean normalize, boolean usePCA, long seed, InputData data)
           
ToroidLayer(int id, Unit su, int xSize, int ySize, int zSize, String metricName, int dim, double[][][][] vectors, long seed)
           
ToroidLayer(int id, Unit su, int xSize, int ySize, String metricName, int dim, boolean normalize, boolean usePCA, long seed, InputData data)
           
ToroidLayer(int id, Unit su, int xSize, int ySize, String metricName, int dim, double[][][] vectors, long seed)
           
 
Method Summary
 double getMapDistance(int x1, int y1, int x2, int y2)
          Toroid distance on the map
 double getMapDistance(int x1, int y1, int z1, int x2, int y2, int z2)
          Returns the distance between two units on the map grid.
 double getMapDistanceSq(int x1, int y1, int z1, int x2, int y2, int z2)
           
protected  ArrayList<Unit> getNeighbouringUnits(Unit u)
          Get direct neighbours of the given unit.
protected  ArrayList<Unit> getNeighbouringUnits(Unit u, double radius)
          Convenience method for GrowingLayer.getNeighbouringUnits(int, int, int, double)
 boolean hasNeighbours(int x, int y)
          On a toroid map each unit has a neighbour
private  void initToroid()
           
 
Methods inherited from class at.tuwien.ifs.somtoolbox.layers.GrowingLayer
addDimension, calculateQuantizationErrorForUnits, checkRotation, clearLabels, clearMappedInput, clone, computeUnitFeatureWeights, equalWeights, flip, get2DUnits, getAllMappedDataNames, getAllMappedDataNames, getAllMappedDataNamesAsList, getAllSubMaps, getAllUnits, getBinAssignment, getBinCentres, getBinCentres, getBinCentresAsList, getBinDeviation, getCommonVectorLabelPrefix, getComponentPlane, getComponentPlane, getComponentPlane3D, getData, getDeviation, getDim, getExtremes, getGridLayout, getGridTopology, getIdentifier, getIdString, getLevel, getMapDistance, getMapDistanceSq, getMetric, getMostDissimilarNeighbor, getNeighbouringUnits, getNeighbouringUnits, getNeighbouringUnits, getNNearestInputs, getNNearestInputs, getNO_CPUS, getNumberOfMappedInputs, getNumberOfNotEmptyUnits, getNumberOfRegions, getQualityMeasure, getRevision, getSuperUnit, getUnit, getUnit, getUnitCount, getUnitDistanceMatrix, getUnitForDatum, getUnitForIndex, getUnitIndex, getUnits, getVirtualLayer, getWinner, getWinner, getWinner, getWinnerFromQuery, getWinners, getWinners, getWinnersAndDistances, getWinnersFromQuery, getWinningInputDataFromQuery, getXSize, getYSize, getZSize, hasMappedInput, hasNeighbours, isEdgeColumn, isEdgeRow, isValidUnitLocation, isValidUnitLocation, mapData, mapDatum, maxNeighbourhoodRadius, neighbourhoodFeatureWeight, printSize, printUnitIndices, rotate, rotate, setCommonVectorLabelPrefix, setGridLayout, setGridTopology, setNO_CPUS, setQualityMeasure, setTrainingInterruptionListener, train, train, train, train, updateUnitsNormal
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToroidLayer

public ToroidLayer(int xSize,
                   int ySize,
                   String metricName,
                   int dim,
                   boolean normalize,
                   boolean usePCA,
                   long seed,
                   InputData data)
See Also:
GrowingLayer.GrowingLayer(int, int, String, int, boolean, boolean, long, InputData)

ToroidLayer

public ToroidLayer(int xSize,
                   int ySize,
                   int zSize,
                   String metricName,
                   int dim,
                   boolean normalize,
                   boolean usePCA,
                   long seed,
                   InputData data)
See Also:
GrowingLayer.GrowingLayer(int, int, int, String, int, boolean, boolean, long, InputData)

ToroidLayer

public ToroidLayer(int id,
                   Unit su,
                   int xSize,
                   int ySize,
                   String metricName,
                   int dim,
                   boolean normalize,
                   boolean usePCA,
                   long seed,
                   InputData data)
See Also:
GrowingLayer.GrowingLayer(int, Unit, int, int, String, int, boolean, boolean, long, InputData)

ToroidLayer

public ToroidLayer(int id,
                   Unit su,
                   int xSize,
                   int ySize,
                   int zSize,
                   String metricName,
                   int dim,
                   boolean normalize,
                   boolean usePCA,
                   long seed,
                   InputData data)
See Also:
GrowingLayer.GrowingLayer(int, Unit, int, int, int, String, int, boolean, boolean, long, InputData)

ToroidLayer

public ToroidLayer(int id,
                   Unit su,
                   int xSize,
                   int ySize,
                   String metricName,
                   int dim,
                   double[][][] vectors,
                   long seed)
            throws SOMToolboxException
Throws:
SOMToolboxException
See Also:
GrowingLayer.GrowingLayer(int, Unit, int, int, String, int, double[][][], long)

ToroidLayer

public ToroidLayer(int id,
                   Unit su,
                   int xSize,
                   int ySize,
                   int zSize,
                   String metricName,
                   int dim,
                   double[][][][] vectors,
                   long seed)
            throws SOMToolboxException
Throws:
SOMToolboxException
See Also:
GrowingLayer.GrowingLayer(int, Unit, int, int, int, String, int, double[][][][], long)
Method Detail

initToroid

private void initToroid()

getMapDistance

public double getMapDistance(int x1,
                             int y1,
                             int x2,
                             int y2)
Toroid distance on the map

Overrides:
getMapDistance in class GrowingLayer

getMapDistance

public double getMapDistance(int x1,
                             int y1,
                             int z1,
                             int x2,
                             int y2,
                             int z2)
Description copied from interface: Layer
Returns the distance between two units on the map grid.

Specified by:
getMapDistance in interface Layer
Overrides:
getMapDistance in class GrowingLayer
Parameters:
x1 - the horizontal position of the first unit.
y1 - the vertical position of the first unit.
z1 - the height position of the first unit.
x2 - the horizontal position of the second unit.
y2 - the vertical position of the second unit.
z2 - the height position of the second unit.
Returns:
the distance between two units.

getMapDistanceSq

public double getMapDistanceSq(int x1,
                               int y1,
                               int z1,
                               int x2,
                               int y2,
                               int z2)
Overrides:
getMapDistanceSq in class GrowingLayer

hasNeighbours

public boolean hasNeighbours(int x,
                             int y)
                      throws LayerAccessException
On a toroid map each unit has a neighbour

Overrides:
hasNeighbours in class GrowingLayer
Throws:
LayerAccessException

getNeighbouringUnits

protected ArrayList<Unit> getNeighbouringUnits(Unit u)
                                        throws LayerAccessException
Description copied from class: GrowingLayer
Get direct neighbours of the given unit. Direct neighbours are neighbours in the same column or row of the SOM, thus this method returns at most six neighbours (two for each of the x, y and z dimensions).

Overrides:
getNeighbouringUnits in class GrowingLayer
Throws:
LayerAccessException

getNeighbouringUnits

protected ArrayList<Unit> getNeighbouringUnits(Unit u,
                                               double radius)
                                        throws LayerAccessException
Description copied from class: GrowingLayer
Convenience method for GrowingLayer.getNeighbouringUnits(int, int, int, double)

Overrides:
getNeighbouringUnits in class GrowingLayer
Throws:
LayerAccessException