ca.nengo.model.plasticity.impl
Class CompositePlasticityRule

java.lang.Object
  extended by ca.nengo.model.plasticity.impl.CompositePlasticityRule
All Implemented Interfaces:
PlasticityRule, Resettable, java.io.Serializable, java.lang.Cloneable

public class CompositePlasticityRule
extends java.lang.Object
implements PlasticityRule

A PlasticityRule that delegates to underlying spike-based and rate-based rules. This enables switching between rate and spiking modes in simulations with plasticity. The spike-based rule is used whenever activity at both the plastic termination and at least one origin are of type SpikeOutput. If either none of the origins has spiking activity, or the plastic termination doesn't receive spiking input, or both, then the rate-based rule is used. The type of input to other (potentially modulatory) terminations is not considered.

Note that using this class introduces substantial overhead. It may be worthwhile to switch rules manually, or to handle both types explicitly in a custom rule implementation.

TODO: test

Author:
Bryan Tripp
See Also:
Serialized Form

Nested Class Summary
static class CompositePlasticityRule.NullRule
          A null plasticity rule that always returns zeros from getDerivative().
 
Constructor Summary
CompositePlasticityRule()
          Defaults to NullRules.
CompositePlasticityRule(PlasticityRule spikeRule, PlasticityRule realRule)
           
 
Method Summary
 PlasticityRule clone()
           
 float[][] getDerivative(float[][] transform, InstantaneousOutput input, float time)
           
 PlasticityRule getRealRule()
           
 PlasticityRule getSpikeRule()
           
 void reset(boolean randomize)
           
 void setModTerminationState(java.lang.String name, InstantaneousOutput state, float time)
          Provides potentially modulatory input to the rule.
 void setOriginState(java.lang.String name, InstantaneousOutput state, float time)
          Provides state or functional output, which may serve as an indication of postsynaptic activity (used in Hebbian learning).
 void setRealRule(PlasticityRule rule)
           
 void setSpikeRule(PlasticityRule rule)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositePlasticityRule

public CompositePlasticityRule(PlasticityRule spikeRule,
                               PlasticityRule realRule)
Parameters:
spikeRule - Rule to use when both inputs and outputs are spiking
realRule - Rule to use when either input or output is real-valued

CompositePlasticityRule

public CompositePlasticityRule()
Defaults to NullRules.

Method Detail

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)

getSpikeRule

public PlasticityRule getSpikeRule()
Returns:
Rule to use when both inputs and outputs are spiking

setSpikeRule

public void setSpikeRule(PlasticityRule rule)
Parameters:
rule - Rule to use when both inputs and outputs are spiking

getRealRule

public PlasticityRule getRealRule()
Returns:
Rule to use when either input or output is real-valued

setRealRule

public void setRealRule(PlasticityRule rule)
Parameters:
rule - Rule to use when either input or output is real-valued

getDerivative

public float[][] getDerivative(float[][] transform,
                               InstantaneousOutput input,
                               float time)
Specified by:
getDerivative in interface PlasticityRule
Parameters:
transform - The present transformation matrix of a Termination
input - The present input to the Termination
time - Simulation time at which input arrives at site of plasticity
Returns:
The rate of change of each element in the transform (units per second) if input is RealOutput, otherwise the increment of each element in the transform
See Also:
PlasticityRule.getDerivative(float[][], ca.nengo.model.InstantaneousOutput, float)

setOriginState

public void setOriginState(java.lang.String name,
                           InstantaneousOutput state,
                           float time)
Description copied from interface: PlasticityRule
Provides state or functional output, which may serve as an indication of postsynaptic activity (used in Hebbian learning).

Specified by:
setOriginState in interface PlasticityRule
Parameters:
name - The name of a DecodedOrigin from the ensemble
state - The present value of output from the named Origin
time - Simulation time at which state arrives at site of plasticity
See Also:
PlasticityRule.setOriginState(java.lang.String, ca.nengo.model.InstantaneousOutput, float)

setModTerminationState

public void setModTerminationState(java.lang.String name,
                                   InstantaneousOutput state,
                                   float time)
Description copied from interface: PlasticityRule
Provides potentially modulatory input to the rule. Note that although modulatory input will most commonly be used here, an NEFEnsemble will provide outputs of all Terminations via this method regardless of whether a Termination has property Termination.MODULATORY=="true".

Specified by:
setModTerminationState in interface PlasticityRule
Parameters:
name - The name of a DecodedTermination onto the ensemble
state - The present value of output from the named Termination (may differ from its input in terms of dynamics and dimension)
time - Simulation time at which state arrives at site of plasticity
See Also:
ca.nengo.model.plasticity.PlasticityRule#setTerminationState(java.lang.String, ca.nengo.model.InstantaneousOutput, float)

clone

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