ca.nengo.sim.impl
Class LocalSimulator

java.lang.Object
  extended by ca.nengo.sim.impl.LocalSimulator
All Implemented Interfaces:
Simulator, VisiblyMutable, java.io.Serializable, java.lang.Cloneable

public class LocalSimulator
extends java.lang.Object
implements Simulator, java.io.Serializable

A Simulator that runs locally (ie in the Java Virtual Machine in which it is called). TODO: test

Author:
Bryan Tripp
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface ca.nengo.util.VisiblyMutable
VisiblyMutable.Event, VisiblyMutable.Listener, VisiblyMutable.NameChangeEvent, VisiblyMutable.NodeRemovedEvent
 
Constructor Summary
LocalSimulator()
           
 
Method Summary
 void addChangeListener(VisiblyMutable.Listener listener)
           
 Probe addProbe(java.lang.String ensembleName, int neuronIndex, java.lang.String state, boolean record)
           
 Probe addProbe(java.lang.String ensembleName, Probeable target, java.lang.String state, boolean record)
           
 Probe addProbe(java.lang.String nodeName, java.lang.String state, boolean record)
           
 void addSimulatorListener(SimulatorListener listener)
           
 Simulator clone()
           
protected  void fireSimulatorEvent(SimulatorEvent event)
           
 Probe[] getProbes()
           
 void initialize(Network network)
          Initializes the Simulator with a given Network, after which changes to the Network MAY OR MAY NOT BE IGNORED.
 void removeChangeListener(VisiblyMutable.Listener listener)
           
 void removeProbe(Probe probe)
           
 void removeSimulatorListener(SimulatorListener listener)
           
 void resetNetwork(boolean randomize, boolean saveWeights)
          Resets all Nodes in the simulated Network.
 void resetProbes()
          Resets all probes in the network, recursively including subnetworks.
 void run(float startTime, float endTime, float stepSize)
          Runs the Network for the given time range.
 void run(float startTime, float endTime, float stepSize, boolean topLevel)
          Run function with option to display (or not) the progress in the console
 void setDisplayProgress(boolean display)
           
 void step(float startTime, float endTime)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalSimulator

public LocalSimulator()
Method Detail

initialize

public void initialize(Network network)
Description copied from interface: Simulator
Initializes the Simulator with a given Network, after which changes to the Network MAY OR MAY NOT BE IGNORED. This is because the Simulator is free to either run the given Neurons/Ensembles, or to make copies of them and run the copies. (The latter is likely in a clustered implementation.) If you make changes to the Network after initializing a Simulator with it, initialize again. If you want the Network to change somehow mid-simulation (e.g. you want to remove some neurons from an Ensemble to test robustness), these changes should be performed by the Ensembles or Neurons themselves, i.e. they should be an explicit part of the model.

Specified by:
initialize in interface Simulator
Parameters:
network - Network to set up for simulation
See Also:
Simulator.initialize(ca.nengo.model.Network)

resetProbes

public void resetProbes()
Description copied from interface: Simulator
Resets all probes in the network, recursively including subnetworks.

Specified by:
resetProbes in interface Simulator
See Also:
Simulator.resetProbes()

run

public void run(float startTime,
                float endTime,
                float stepSize)
         throws SimulationException
Description copied from interface: Simulator
Runs the Network for the given time range. The states of all components of the Network are assumed to be consistent with the given start time. So, you could reset to the t=0 state, and then immediately start running from t=100, but the results may not make sense.

Specified by:
run in interface Simulator
Parameters:
startTime - Simulation time at which running starts
endTime - Simulation time at which running stops
stepSize - Length of time step at which the Network is run. This determines the frequency with which outputs are passed between Ensembles, but individual Neurons may run with different and/or variable time steps.
Throws:
SimulationException - if a problem is encountered while trying to run
See Also:
Simulator.run(float, float, float)

run

public void run(float startTime,
                float endTime,
                float stepSize,
                boolean topLevel)
         throws SimulationException
Run function with option to display (or not) the progress in the console

Specified by:
run in interface Simulator
Parameters:
startTime - Simulation time at which running starts
endTime - Simulation time at which running stops
stepSize - Length of time step at which the Network is run. This determines the frequency with which outputs are passed between Ensembles, but individual Neurons may run with different and/or variable time steps.
topLevel - true if the network being run is the top level network, false if it is a subnetwork
Throws:
SimulationException - if a problem is encountered while trying to run

step

public void step(float startTime,
                 float endTime)
          throws SimulationException
Throws:
SimulationException

