Package org.apache.commons.math3.optim.nonlinear.vector

Examples of org.apache.commons.math3.optim.nonlinear.vector.ModelFunction


    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

        // Multi-start loop.
        for (int i = 0; i < starts; i++) {
            // CHECKSTYLE: stop IllegalCatch
            try {
                // Decrease number of allowed evaluations.
                optimData[maxEvalIndex] = new MaxEval(maxEval - totalEvaluations);
                // New start value.
                final double s = (i == 0) ?
                    startValue :
                    min + generator.nextDouble() * (max - min);
                optimData[searchIntervalIndex] = new SearchInterval(min, max, s);
View Full Code Here

        /**
         * @return the model function values.
         */
        public ModelFunction getModelFunction() {
            return new ModelFunction(new MultivariateVectorFunction() {
                    /** {@inheritDoc} */
                    public double[] value(double[] point) {
                        // compute the residuals
                        final double[] values = new double[observations.size()];
                        int i = 0;
View Full Code Here

    public void testGetIterations() {
        AbstractLeastSquaresOptimizer optim = createOptimizer();
        optim.optimize(new MaxEval(100), new Target(new double[] { 1 }),
                       new Weight(new double[] { 1 }),
                       new InitialGuess(new double[] { 3 }),
                       new ModelFunction(new MultivariateVectorFunction() {
                               public double[] value(double[] point) {
                                   return new double[] {
                                       FastMath.pow(point[0], 4)
                                   };
                               }
View Full Code Here

        public Target getTarget() {
            return new Target(target);
        }

        public ModelFunction getModelFunction() {
            return new ModelFunction(new MultivariateVectorFunction() {
                    public double[] value(double[] params) {
                        return factors.operate(params);
                    }
                });
        }
View Full Code Here

        return w;
    }

    public ModelFunction getModelFunction() {
        return new ModelFunction(new MultivariateVectorFunction() {
                public double[] value(double[] params) {
                    final Model line = new Model(params[0], params[1]);

                    final double[] model = new double[points.size()];
                    for (int i = 0; i < points.size(); i++) {
View Full Code Here

        this.problem = new LeastSquaresProblem();
    }

    class LeastSquaresProblem {
        public ModelFunction getModelFunction() {
            return new ModelFunction(new MultivariateVectorFunction() {
                    public double[] value(final double[] a) {
                        final int n = getNumObservations();
                        final double[] yhat = new double[n];
                        for (int i = 0; i < n; i++) {
                            yhat[i] = getModelValue(getX(i), a);
View Full Code Here

                }
            }
        }

        public ModelFunction getModelFunction() {
            return new ModelFunction(new MultivariateVectorFunction() {
                    public double[] value(double[] point) {
                        return computeValue(point);
                    }
                });
        }
View Full Code Here

        return w;
    }

    public ModelFunction getModelFunction() {
        return new ModelFunction(new MultivariateVectorFunction() {
                public double[] value(double[] params) {
                    final double cx = params[0];
                    final double cy = params[1];
                    final double r = params[2];
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.optim.nonlinear.vector.ModelFunction

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.