Package ca.nengo.model.neuron.impl

Examples of ca.nengo.model.neuron.impl.LIFSpikeGenerator


  /*
   * Test method for 'ca.bpt.cn.model.impl.LIFSpikeGenerator.getHistory(String)'
   */
  public void testGetHistory() throws SimulationException {
    LIFSpikeGenerator sg = new LIFSpikeGenerator(.0005f, .02f, .002f);
    TimeSeries history = sg.getHistory("V");
    assertTrue(history instanceof TimeSeries1D);
    assertEquals(0, history.getTimes().length);
    assertEquals(0, history.getValues().length);
   
    sg.run(new float[]{0f, .002f}, new float[]{1f, 1f});
    history = sg.getHistory("V");
    assertEquals(4, history.getTimes().length);
    assertEquals(4, history.getValues().length);
    assertTrue(history.getTimes()[1] > history.getTimes()[0]);
    assertTrue(history.getValues()[1][0] > history.getValues()[0][0]);

    try {
      sg.getHistory("X");
      fail("Should have thrown exception");
    } catch (SimulationException e) {} //exception is expected
  }
View Full Code Here


  /*
   * Test method for 'ca.bpt.cn.model.impl.LIFSpikeGenerator.reset(boolean)'
   */
  public void testReset() throws SimulationException {
    float initialVoltage = .2f;
    LIFSpikeGenerator sg = new LIFSpikeGenerator(.0005f, .02f, .002f, initialVoltage);
    sg.run(new float[]{0f, .005f}, new float[]{1f, 1f});
    float[] voltage1 = ((TimeSeries1D) sg.getHistory("V")).getValues1D();

    sg.run(new float[]{0f, .005f}, new float[]{1f, 1f});
    float[] voltage2 = ((TimeSeries1D) sg.getHistory("V")).getValues1D();
   
    sg.reset(false);
   
    sg.run(new float[]{0f, .005f}, new float[]{1f, 1f});
    float[] voltage3 = ((TimeSeries1D) sg.getHistory("V")).getValues1D();
   
    assertBetween(voltage1[0], .2f, .23f);
    assertBetween(voltage2[0], .37f, .4f);
    assertBetween(voltage3[0], .2f, .23f);
  }
View Full Code Here

    float maxTimeStep = .0005f;
    float[] current = new float[]{0f, 2f, 5f};
    float[] tauRC = new float[]{0.01f, .02f};
    float[] tauRef = new float[]{.001f, .002f};

    LIFSpikeGenerator sg = new LIFSpikeGenerator(maxTimeStep, tauRC[0], tauRef[0]);
    sg.setMode(SimulationMode.CONSTANT_RATE);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[0]})).getValues()[0], -.001f, .001f);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[1]})).getValues()[0], 126f, 127f);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[2]})).getValues()[0], 309f, 310f);
       
    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[0], tauRef[1]);
    sg.setMode(SimulationMode.CONSTANT_RATE);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[0]})).getValues()[0], -.001f, .001f);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[1]})).getValues()[0], 111f, 112f);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[2]})).getValues()[0], 236f, 237f);
       
    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[1], tauRef[0]);
    sg.setMode(SimulationMode.CONSTANT_RATE);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[0]})).getValues()[0], -.001f, .001f);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[1]})).getValues()[0], 67f, 68f);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[2]})).getValues()[0], 183f, 184f);

    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[1], tauRef[1]);
    sg.setMode(SimulationMode.CONSTANT_RATE);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[0]})).getValues()[0], -.001f, .001f);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[1]})).getValues()[0], 63f, 64f);
    assertBetween(((RealOutput) sg.run(new float[1], new float[]{current[2]})).getValues()[0], 154f, 155f);
  }
