Package ca.nengo.model.impl

Source Code of ca.nengo.model.impl.DelayedLinearExponentialTermination

package ca.nengo.model.impl;

import java.util.ArrayList;

import ca.nengo.model.InstantaneousOutput;
import ca.nengo.model.Node;
import ca.nengo.model.SimulationException;
import ca.nengo.model.Units;

/**
* A LinearExponentialTermination where all inputs are delayed by a fixed number of
* timesteps.
*
* @author Daniel Rasmussen
*/
public class DelayedLinearExponentialTermination extends LinearExponentialTermination {
 
  private static final long serialVersionUID = 1L;
 
  private int myDelay;
  private ArrayList<InstantaneousOutput> myQueue;
 
 
   /**
    * 
   * @param delay delay in timesteps between when input arrives at this termination and when it will be processed
   * @see LinearExponentialTermination#LinearExponentialTermination(Node, String, float[], float)
   */
  public DelayedLinearExponentialTermination(Node node, String name, float[] weights, float tauPSC, int delay) {
    super(node, name, weights, tauPSC);
    myDelay = delay;
    myQueue = new ArrayList<InstantaneousOutput>(myDelay*3);
    for(int i=0; i < myDelay; i++)
      myQueue.add(new RealOutputImpl(new float[weights.length], Units.UNK, 0.0f));
  }
 
  /**
   * Adds a value to this termination's queue.  That value will not actually be
   * processed until myDelay timesteps have called (we are assuming this function
   * will be called once per timestep).
   *
   * @see LinearExponentialTermination#setValues(InstantaneousOutput)
   */
  public void setValues(InstantaneousOutput values) throws SimulationException {
    myQueue.add(values);
    InstantaneousOutput v = myQueue.remove(0);
    super.setValues(v);
  }
}
TOP

Related Classes of ca.nengo.model.impl.DelayedLinearExponentialTermination

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.