Package ca.nengo.model.impl

Examples of ca.nengo.model.impl.RealOutputImpl


   
    public InstantaneousOutput run(float[] time, float[] current) {
      if (myMode.equals(SimulationMode.DEFAULT)) {
        return new SpikeOutputImpl(new boolean[]{myNextSpikeOutput}, Units.SPIKES, 0);
      } else {
        return new RealOutputImpl(new float[]{myNextRateOutput}, Units.SPIKES_PER_S, 0);
      }
    }
View Full Code Here


   */
  public InstantaneousOutput run(float[] time, float[] current) {
    InstantaneousOutput result = null;

    if (myMode.equals(SimulationMode.CONSTANT_RATE) || myMode.equals(SimulationMode.RATE)) {
      result = new RealOutputImpl(new float[]{doConstantRateRun(time[0], current[0])}, Units.SPIKES_PER_S, time[time.length-1]);
    } else if (myMode.equals(SimulationMode.PRECISE)) {
      result = new PreciseSpikeOutputImpl(new float[]{doPreciseSpikingRun(time, current)}, Units.SPIKES, time[time.length-1]);
    } else {
      //result = new SpikeOutputImpl(new boolean[]{doSpikingRun(time, current)}, Units.SPIKES, time[time.length-1]);
      result = new SpikeOutputImpl(new boolean[]{doPreciseSpikingRun(time, current)>=0}, Units.SPIKES, time[time.length-1]);
View Full Code Here

          count = origins.length;
 
          for (j = 0; j < count; j++) {
            float[] currentRepOutput = representedOutputValues[i][j];
            if(currentRepOutput != null){
              origins[j].setValues(new RealOutputImpl(
                  currentRepOutput.clone(),
                    Units.UNK, endTime));
            }
          }
        }
View Full Code Here

   
    Map<String, float[][]> terminations2 = new HashMap<String, float[][]>(10);
    terminations2.put("a", MU.I(2));
    terminations2.put("b", MU.I(2));
    PassthroughNode node2 = new PassthroughNode("test2", 2, terminations2);
    node2.getTermination("a").setValues(new RealOutputImpl(new float[]{10, 5}, Units.UNK, 0));
    node2.getTermination("b").setValues(new RealOutputImpl(new float[]{1, 0}, Units.UNK, 0));
    node2.run(0, .01f);
    RealOutput out2 = (RealOutput) node2.getOrigin(PassthroughNode.ORIGIN).getValues();
    TestUtil.assertClose(11, out2.getValues()[0], .001f);
    TestUtil.assertClose(5, out2.getValues()[1], .001f);
   
    Map<String, float[][]> terminations3 = new HashMap<String, float[][]>(10);
    terminations3.put("a", new float[][]{new float[]{1, -1}});
    PassthroughNode node3 = new PassthroughNode("test3", 1, terminations3);
    node3.getTermination("a").setValues(new RealOutputImpl(new float[]{10, 3}, Units.UNK, 0));
    node3.run(0, .01f);
    RealOutput out3 = (RealOutput) node3.getOrigin(PassthroughNode.ORIGIN).getValues();
    TestUtil.assertClose(7, out3.getValues()[0], .001f);
  }
