ca.nengo.model.nef.impl
Class DecodedOrigin

java.lang.Object
  extended by ca.nengo.model.nef.impl.DecodedOrigin
All Implemented Interfaces:
Noise.Noisy, Origin, Resettable, SimulationMode.ModeConfigurable, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
BiasOrigin

public class DecodedOrigin
extends java.lang.Object
implements Origin, Resettable, SimulationMode.ModeConfigurable, Noise.Noisy

An Origin of functions of the state variables of an NEFEnsemble. TODO: how do units fit in. define in constructor? ignore? TODO: select nodes make up decoded origin

Author:
Bryan Tripp
See Also:
Serialized Form

Constructor Summary
DecodedOrigin(Node node, java.lang.String name, Node[] nodes, java.lang.String nodeOrigin, Function[] functions, float[][] decoders)
          With this constructor decoding vectors are specified by the caller.
DecodedOrigin(Node node, java.lang.String name, Node[] nodes, java.lang.String nodeOrigin, Function[] functions, LinearApproximator approximator)
          With this constructor, decoding vectors are generated using default settings.
 
Method Summary
 Origin clone()
           
 float[][] getDecoders()
           
 int getDimensions()
           
 float[] getError()
           
 Function[] getFunctions()
           
 SimulationMode getMode()
           
 java.lang.String getName()
           
 Node getNode()
           
protected  java.lang.String getNodeOrigin()
           
 Noise getNoise()
           
 InstantaneousOutput getValues()
           
 void reset(boolean randomize)
           
 void run(float[] state, float startTime, float endTime)
          Must be called at each time step after Nodes are run and before getValues().
 void setDecoders(float[][] decoders)
           
 void setMode(SimulationMode mode)
          Sets the object to run in either the given mode or the closest mode that it supports (all ModeConfigurables must support SimulationMode.DEFAULT, and must default to this mode).
 void setNoise(Noise noise)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecodedOrigin

public DecodedOrigin(Node node,
                     java.lang.String name,
                     Node[] nodes,
                     java.lang.String nodeOrigin,
                     Function[] functions,
                     LinearApproximator approximator)
              throws StructuralException
With this constructor, decoding vectors are generated using default settings.

Parameters:
node - The parent Node
name - Name of this Origin
nodes - Nodes that belong to the NEFEnsemble from which this Origin arises
nodeOrigin - Name of the Origin on each given node from which output is to be decoded
functions - Output Functions on the vector that is represented by the NEFEnsemble (one Function per dimension of output). For example if the Origin is to output x1*x2, where the ensemble represents [x1 x1], then one 2D function would be needed in this list. The input dimension of each function must be the same as the dimension of the state vector represented by this ensemble.
Throws:
StructuralException - if functions do not all have the same input dimension (we don't check against the state dimension at this point)

DecodedOrigin

public DecodedOrigin(Node node,
                     java.lang.String name,
                     Node[] nodes,
                     java.lang.String nodeOrigin,
                     Function[] functions,
                     float[][] decoders)
              throws StructuralException
With this constructor decoding vectors are specified by the caller.

Parameters:
node - The parent Node
name - As in other constructor
nodes - As in other constructor
nodeOrigin - Name of the Origin on each given node from which output is to be decoded
functions - As in other constructor
decoders - Decoding vectors which are scaled by the main output of each Node, and then summed, to estimate the same function of the ensembles state vector that is defined by the 'functions' arg. The 'functions' arg is still needed, because in DIRECT SimulationMode, these functions are used directly. The 'decoders' arg allows the caller to provide decoders that are generated with non-default methods or parameters (eg an unusual number of singular values). Must be a matrix with one row per Node and one column per function.
Throws:
StructuralException - If dimensions.length != neurons.length, decoders is not a matrix (ie all elements with same length), or if the number of columns in decoders is not equal to the number of functions
Method Detail

getError

public float[] getError()
Returns:
Mean-squared error of this origin over randomly selected points

setNoise

public void setNoise(Noise noise)
Specified by:
setNoise in interface Noise.Noisy
Parameters:
noise - New output noise model (defaults to no noise)

getNoise

public Noise getNoise()
Specified by:
getNoise in interface Noise.Noisy
Returns:
Noise with which output of this Origin is corrupted

reset

public void reset(boolean randomize)
Specified by:
reset in interface Resettable
Parameters:
randomize - True indicates that the object should be reset to a randomly selected initial state (the object must be aware of the distribution from which to draw from). False indicates that the object should be reset to a fixed initial state (which it must also know). Some objects may not support randomization of the initial state, in which case a fixed state will be used in either case.
See Also:
Resettable.reset(boolean)

getName

public java.lang.String getName()
Specified by:
getName in interface Origin
Returns:
Name of this Origin (unique in the scope of a source of Origins, eg a Neuron or Ensemble)
See Also:
Origin.getName()

getDimensions

public int getDimensions()
Specified by:
getDimensions in interface Origin
Returns:
Dimensionality of information coming from this Origin (eg number of axons, or dimension of decoded function of variables represented by the Ensemble)
See Also:
Origin.getDimensions()

getDecoders

public float[][] getDecoders()
Returns:
Decoding vectors for each Node

setDecoders

public void setDecoders(float[][] decoders)
Parameters:
decoders - New decoding vectors (row per Node)

setMode

public void setMode(SimulationMode mode)
Description copied from interface: SimulationMode.ModeConfigurable
Sets the object to run in either the given mode or the closest mode that it supports (all ModeConfigurables must support SimulationMode.DEFAULT, and must default to this mode).

Specified by:
setMode in interface SimulationMode.ModeConfigurable
Parameters:
mode - Requested simulation mode

getMode

public SimulationMode getMode()
Specified by:
getMode in interface SimulationMode.ModeConfigurable
Returns:
The mode in which the Ensemble is currently running.

run

public void run(float[] state,
                float startTime,
                float endTime)
         throws SimulationException
Must be called at each time step after Nodes are run and before getValues().

Parameters:
state - Idealized state (as defined by inputs) which can be fed into (idealized) functions that make up the Origin, when it is running in DIRECT mode. This is not used in other modes, and can be null.
startTime - simulation time of timestep onset
endTime - simulation time of timestep end
Throws:
SimulationException - If the given state is not of the expected dimension (ie the input dimension of the functions provided in the constructor)

getValues

public InstantaneousOutput getValues()
                              throws SimulationException
Specified by:
getValues in interface Origin
Returns:
Instantaneous output from this Origin.
Throws:
SimulationException - if there is any problem retrieving values
See Also:
Origin.getValues()

getFunctions

public Function[] getFunctions()
Returns:
List of Functions approximated by this DecodedOrigin

getNodeOrigin

protected java.lang.String getNodeOrigin()
Returns:
Name of Node-level Origin on which this DecodedOrigin is based

getNode

public Node getNode()
Specified by:
getNode in interface Origin
Returns:
The Node to which the Origin belongs
See Also:
Origin.getNode()

clone

public Origin clone()
             throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Origin
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException