Package org.apache.commons.math3.ode.events

Examples of org.apache.commons.math3.ode.events.EventHandler


        double[] qtf     = new double[nR];
        double[] work1   = new double[nC];
        double[] work2   = new double[nC];
        double[] work3   = new double[nC];

        final RealMatrix weightMatrixSqrt = getWeightSquareRoot();

        // Evaluate the function at the starting point and calculate its norm.
        double[] currentObjective = computeObjectiveValue(currentPoint);
        double[] currentResiduals = computeResiduals(currentObjective);
        PointVectorValuePair current = new PointVectorValuePair(currentPoint, currentObjective);
        double currentCost = computeCost(currentResiduals);

        // Outer loop.
        lmPar = 0;
        boolean firstIteration = true;
        final ConvergenceChecker<PointVectorValuePair> checker = getConvergenceChecker();
        while (true) {
            incrementIterationCount();

            final PointVectorValuePair previous = current;

            // QR decomposition of the jacobian matrix
            qrDecomposition(computeWeightedJacobian(currentPoint));

            weightedResidual = weightMatrixSqrt.operate(currentResiduals);
            for (int i = 0; i < nR; i++) {
                qtf[i] = weightedResidual[i];
            }

            // compute Qt.res
View Full Code Here


    for (SiteWithPolynomial site : sites) {
     
      List<SiteWithPolynomial> nearestSites =
          nearestSiteMap.get(site);
     
      RealVector vector = new ArrayRealVector(SITES_FOR_APPROX);
      RealMatrix matrix = new Array2DRowRealMatrix(
          SITES_FOR_APPROX, DefaultPolynomial.NUM_COEFFS);
     
      for (int row = 0; row < SITES_FOR_APPROX; row++) {
        SiteWithPolynomial nearSite = nearestSites.get(row);
        DefaultPolynomial.populateMatrix(matrix, row, nearSite.pos.x, nearSite.pos.z);
        vector.setEntry(row, nearSite.pos.y);
      }
     
      QRDecomposition qr = new QRDecomposition(matrix);
      RealVector solution = qr.getSolver().solve(vector);
       
      double[] coeffs = solution.toArray();
     
      for (double coeff : coeffs) {
        if (coeff > 10e3) {
          continue calculatePolynomials;
        }
View Full Code Here

                return Double.compare(weightedResidual(o1),
                                      weightedResidual(o2));
            }

            private double weightedResidual(final PointVectorValuePair pv) {
                final RealVector v = new ArrayRealVector(pv.getValueRef(), false);
                final RealVector r = target.subtract(v);
                return r.dotProduct(weight.operate(r));
            }
        };
    }
View Full Code Here

            // predict a first estimate of the state at step end
            final double stepEnd = stepStart + stepSize;
            interpolator.shift();
            interpolator.setInterpolatedTime(stepEnd);
            final ExpandableStatefulODE expandable = getExpandable();
            final EquationsMapper primary = expandable.getPrimaryMapper();
            primary.insertEquationData(interpolator.getInterpolatedState(), y);
            int index = 0;
            for (final EquationsMapper secondary : expandable.getSecondaryMappers()) {
                secondary.insertEquationData(interpolator.getInterpolatedSecondaryState(index), y);
                ++index;
            }
View Full Code Here

            // predict a first estimate of the state at step end
            final double stepEnd = stepStart + stepSize;
            interpolator.shift();
            interpolator.setInterpolatedTime(stepEnd);
            final ExpandableStatefulODE expandable = getExpandable();
            final EquationsMapper primary = expandable.getPrimaryMapper();
            primary.insertEquationData(interpolator.getInterpolatedState(), y);
            int index = 0;
            for (final EquationsMapper secondary : expandable.getSecondaryMappers()) {
                secondary.insertEquationData(interpolator.getInterpolatedSecondaryState(index), y);
                ++index;
            }

            // evaluate the derivative
View Full Code Here

      Assert.assertEquals(tEvent, finalT, 5.0e-6);
      for (int i = 0; i < y.length; ++i) {
          Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
      }

      integrator.addEventHandler(new EventHandler() {

          public void init(double t0, double[] y0, double t) {
          }

          public void resetState(double t, double[] y) {
View Full Code Here

        Assert.assertEquals(tEvent, finalT, 1.0e-15);
        for (int i = 0; i < y.length; ++i) {
            Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-15);
        }

        integrator.addEventHandler(new EventHandler() {

            public void init(double t0, double[] y0, double t) {
            }

            public void resetState(double t, double[] y) {
View Full Code Here

      for (int i = 0; i < y.length; ++i) {
          Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
      }

      integrator.setInitialStepSize(60.0);
      integrator.addEventHandler(new EventHandler() {

          public void init(double t0, double[] y0, double t) {
          }

          public void resetState(double t, double[] y) {
View Full Code Here

          new HighamHall54Integrator(minStep, maxStep,
                                     scalAbsoluteTolerance, scalRelativeTolerance);
      TestProblemHandler handler = new TestProblemHandler(pb, integ);
      integ.addStepHandler(handler);

      integ.addEventHandler(new EventHandler() {
        public void init(double t0, double[] y0, double t) {
        }
        public Action eventOccurred(double t, double[] y, boolean increasing) {
          return Action.CONTINUE;
        }
View Full Code Here

        new HighamHall54Integrator(minStep, maxStep,
                                   scalAbsoluteTolerance, scalRelativeTolerance);
    TestProblemHandler handler = new TestProblemHandler(pb, integ);
    integ.addStepHandler(handler);

    integ.addEventHandler(new EventHandler() {
      public void init(double t0, double[] y0, double t) {
      }
      public Action eventOccurred(double t, double[] y, boolean increasing) {
        return Action.CONTINUE;
      }
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.ode.events.EventHandler

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.