databionics.esom.grid
Class Grid

java.lang.Object
  extended by databionics.esom.grid.Grid
Direct Known Subclasses:
MatrixGrid

public abstract class Grid
extends java.lang.Object

Abstract base class for a grid structure. A grid is a collection of weight vectors (neurons) in a grid structure. The grid concept encapsules the shape of the grid, the topology of the grid and the distance betweeen the neurons on the grid. The neurons should be uniquely numbered with 0..N-1 and be accessible via the method getNeuron(int index). The neighbors of a neuron should be can be found with the method findNeighbors(int index, IntArrayList neighbors, IntArrayList distances). Both these methods need to be implemented in subclasses. The name of all subclasses should roughly adhere to the following naming convention, consisting of

  1. Topology of the grid, e.g. planar, cylindrical, toroid, spherical
  2. Shape of the unfolded grid, optional because usually rectangular
  3. Distance function on the grid, e.g. Euclid, Manhattan, Max, Hexagon Manhattan
  4. 'Grid'
  5. Dimensionality of grid, can be omitted if 2
For 1D grids there are only two topologies, one shape, and one distance function. The following 1D grids are possible: For 2D grids the neurons can basically have 2 different shapes: squares or hexagons,but the difference is only important for distance calculations. For squares there are basically three distance functions: Euclid, Manhattan, and Max. For hexagons only the Manhattan distance makes sense, the name Hexa will be used in class names. The Euclidean distance is also possible on hexagonal grids, but especially for small distances it is almost the same as Manhattan. For rectangular grids, there are two important topologies: planar and toroid. Cylindrical in each direction is also possible, but there is no reason not to use toroid grids in the first place. A special case is a sphere that can be build out of many hexagons and some pentagons. The following 2D grids are possible but not all implemented 3D grids always have squared neurons, and only two topologies make sense. The following 3D grids are possible: Note: hyperbolical grids have not been considered here, yet, but they should fit into the abstraction mechanism as well.


Field Summary
protected  int dim
          number weights per neuron
protected  cern.colt.function.VectorVectorFunction distanceFunction
          distance function in data space
protected  java.lang.String distanceFunctionName
          distance function name for debugging
protected static org.apache.log4j.Logger log
          interface to log4j system
protected  int size
          number of grid points
 
Constructor Summary
Grid()
          Standard constructor
Grid(int size, int dim)
          Constructor with size
 
Method Summary
 int dim()
          Get the value of dim.
abstract  void findNeighbors(int index, int radius, cern.colt.list.IntArrayList neighbors, cern.colt.list.IntArrayList distances)
          Find all neighbors of a neuron within a given radius along with the distance from the center.
 cern.colt.function.VectorVectorFunction getDistanceFunction()
          Get the distance function in data space
 java.lang.String getDistanceFunctionName()
          Get the name distance function in data space
abstract  cern.colt.matrix.DoubleMatrix1D getNeuron(int index)
          Access to a weight vector by the neuron's index.
 void init(Descriptives desc)
          Initialize all weights by a normal distribution.
 void init(java.lang.String method, Descriptives desc)
          Initialize all weights by a given method.
 void init(java.lang.String method, Descriptives desc, cern.jet.random.engine.RandomEngine random)
          Initialize all weights by a given method.
 void setDim(int dim)
          Set the value of dim.
 void setDistanceFunction(cern.colt.function.VectorVectorFunction v)
          Set the distance function in data space
 void setDistanceFunction(cern.colt.function.VectorVectorFunction v, java.lang.String n)
          Set the distance function in data space
 void setSize(int size)
          Set the value of size.
 int size()
          Get the value of size.
 int transformRadius(int radius)
          How to transform an official radius into the internal format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log
interface to log4j system


size

protected int size
number of grid points


dim

protected int dim
number weights per neuron


distanceFunction

protected cern.colt.function.VectorVectorFunction distanceFunction
distance function in data space


distanceFunctionName

protected java.lang.String distanceFunctionName
distance function name for debugging

Constructor Detail

Grid

public Grid()
Standard constructor


Grid

public Grid(int size,
            int dim)
Constructor with size

Parameters:
size - number of neurons
dim - number of weights per neuron
Method Detail

size

public int size()
Get the value of size.

Returns:
value of size.

setSize

public void setSize(int size)
Set the value of size.

Parameters:
size - value of size.

dim

public int dim()
Get the value of dim.

Returns:
value of dim.

setDim

public void setDim(int dim)
Set the value of dim.

Parameters:
dim - size value of dim.

getDistanceFunction

public cern.colt.function.VectorVectorFunction getDistanceFunction()
Get the distance function in data space

Returns:
value of distanceFunction.

getDistanceFunctionName

public java.lang.String getDistanceFunctionName()
Get the name distance function in data space

Returns:
name of distanceFunction.

setDistanceFunction

public void setDistanceFunction(cern.colt.function.VectorVectorFunction v)
Set the distance function in data space

Parameters:
v - Value to assign to distanceFunction.

setDistanceFunction

public void setDistanceFunction(cern.colt.function.VectorVectorFunction v,
                                java.lang.String n)
Set the distance function in data space

Parameters:
v - Value to assign to distanceFunction.
v - Name of distanceFunction.

getNeuron

public abstract cern.colt.matrix.DoubleMatrix1D getNeuron(int index)
Access to a weight vector by the neuron's index. Override this method in subclasses.

Parameters:
index - index of neuron

findNeighbors

public abstract void findNeighbors(int index,
                                   int radius,
                                   cern.colt.list.IntArrayList neighbors,
                                   cern.colt.list.IntArrayList distances)
Find all neighbors of a neuron within a given radius along with the distance from the center. The results are saved in the two list parameters given by reference. Override this method in subclasses.

Parameters:
index - index of neuron
radius - radius around center
neighbors - list of neighbors' indices
distance - corresponding distances

transformRadius

public int transformRadius(int radius)
How to transform an official radius into the internal format. Usually the identity, but for euclid the square to avoid using a float variable for the radius

Parameters:
radius - current maximal radius
Returns:
transformed radius, default is identity

init

public void init(Descriptives desc)
Initialize all weights by a normal distribution.

Parameters:
desc - statistics about the training data

init

public void init(java.lang.String method,
                 Descriptives desc)
Initialize all weights by a given method.

Parameters:
method - name of initialization method
desc - statistics about the training data

init

public void init(java.lang.String method,
                 Descriptives desc,
                 cern.jet.random.engine.RandomEngine random)
Initialize all weights by a given method.

Parameters:
method - name of initialization method
desc - statistics about the training data
random - An already existing random number generator.


Copyright © 2005-2006 Databionics Research Group. All Rights Reserved.