ca.nengo.model.nef.impl
Class NEFEnsembleFactoryImpl

java.lang.Object
  extended by ca.nengo.model.nef.impl.NEFEnsembleFactoryImpl
All Implemented Interfaces:
NEFEnsembleFactory, java.io.Serializable

public class NEFEnsembleFactoryImpl
extends java.lang.Object
implements NEFEnsembleFactory, java.io.Serializable

Default implementation of NEFEnsembleFactory.

Author:
Bryan Tripp
See Also:
Serialized Form

Constructor Summary
NEFEnsembleFactoryImpl()
           
 
Method Summary
protected  void addDefaultOrigins(NEFEnsemble ensemble)
          Adds standard decoded Origins to the given NEFEnsemble This method is exposed so that it can be over-ridden to change behaviour.
 void beQuiet()
          Stops the factory from printing out information to console during make process.
protected  NEFEnsemble construct(java.lang.String name, NEFNode[] nodes, float[][] encoders, ApproximatorFactory af, float[][] evalPoints, float[] radii)
          This method is exposed so that it can be over-ridden to change behaviour.
 ApproximatorFactory getApproximatorFactory()
           
 java.io.File getDatabase()
           
 VectorGenerator getEncoderFactory()
           
 VectorGenerator getEvalPointFactory()
           
 NodeFactory getNodeFactory()
           