View Full Code Here

    public InstantaneousOutput run(float[] time, float[] current) {
        InstantaneousOutput result = null;

        //calculates rate as a function of current
        if (myMode.equals(SimulationMode.CONSTANT_RATE)) {
            result = new RealOutputImpl(new float[]{myRateFunction.map(new float[]{current[0]})}, Units.SPIKES_PER_S, time[time.length-1]);
        } else if (myMode.equals(SimulationMode.RATE)) {
            float totalTimeSpan = time[time.length-1] - time[0];
            float ratePerSecond = myRateFunction.map(new float[]{MU.mean(current)});
            float ratePerStep = totalTimeSpan * ratePerSecond;
            float numSpikes = ratePerStep;

            result = new RealOutputImpl(new float[]{numSpikes / totalTimeSpan}, Units.SPIKES_PER_S, time[time.length-1]);
        } else if (smooth) {
            boolean spike = false;
            for (int i = 0; i < time.length - 1; i++) {
                float timeSpan = time[i+1] - time[i];
                float rate = myRateFunction.map(new float[]{current[i]});
View Full Code Here

    if (myMode.equals(SimulationMode.CONSTANT_RATE)) {
      if (!myConstantRateFunctionOK) {
                setConstantRateFunction();
            }
      float rate = myConstantRateFunction.map(new float[]{current[current.length-1]});
      return new RealOutputImpl(new float[]{rate}, Units.SPIKES_PER_S, time[time.length-1]);
    } else {
      boolean spike = false;

      myDynamicsOutput = myIntegrator.integrate(myDynamics, new TimeSeries1DImpl(time, current, Units.uAcm2));
      float[][] values = myDynamicsOutput.getValues();
View Full Code Here

      if (Vm > Vf) {
                rate = 1f / getRefreactoryTime(Vm);
            }

      myMembranePotentialHistory = new TimeSeries1DImpl(new float[]{time[0]}, new float[]{Vm}, Units.mV);
      result = new RealOutputImpl(new float[]{rate}, Units.SPIKES_PER_S, time[time.length-1]);
    } else {
      float[][] input = new float[current.length][];
      for (int i = 0; i < input.length; i++) {
        input[i] = new float[]{current[i], myDopamine};
      }

      TimeSeries output = myIntegrator.integrate(myDynamics,
          new TimeSeriesImpl(time, input, new Units[]{Units.uAcm2, Units.UNK}));

      myMembranePotentialHistory = output;

      if (myMode.equals(SimulationMode.RATE)) {
        float Vm = output.getValues()[0][0];
        float rate = (Vm > Vf) ? 1f / getRefreactoryTime(Vm) : 0;
        result = new RealOutputImpl(new float[]{rate}, Units.SPIKES_PER_S, time[time.length-1]);
      } else {
        boolean spike = false;
        for (int i = 0; i < output.getTimes().length && !spike; i++) { //note: this only allows 1 spike / step
          float Vm = output.getValues()[i][0];
          if (Vm > Vf) {
View Full Code Here

     * @param mode Target simulation mode
     * @see ca.nengo.model.neuron.Neuron#setMode(ca.nengo.model.SimulationMode)
     */
    public void setMode(SimulationMode mode) {
        if (mode == SimulationMode.CONSTANT_RATE || mode == SimulationMode.RATE){
            myOutput = new RealOutputImpl(new float[]{0.0f}, Units.SPIKES_PER_S, 0);
        } else {
            myOutput = new SpikeOutputImpl(new boolean[]{false}, Units.SPIKES, 0);
        }
    }
View Full Code Here

    }
   
    public void reset(boolean randomize) {
      myGenerator.reset(randomize);
      if (myOutput instanceof RealOutputImpl){
            myOutput = new RealOutputImpl(new float[]{0.0f}, Units.SPIKES_PER_S, 0);
        } else {
            myOutput = new SpikeOutputImpl(new boolean[]{false}, Units.SPIKES, 0);
        }
    }
View Full Code Here

  /*
   * Test method for 'ca.bpt.cn.model.impl.SpikingNeuron.run(float, float)'
   */
  public void testRun() throws StructuralException, SimulationException {
    myIntegrator.addTermination("test", new float[]{1}, .005f, false);
    myIntegrator.getTerminations()[0].setValues(new RealOutputImpl(new float[]{5}, Units.SPIKES_PER_S, 0));
   
    myNeuron.run(0, .005f);
    InstantaneousOutput output = myNeuron.getOrigins()[0].getValues();
    assertTrue(output instanceof SpikeOutput);
    assertTrue(((SpikeOutput) output).getValues()[0] == false);
View Full Code Here

TOP

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

Copyright © 2018 www.massapicom. 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.