View Full Code Here

    float maxTimeStep = .0005f;
    float[] current = new float[]{0f, 2f, 5f};
    float[] tauRC = new float[]{0.01f, .02f};
    float[] tauRef = new float[]{.001f, .002f};

    LIFSpikeGenerator sg = new LIFSpikeGenerator(maxTimeStep, tauRC[0], tauRef[0]);
    assertSpikesCloseToRate(sg, current[0], 1);
    assertSpikesCloseToRate(sg, current[1], 4);
    assertSpikesCloseToRate(sg, current[2], 5);
       
    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[0], tauRef[1]);
    assertSpikesCloseToRate(sg, current[0], 1);
    assertSpikesCloseToRate(sg, current[1], 4);
    assertSpikesCloseToRate(sg, current[2], 4);
       
    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[1], tauRef[0]);
    assertSpikesCloseToRate(sg, current[0], 1);
    assertSpikesCloseToRate(sg, current[1], 1);
    assertSpikesCloseToRate(sg, current[2], 10);

    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[1], tauRef[1]);
    assertSpikesCloseToRate(sg, current[0], 1);
    assertSpikesCloseToRate(sg, current[1], 1);
    assertSpikesCloseToRate(sg, current[2], 10);
  }
View Full Code Here

    assertSpikesCloseToRate(sg, current[2], 10);
  }
   
   
public void testRunPrecise() throws SimulationException {
    LIFSpikeGenerator sg = new LIFSpikeGenerator(0.001f, 0.02f, 0.002f);

    assertSpikesCloseToRate(sg, 1.46335061f, 1, SimulationMode.DEFAULT);
    assertSpikesCloseToRate(sg, 1.46335061f, 1, SimulationMode.PRECISE);

    assertSpikesCloseToRate(sg, 4.80514111f, 10, SimulationMode.DEFAULT);   
    assertSpikesCloseToRate(sg, 4.80514111f, 4, SimulationMode.PRECISE);   

   
    float maxTimeStep = .0005f;
    float[] current = new float[]{0f, 2f, 5f};
    float[] tauRC = new float[]{0.01f, .02f};
    float[] tauRef = new float[]{.001f, .002f};

    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[0], tauRef[0]);
    //assertSpikesCloseToRate(sg, current[0], 1, SimulationMode.PRECISE);
    assertSpikesCloseToRate(sg, current[1], 2, SimulationMode.PRECISE);
    assertSpikesCloseToRate(sg, current[2], 5, SimulationMode.PRECISE);
       
    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[0], tauRef[1]);
    assertSpikesCloseToRate(sg, current[0], 1, SimulationMode.PRECISE);
    assertSpikesCloseToRate(sg, current[1], 3, SimulationMode.PRECISE);
    assertSpikesCloseToRate(sg, current[2], 3, SimulationMode.PRECISE);
       
    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[1], tauRef[0]);
    assertSpikesCloseToRate(sg, current[0], 1, SimulationMode.PRECISE);
    assertSpikesCloseToRate(sg, current[1], 1, SimulationMode.PRECISE);
    assertSpikesCloseToRate(sg, current[2], 2, SimulationMode.PRECISE);

    sg = new LIFSpikeGenerator(maxTimeStep, tauRC[1], tauRef[1]);
    assertSpikesCloseToRate(sg, current[0], 1, SimulationMode.PRECISE);
    assertSpikesCloseToRate(sg, current[1], 1, SimulationMode.PRECISE);
    assertSpikesCloseToRate(sg, current[2], 2, SimulationMode.PRECISE);
   
   
View Full Code Here

  private SpikingNeuron myNeuron;
 
  protected void setUp() throws Exception {
    super.setUp();
    myIntegrator = new LinearSynapticIntegrator(.001f, Units.ACU);
    myGenerator = new LIFSpikeGenerator(.001f, .01f, .001f);
    myNeuron = new SpikingNeuron(myIntegrator, myGenerator, 1, 0, "test");   
  }
View Full Code Here

    } catch (StructuralException e) {
      e.printStackTrace();
      return null;
    }

    LIFSpikeGenerator generator = (LIFSpikeGenerator) origin.getGenerator();

    neuronData[1] = generator.getTauRC();
    neuronData[2] = generator.getTauRef();
    if (myPlasticEnsembleTerminations.size() > 0) {
      neuronData[3] = neuron.getTerminations()[0].getTau();
    } else {
      neuronData[3] = 0;
    }
    neuronData[4] = generator.getMaxTimeStep();

    int i = 0;
    for(; i < numNeurons; i++)
    {
      neuronData[i + 5] = neurons[i].getBias();
View Full Code Here

TOP

Related Classes of ca.nengo.model.neuron.impl.LIFSpikeGenerator

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.