protected  int getNumEvalPoints(int dim)
          This method is exposed so that it can be over-ridden to change behaviour.
 NEFEnsemble make(java.lang.String name, int n, float[] radii)
           
 NEFEnsemble make(java.lang.String name, int n, float[] radii, java.lang.String storageName, boolean overwrite)
          Loads an NEFEnsemble, or creates and saves it.
 NEFEnsemble make(java.lang.String name, int n, int dim)
           
 NEFEnsemble make(java.lang.String name, int n, int dim, java.lang.String storageName, boolean overwrite)
          Loads an NEFEnsemble, or creates and saves it.
 void setApproximatorFactory(ApproximatorFactory factory)
           
 void setDatabase(java.io.File database)
           
 void setEncoderFactory(VectorGenerator factory)
           
 void setEvalPointFactory(VectorGenerator factory)
           
 void setNodeFactory(NodeFactory factory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NEFEnsembleFactoryImpl

public NEFEnsembleFactoryImpl()
Method Detail

getApproximatorFactory

public ApproximatorFactory getApproximatorFactory()
Specified by:
getApproximatorFactory in interface NEFEnsembleFactory
Returns:
The factory that creates LinearApproximators used in decoding ensemble output
See Also:
NEFEnsembleFactory.getApproximatorFactory()

getEncoderFactory

public VectorGenerator getEncoderFactory()
Specified by:
getEncoderFactory in interface NEFEnsembleFactory
Returns:
The VectorGenerator used to create encoding vectors that are associated with each Node in a new Ensemble
See Also:
NEFEnsembleFactory.getEncoderFactory()

getEvalPointFactory

public VectorGenerator getEvalPointFactory()
Specified by:
getEvalPointFactory in interface NEFEnsembleFactory
Returns:
The VectorGenerator used to generate the vector states at which decoding functions are evaluated
See Also:
NEFEnsembleFactory.getEvalPointFactory()

getNodeFactory

public NodeFactory getNodeFactory()
Specified by:
getNodeFactory in interface NEFEnsembleFactory
Returns:
The NodeFactory used to create Nodes that make up new Ensembles
See Also:
NEFEnsembleFactory.getNodeFactory()

beQuiet

public void beQuiet()
Stops the factory from printing out information to console during make process.


make

public NEFEnsemble make(java.lang.String name,
                        int n,
                        int dim)
                 throws StructuralException
Specified by:
make in interface NEFEnsembleFactory
Parameters:
name - Name of the NEFEnsemble
n - Number of neurons in the ensemble
dim - Dimension of the ensemble.
Returns:
NEFEnsemble containing Neurons generated with the default NeuronFactory
Throws:
StructuralException - if there is any error attempting to create the ensemble
See Also:
NEFEnsembleFactory.make(java.lang.String, int, int)

make

public NEFEnsemble make(java.lang.String name,
                        int n,
                        float[] radii)
                 throws StructuralException
Specified by:
make in interface NEFEnsembleFactory
Parameters:
name - Name of the NEFEnsemble
n - Number of neurons in the ensemble
radii - Radius of encoded region in each dimension
Returns:
NEFEnsemble containing Neurons generated with the default NeuronFactory
Throws:
StructuralException - if there is any error attempting to create the ensemble
See Also:
NEFEnsembleFactory.make(java.lang.String, int, float[])

make

public NEFEnsemble make(java.lang.String name,
                        int n,
                        int dim,
                        java.lang.String storageName,
                        boolean overwrite)
                 throws StructuralException
Description copied from interface: NEFEnsembleFactory
Loads an NEFEnsemble, or creates and saves it.

Specified by:
make in interface NEFEnsembleFactory
Parameters:
name - Name of the NEFEnsemble
n - Number of neurons in the ensemble
dim - Dimension of the ensemble.
storageName - Name for storage (eg filename, db key; may have to be more fully qualified than name param, if ensembles belonging to multiple networks are stored in the same place)
overwrite - If false, loads the ensemble if it can be found in storage. If true, creates a new ensemble regardless and overwrites any existing ensemble.
Returns:
Either new NEFEnsemble generated according to specs and with default NeuronFactory, or a previously-created ensemble loaded from storage
Throws:
StructuralException - if there is any error attempting to create the ensemble
See Also:
NEFEnsembleFactory.make(java.lang.String, int, int, java.lang.String, boolean)

make

public NEFEnsemble make(java.lang.String name,
                        int n,
                        float[] radii,
                        java.lang.String storageName,
                        boolean overwrite)
                 throws StructuralException
Description copied from interface: NEFEnsembleFactory
Loads an NEFEnsemble, or creates and saves it.

Specified by:
make in interface NEFEnsembleFactory
Parameters:
name - Name of the NEFEnsemble
n - Number of neurons in the ensemble
radii - Radius of encoded region in each dimension.
storageName - Name for storage (eg filename, db key; may have to be more fully qualified than name param, if ensembles belonging to multiple networks are stored in the same place)
overwrite - If false, loads the ensemble if it can be found in storage. If true, creates a new ensemble regardless and overwrites any existing ensemble.
Returns:
Either new NEFEnsemble generated according to specs and with default NeuronFactory, or a previously-created ensemble loaded from storage
Throws:
StructuralException - if there is any error attempting to create the ensemble
See Also:
NEFEnsembleFactory.make(java.lang.String, int, int, java.lang.String, boolean)

setApproximatorFactory

public void setApproximatorFactory(ApproximatorFactory factory)
Specified by:
setApproximatorFactory in interface NEFEnsembleFactory
Parameters:
factory - A factory for creating the LinearApproximators used in decoding ensemble output
See Also:
NEFEnsembleFactory.setApproximatorFactory(ca.nengo.math.ApproximatorFactory)

setEncoderFactory

public void setEncoderFactory(VectorGenerator factory)
Specified by:
setEncoderFactory in interface NEFEnsembleFactory
Parameters:
factory - A VectorGenerator to be used to create encoding vectors that are associated with each Node in a new Ensemble
See Also:
NEFEnsembleFactory.setEncoderFactory(ca.nengo.util.VectorGenerator)

setEvalPointFactory

public void setEvalPointFactory(VectorGenerator factory)
Specified by:
setEvalPointFactory in interface NEFEnsembleFactory
Parameters:
factory - A VectorGenerator to be used to generate the vector states at which decoding functions are evaluated
See Also:
NEFEnsembleFactory.setEvalPointFactory(ca.nengo.util.VectorGenerator)

setNodeFactory

public void setNodeFactory(NodeFactory factory)
Specified by:
setNodeFactory in interface NEFEnsembleFactory
Parameters:
factory - NodeFactory to be used to create Nodes that make up new Ensembles
See Also:
NEFEnsembleFactory.setNodeFactory(ca.nengo.model.impl.NodeFactory)

getNumEvalPoints

protected int getNumEvalPoints(int dim)
This method is exposed so that it can be over-ridden to change behaviour.

Parameters:
dim - the dimension of the state represented by an Ensemble
Returns:
The number of points at which to approximate decoded functions

construct

protected NEFEnsemble construct(java.lang.String name,
                                NEFNode[] nodes,
                                float[][] encoders,
                                ApproximatorFactory af,
                                float[][] evalPoints,
                                float[] radii)
                         throws StructuralException
This method is exposed so that it can be over-ridden to change behaviour.

Parameters:
name - Name of new Ensemble
nodes - Nodes that make up Ensemble
encoders - Encoding vector for each Node
af - Factory that produces LinearApproximators for decoding Ensemble output
evalPoints - States at which Node output is evaluated for decoding purposes
radii - Radius of encoded area in each dimension
Returns:
New NEFEnsemble with given parameters
Throws:
StructuralException

addDefaultOrigins

protected void addDefaultOrigins(NEFEnsemble ensemble)
                          throws StructuralException
Adds standard decoded Origins to the given NEFEnsemble This method is exposed so that it can be over-ridden to change behaviour.

Parameters:
ensemble - A new NEFEnsemble
Throws:
StructuralException

getDatabase

public java.io.File getDatabase()
Returns:
Directory for saving / loading ensembles

setDatabase

public void setDatabase(java.io.File database)
Parameters:
database - New directory for saving / loading ensembles