Examples of NEFNode


Examples of ca.nengo.model.nef.NEFNode

  protected float[] getConstantOutput(int nodeIndex, float[][] evalPoints, String origin)
      throws StructuralException, SimulationException {

    float[] result = new float[evalPoints.length];

    NEFNode node = (NEFNode) getNodes()[nodeIndex];
    synchronized (node) {
      SimulationMode mode = node.getMode();

      node.setMode(SimulationMode.CONSTANT_RATE);
      if ( !node.getMode().equals(SimulationMode.CONSTANT_RATE) ) {
        throw new StructuralException(
          "To find decoders using this method, all Nodes must support CONSTANT_RATE simulation mode");
      }

      for (int i = 0; i < result.length; i++) {
        node.setRadialInput(getRadialInput(evalPoints[i], nodeIndex));

        node.run(0f, 0f);

        RealOutput output = (RealOutput) node.getOrigin(origin).getValues();
        result[i] = output.getValues()[0];
      }

      node.setMode(mode);
    }

    return result;
  }
View Full Code Here

Examples of ca.nengo.model.nef.NEFNode

   */
  protected float[][] getSignalOutput(int nodeIndex, TimeSeries[] evalSignals, String origin) throws StructuralException, SimulationException
  {
    float[][] result = new float[evalSignals.length][];

    NEFNode node = (NEFNode) getNodes()[nodeIndex];
    synchronized (node) {
      SimulationMode mode = node.getMode();

      node.setMode(SimulationMode.RATE);
      if ( !node.getMode().equals(SimulationMode.RATE) ) {
        throw new StructuralException(
          "To find decoders using this method, all Nodes must support RATE simulation mode");
      }

      for (int i = 0; i < evalSignals.length; i++) {
        node.reset(false);
        float[][] vals = evalSignals[i].getValues();
        float[] times = evalSignals[i].getTimes();
        float dt = times[1] - times[0]; //note: we assume dt is the same across the signal
       
        result[i] = new float[times.length];
        for(int t=0; t < times.length; t++)
        {
          //two possibilities: evaluation signal represents a separate signal for each node (first case),
          //    or evaluation signal presents a single value and a separate input is calculated for each
          //    node using that node's encoder.
          if(vals[t].length == getNodes().length)
            node.setRadialInput(vals[t][nodeIndex]);
          else
            node.setRadialInput(getRadialInput(vals[t], nodeIndex));
           
 
          node.run(times[t], times[t]+dt);
 
          RealOutput output = (RealOutput) node.getOrigin(origin).getValues();
          result[i][t] = output.getValues()[0];
        }
      }

      node.setMode(mode);
    }

    return result;
  }
View Full Code Here
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.