Package ca.nengo.model.impl

Examples of ca.nengo.model.impl.FunctionInput


    Function[] functions = (Function[]) props.getValue(pFunctions);

    try {
      // setName((String) getProperty(pName));
      return new FunctionInput(name, functions, Units.UNK);
    } catch (StructuralException e) {
      throw new ConfigException(e.getMessage());

    }
View Full Code Here


   * @throws SimulationException
   */
  public void functionalTestSort() throws StructuralException, SimulationException {
    Network network = new NetworkImpl();
   
    FunctionInput input = new FunctionInput("input", new Function[]{new SineFunction(5)}, Units.UNK);
    network.addNode(input);
   
    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
    NEFEnsemble ensemble = ef.make("ensemble", 100, 1);
    ensemble.addDecodedTermination("input", MU.I(1), .005f, false);
    ensemble.collectSpikes(true);
    network.addNode(ensemble);
   
    network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), ensemble.getTermination("input"));
    network.run(0, 2);
   
    SpikePattern unsorted = ensemble.getSpikePattern();
    SpikePattern sorted = DataUtils.sort(unsorted, ensemble);
   
View Full Code Here

            ensemble.addDecodedTermination("input", MU.I(1), .01f, false);
            Plotter.plot(ensemble);

            Network network = new NetworkImpl();
            network.addNode(ensemble);
            FunctionInput input = new FunctionInput("input", new Function[]{new SineFunction(3)}, Units.UNK);
            network.addNode(input);
            network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), ensemble.getTermination("input"));

            network.setMode(SimulationMode.RATE);
            Probe rates = network.getSimulator().addProbe("test", "rate", true);
            network.run(0, 2);
            //          Plotter.plot(rates.getData(), .05f, "rates");
View Full Code Here

  /*
   * Test method for 'ca.nengo.model.impl.FunctionInput.getName()'
   */
  public void testGetName() throws StructuralException {
    String name = "test";
    FunctionInput input = new FunctionInput(name, new Function[]{new ConstantFunction(1, 1f)}, Units.UNK);
    assertEquals(name, input.getName());
  }
View Full Code Here

  /*
   * Test method for 'ca.nengo.model.impl.FunctionInput.getDimensions()'
   */
  public void testGetDimensions() throws StructuralException {
    FunctionInput input = new FunctionInput("test", new Function[]{new ConstantFunction(1, 1f)}, Units.UNK);
    assertEquals(1, input.getOrigin(FunctionInput.ORIGIN_NAME).getDimensions());

    input = new FunctionInput("test", new Function[]{new ConstantFunction(1, 1f), new ConstantFunction(1, 1f)}, Units.UNK);
    assertEquals(2, input.getOrigin(FunctionInput.ORIGIN_NAME).getDimensions());   
   
    try {
      input = new FunctionInput("test", new Function[]{new ConstantFunction(2, 1f)}, Units.UNK);
      fail("Should have thrown exception due to 2-D function");
    } catch (Exception e) {} //exception is expected
  }
View Full Code Here

  /*
   * Test method for 'ca.nengo.model.impl.FunctionInput.getValues()'
   */
  public void testGetValues() throws StructuralException, SimulationException {
    FunctionInput input = new FunctionInput("test", new Function[]{new ConstantFunction(1, 1f), new ConstantFunction(1, 2f)}, Units.UNK);
    Origin origin = input.getOrigin(FunctionInput.ORIGIN_NAME);
    assertEquals(2, origin.getValues().getDimension());
    assertEquals(2, ((RealOutput) origin.getValues()).getValues().length);
   
    input.run(0f, 1f);
    assertEquals(2, origin.getValues().getDimension());
    assertEquals(2, ((RealOutput) origin.getValues()).getValues().length);
    float value = ((RealOutput) origin.getValues()).getValues()[0];
    assertTrue(value > .9f);
    value = ((RealOutput) origin.getValues()).getValues()[1];
View Full Code Here

  /*
   * Test method for 'ca.nengo.model.impl.FunctionInput.getMode()'
   */
  public void testGetMode() throws StructuralException {
    FunctionInput input = new FunctionInput("test", new Function[]{new ConstantFunction(1, 1f)}, Units.UNK);
    assertEquals(SimulationMode.DEFAULT, input.getMode());
  }
View Full Code Here

  /*
   * Test method for 'ca.nengo.model.impl.FunctionInput.getHistory(String)'
   */
  public void testGetHistory() throws StructuralException, SimulationException {
    FunctionInput input = new FunctionInput("test", new Function[]{new ConstantFunction(1, 1f), new ConstantFunction(1, 2f)}, Units.UNK);
    assertEquals(1, input.listStates().size());
    assertTrue(input.listStates().get(FunctionInput.STATE_NAME) != null);
   
    assertEquals(1, input.getHistory(FunctionInput.STATE_NAME).getValues().length);
    assertTrue(input.getHistory(FunctionInput.STATE_NAME).getValues()[0][0] > .5f);
   
    input.run(0f, 1f);
   
    assertEquals(1, input.getHistory(FunctionInput.STATE_NAME).getValues().length);
    assertTrue(input.getHistory(FunctionInput.STATE_NAME).getValues()[0][0] > .5f);
  }
View Full Code Here

   
    Network network = new NetworkImpl();
   
    Function f = new ConstantFunction(1, 1f);
//    Function f = new SineFunction();
    FunctionInput input = new FunctionInput("input", new Function[]{f}, Units.UNK);
    network.addNode(input);
   
    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
   
    NEFEnsemble integrator = ef.make("integrator", 500, 1, "integrator1", true)
    network.addNode(integrator);
    integrator.collectSpikes(true);

    Plotter.plot(integrator);
    Plotter.plot(integrator, NEFEnsemble.X);
   
    float tau = .05f;
   
    Termination interm = integrator.addDecodedTermination("input", new float[][]{new float[]{tau}}, tau, false);
//    Termination interm = integrator.addDecodedTermination("input", new float[][]{new float[]{1f}}, tau);
    network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), interm);
   
    Termination fbterm = integrator.addDecodedTermination("feedback", new float[][]{new float[]{1f}}, tau, false);
    network.addProjection(integrator.getOrigin(NEFEnsemble.X), fbterm);
   
    //System.out.println("Network creation: " + (System.currentTimeMillis() - start));
View Full Code Here

      Function[] funcs = new Function[2];
      for(int i=0; i<funcs.length; ++i) {
        funcs[i] = new PostfixFunction("sin(x0)^"+(i+1), 1);
      }
      String name = "functions of time";
      FunctionInput fi = new FunctionInput(name, funcs, Units.uAcm2);
      network.addNode(fi);
     
      //we can add a probe to it and run the simulator ...
      Probe p = network.getSimulator().addProbe(name, FunctionInput.STATE_NAME, true);     
      network.run(0, 10);
View Full Code Here

TOP

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

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.