Package ca.nengo.dynamics

Examples of ca.nengo.dynamics.Integrator


    //Plotter.plot(CEForceVelocity, vmax, .1f, -vmax, "CE Force-Velocity");
    //Plotter.plot(SEForceLength, 0f, rl*.001f, rl*.1f, "SE Force-Length");

    Dynamics d = new Dynamics(tauEA, 5000f, CEForceLength, CEForceVelocity, SEForceLength, false);
    d.setState(new float[]{.001f, rl});
    Integrator i = new EulerIntegrator(.0001f);

//    TimeSeries input = new TimeSeriesImpl(new float[]{0f, 1f},
//        new float[][]{new float[]{1, rl, 0f}, new float[]{1, rl, 0f}},
//        new Units[]{Units.UNK, Units.M, Units.M_PER_S});
    TimeSeries input = new TimeSeriesImpl(new float[]{0f, .001f, .5f},
        new float[][]{new float[]{1, rl, 0f}, new float[]{0, rl, 0f}, new float[]{0, rl, 0f}},
        new Units[]{Units.UNK, Units.M, Units.M_PER_S});

    long startTime = System.currentTimeMillis();
    TimeSeries output = i.integrate(d, input);
    ourLogger.info("Elapsed time: " + (System.currentTimeMillis() - startTime));

    Plotter.plot(output, "Force");
  }
View Full Code Here


  public static TimeSeries filter(TimeSeries series, float tau) {
    float[] times = series.getTimes();
    float meanStepSize = (times[times.length-1] - times[1]) / times.length;
    float integrationStepSize = Math.min(meanStepSize/2f, tau/2f);
   
    Integrator integrator = new EulerIntegrator(integrationStepSize);
   
    int dim = series.getDimension();
    float[] A = new float[dim];
    float[][] B = new float[dim][];
    float[][] C = new float[dim][];
    for (int i = 0; i < dim; i++) {
      A[i] = -1f / tau;
      B[i] = new float[dim];
      B[i][i] = 1f;
      C[i] = new float[dim];
      C[i][i] = 1f / tau;
    }   
    LTISystem filter = new SimpleLTISystem(A, B, C, new float[dim], series.getUnits());
   
    return integrator.integrate(filter, series);   
  }
View Full Code Here

    double[] eigenvalues = m.eig().getRealEigenvalues();
    double[] eigRange = range(eigenvalues, minTimeConstant, maxTimeConstant);
   
    //We will give an approximation of an impulse, then let the system decay for 10 X the longest time constant, 
    //then step in increments of 1/2 X the longest time constant until there is little change in the integral
    Integrator integrator = new EulerIntegrator(-1f / (10f * (float) eigRange[0]));
   
    float[] integral = new float[system.getOutputDimension()];
   
    system.setState(new float[eigenvalues.length]);
   
    float[] impulse = new float[system.getInputDimension()];
    float pulseWidth = (float) minTimeConstant; //prevents saturation
    float pulseHeight = 1f / pulseWidth;
    impulse[input] = pulseHeight;
   
    float[] zero = new float[system.getInputDimension()];
    Units[] units = new Units[system.getInputDimension()];   
   
    TimeSeries pulse = integrator.integrate(system,
        new TimeSeriesImpl(new float[]{0f, pulseWidth}, new float[][]{impulse, impulse}, units));
    integral = integrate(pulse);   
   
    float decayTime = -10f / (float) eigRange[1];   
    TimeSeries decay = integrator.integrate(system,
        new TimeSeriesImpl(new float[]{0f, decayTime}, new float[][]{zero, zero}, units)); //time-invariant, so we can start at 0
    float[] increment = integrate(decay);
    integral = MU.sum(integral, increment);
 
    float stepTime = -.5f / (float) eigRange[1];
    do {
      decay = integrator.integrate(system,
          new TimeSeriesImpl(new float[]{0f, stepTime}, new float[][]{zero, zero}, units));
      increment = integrate(decay);
      integral = MU.sum(integral, increment);
    } while (substantialChange(integral, increment, .001f * stepTime / decayTime));

View Full Code Here

*/
public class RK45IntegratorTest extends TestCase {

  public void testIntegrate() {
    VanderPol system = new VanderPol(new float[]{.1f, .1f});
    Integrator integrator = new RK45Integrator();
    TimeSeries input = new TimeSeriesImpl(new float[]{0, 10f}, new float[][]{new float[0], new float[0]}, new Units[]{});
    TimeSeries result = integrator.integrate(system, input);
   
    assertTrue(result.getTimes().length < 60);
   
    //check results against selected hard-coded values from matlab solution ...
    InterpolatorND interpolator = new LinearInterpolatorND(result);
View Full Code Here

    //functional test ...
    public static void main(String[] args) {
        float tau = .01f;
        DynamicalSystem dynamics = new SimpleLTISystem(new float[]{-1f/tau}, new float[][]{new float[]{1f/tau}}, MU.I(1), new float[1], new Units[]{Units.UNK});
        Integrator integrator = new EulerIntegrator(.0001f);
//      Noise noise = NoiseFactory.makeRandomNoise(1000, new GaussianPDF(0, 1));
        Noise noise = NoiseFactory.makeRandomNoise(1000, new GaussianPDF(0, 1), dynamics, integrator);
//      Noise noise = NoiseFactory.makeNullNoise(1);
//      Noise noise = NoiseFactory.makeExplicitNoise(new Function[]{new FourierFunction(1, 10, 1, -1)});
View Full Code Here

TOP

Related Classes of ca.nengo.dynamics.Integrator

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.