Package ca.nengo.model

Examples of ca.nengo.model.InstantaneousOutput


    super.constructTooltips(tooltips);

    tooltips.addProperty("Dimensions", "" + getModel().getDimensions());

    try {
      InstantaneousOutput value = getModel().getValues();

      tooltips.addProperty("Time: ", "" + value.getTime());
      tooltips.addProperty("Units: ", "" + value.getUnits());

    } catch (SimulationException e) {
    }

  }
View Full Code Here


   *     the same units, and must output the same type of InstantaneousOuput (ie
   *     either SpikeOutput or RealOutput), otherwise an exception is thrown.  
   * @see ca.nengo.model.Origin#getValues()
   */
  public InstantaneousOutput getValues() throws SimulationException {
    InstantaneousOutput result = null;
   
    Units units = myNodeOrigins[0].getValues().getUnits(); //must be same for all
   
    if (myNodeOrigins[0].getValues() instanceof RealOutput) {
      result = composeRealOutput(myNodeOrigins, units);
View Full Code Here

 
  private static RealOutput composeRealOutput(Origin[] origins, Units units) throws SimulationException {
    float[] values = new float[origins.length];
   
    for (int i = 0; i < origins.length; i++) {
      InstantaneousOutput o = origins[i].getValues();
      if ( !(o instanceof RealOutput) ) {
        throw new SimulationException("Some of the Node Origins are not producing real-valued output");
      }
      if ( !o.getUnits().equals(units) ) {
        throw new SimulationException("Some of the Node Origins are producing outputs with non-matching units");
      }
     
      values[i] = ((RealOutput) o).getValues()[0];
    }
View Full Code Here

 
  private static SpikeOutput composeSpikeOutput(Origin[] origins, Units units) throws SimulationException {
    boolean[] values = new boolean[origins.length];
   
    for (int i = 0; i < origins.length; i++) {
      InstantaneousOutput o = origins[i].getValues();
      if ( !(o instanceof SpikeOutput) ) {
        throw new SimulationException("Some of the Node Origins are not producing spiking output");
      }
      if ( !o.getUnits().equals(units) ) {
        throw new SimulationException("Some of the Node Origins are producing outputs with non-matching units");
      }
     
      values[i] = ((SpikeOutput) o).getValues()[0];
    }
View Full Code Here

  private static PreciseSpikeOutput composePreciseSpikeOutput(Origin[] origins, Units units) throws SimulationException {
    float[] values = new float[origins.length];
   
    for (int i = 0; i < origins.length; i++) {
      InstantaneousOutput o = origins[i].getValues();
      if ( !(o instanceof PreciseSpikeOutput) ) {
        throw new SimulationException("Some of the Node Origins are not producing precise spiking output");
      }
      if ( !o.getUnits().equals(units) ) {
        throw new SimulationException("Some of the Node Origins are producing outputs with non-matching units");
      }
     
      values[i] = ((PreciseSpikeOutput) o).getSpikeTimes()[0];
    }
View Full Code Here

  // might have to make these protected?
  protected void runProjections(float startTime, float endTime) throws SimulationException{
   
    for (int i = myStartIndexInProjections; i < myEndIndexInProjections; i++) {
     
      InstantaneousOutput values = myProjections[i].getOrigin().getValues();
      myProjections[i].getTermination().setValues(values);
    }
   
  }
View Full Code Here

   */
  public void testGetValues() throws SimulationException {
    myGenerator.setNextOutput(true, 1f);
   
    myOrigin.run(new float[]{0f}, new float[]{0f});
    InstantaneousOutput output = myOrigin.getValues();
    assertTrue(output instanceof SpikeOutput);
    assertEquals(1, output.getDimension());
    assertEquals(Units.SPIKES, output.getUnits());
    assertEquals(1, ((SpikeOutput) output).getValues().length);
    assertEquals(true, ((SpikeOutput) output).getValues()[0]);
   
    myGenerator.setMode(SimulationMode.CONSTANT_RATE);
   
    myOrigin.run(new float[]{0f}, new float[]{0f});
    output = myOrigin.getValues();
    assertTrue(output instanceof RealOutput);
    assertEquals(1, output.getDimension());
    assertEquals(Units.SPIKES_PER_S, output.getUnits());
    assertEquals(1, ((RealOutput) output).getValues().length);
    assertTrue(((RealOutput) output).getValues()[0] > .99f);   
  }
View Full Code Here

  /**
   * @see ca.nengo.model.neuron.SpikeGenerator#run(float[], float[])
   */
  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]);
View Full Code Here

        // TODO: Test with spiking outputs?
        float[] values = new float[myDimension];
        Iterator<PassthroughTermination> it = myTerminations.values().iterator();
        while (it.hasNext()) {
          PassthroughTermination termination = it.next();
          InstantaneousOutput io = termination.getValues();
          if (io instanceof RealOutput) {
            values = MU.sum(values, ((RealOutput) io).getValues());
          } else if (io instanceof SpikeOutput) {
            boolean[] spikes = ((SpikeOutput) io).getValues();
            for (int i = 0; i < spikes.length; i++) {
              if (spikes[i]) {
                              values[i] += 1f/(endTime - startTime);
                          }
            }
          } else if (io == null) {
            throw new SimulationException("Null input to Termination " + termination.getName());
          } else {
            throw new SimulationException("Output type unknown: " + io.getClass().getName());
          }
        }
        // Send values over the socket.
        // Datagram format:
        // - bytes 1-4: Timestamp (float)
View Full Code Here

    si.addTermination("two", new float[]{1f}, 1f, false);
    si.addTermination("three", new float[]{1f}, 1f, true);

    Termination[] t = si.getTerminations();
   
    InstantaneousOutput spike = new SpikeOutputImpl(new boolean[]{true}, Units.SPIKES, 0);
   
    t[0].setValues(spike);
    t[1].setValues(spike);
    t[2].setValues(spike);
   
View Full Code Here

TOP

Related Classes of ca.nengo.model.InstantaneousOutput

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.