resetNetwork

public void resetNetwork(boolean randomize,
                         boolean saveWeights)
Description copied from interface: Simulator
Resets all Nodes in the simulated Network.

Specified by:
resetNetwork in interface Simulator
Parameters:
randomize - True indicates reset to random initial condition (see Resettable.reset(boolean)).
saveWeights - True indicates that the weights on LinearExponentialTerminations should be saved rather than reset
See Also:
ca.nengo.sim.Simulator#resetNetwork(boolean)

addProbe

public Probe addProbe(java.lang.String nodeName,
                      java.lang.String state,
                      boolean record)
               throws SimulationException
Specified by:
addProbe in interface Simulator
Parameters:
nodeName - Name of a Probeable Node from which state is to be probed
state - The name of the state variable to probe
record - Probe retains history if true
Returns:
A Probe connected to the specified Node
Throws:
SimulationException - if the referenced Node can not be found, or is not Probeable, or does not have the specified state variable
See Also:
Simulator.addProbe(java.lang.String, java.lang.String, boolean)

addProbe

public Probe addProbe(java.lang.String ensembleName,
                      int neuronIndex,
                      java.lang.String state,
                      boolean record)
               throws SimulationException
Specified by:
addProbe in interface Simulator
Parameters:
ensembleName - Name of Ensemble containing a Probeable Neuron from which state is to be probed
neuronIndex - Index of the Neuron (from 0) within the specified Ensemble
state - The name of the state variable to probe
record - Probe retains history if true
Returns:
A Probe connected to the specified Neuron
Throws:
SimulationException - if the referenced Neuron can not be found, or is not Probeable, or does not have the specified state variable
See Also:
Simulator.addProbe(java.lang.String, int, java.lang.String, boolean)

addProbe

public Probe addProbe(java.lang.String ensembleName,
                      Probeable target,
                      java.lang.String state,
                      boolean record)
               throws SimulationException
Specified by:
addProbe in interface Simulator
Parameters:
ensembleName - Name of Ensemble the target belongs to. Null, if the target is a top-level node
target - Probeable target
state - The name of the state variable to probe
record - Probe retains history if true
Returns:
A Probe connected to the specified Neuron
Throws:
SimulationException - if the referenced Neuron can not be found, or is not Probeable, or does not have the specified state variable
See Also:
Simulator.addProbe(java.lang.String, int, java.lang.String, boolean)

removeProbe

public void removeProbe(Probe probe)
                 throws SimulationException
Specified by:
removeProbe in interface Simulator
Parameters:
probe - Probe to be removed
Throws:
SimulationException - if the referenced probe cannot be removed
See Also:
Simulator.removeProbe(ca.nengo.util.Probe)

getProbes

public Probe[] getProbes()
Specified by:
getProbes in interface Simulator
Returns:
List of Probes that have been added to this Simulator.
See Also:
Simulator.getProbes()

setDisplayProgress

public void setDisplayProgress(boolean display)

addSimulatorListener

public void addSimulatorListener(SimulatorListener listener)
Specified by:
addSimulatorListener in interface Simulator
Parameters:
listener - A Simulator listener to be added
See Also:
Simulator.addSimulatorListener(ca.nengo.sim.SimulatorListener)

fireSimulatorEvent

protected void fireSimulatorEvent(SimulatorEvent event)
Parameters:
event -

removeSimulatorListener

public void removeSimulatorListener(SimulatorListener listener)
Specified by:
removeSimulatorListener in interface Simulator
Parameters:
listener - A Simulator listener to be removed
See Also:
Simulator.removeSimulatorListener(ca.nengo.sim.SimulatorListener)

addChangeListener

public void addChangeListener(VisiblyMutable.Listener listener)
Specified by:
addChangeListener in interface VisiblyMutable
Parameters:
listener - Listener to add
See Also:
VisiblyMutable.addChangeListener(ca.nengo.util.VisiblyMutable.Listener)

removeChangeListener

public void removeChangeListener(VisiblyMutable.Listener listener)
Specified by:
removeChangeListener in interface VisiblyMutable
Parameters:
listener - Listener to remove
See Also:
VisiblyMutable.removeChangeListener(ca.nengo.util.VisiblyMutable.Listener)

clone

public Simulator clone()
                throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Simulator
Overrides:
clone in class java.lang.Object
Returns:
An independent copy of the Simulator. The copy has the same type and parameters, but doesn't reference any Network, contain any Probes, or have any SimulatorListeners
Throws:
java.lang.CloneNotSupportedException