Package org.apache.commons.math3.optimization

Examples of org.apache.commons.math3.optimization.PointVectorValuePair$DataTransferObject


                10, 0 },
                { -11, 0 },
                0, -1, 1 }
        }, new double[] { 1, 1, 1});
        AbstractLeastSquaresOptimizer optimizer = createOptimizer();
        PointVectorValuePair optimum =
            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new double[] { 0, 0, 0 });
        Assert.assertEquals(0, optimizer.getRMS(), 1.0e-10);
        Assert.assertEquals(1.0, optimum.getPoint()[0], 1.0e-10);
        Assert.assertEquals(2.0, optimum.getPoint()[1], 1.0e-10);
        Assert.assertEquals(3.0, optimum.getPoint()[2], 1.0e-10);
    }
View Full Code Here


                00,   00, epsilon, 1 },
                00,   00,       1, 1 }
        }, new double[] { 2, -9, 2, 2, 1 + epsilon * epsilon, 2});

        AbstractLeastSquaresOptimizer optimizer = createOptimizer();
        PointVectorValuePair optimum =
            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1, 1 },
                               new double[] { 0, 0, 0, 0, 0, 0 });
        Assert.assertEquals(0, optimizer.getRMS(), 1.0e-10);
        Assert.assertEquals( 3.0, optimum.getPoint()[0], 1.0e-10);
        Assert.assertEquals( 4.0, optimum.getPoint()[1], 1.0e-10);
        Assert.assertEquals(-1.0, optimum.getPoint()[2], 1.0e-10);
        Assert.assertEquals(-2.0, optimum.getPoint()[3], 1.0e-10);
        Assert.assertEquals( 1.0 + epsilon, optimum.getPoint()[4], 1.0e-10);
        Assert.assertEquals( 1.0 - epsilon, optimum.getPoint()[5], 1.0e-10);
    }
View Full Code Here

            weights[i] = point.getWeight();
            ++i;
        }

        // perform the fit
        final PointVectorValuePair optimum;
        if (optimizer == null) {
            // to be removed in 4.0
            optimum = oldOptimizer.optimize(maxEval, new OldTheoreticalValuesFunction(f),
                                            target, weights, initialGuess);
        } else {
            optimum = optimizer.optimize(maxEval, new TheoreticalValuesFunction(f),
                                         target, weights, initialGuess);
        }

        // extract the coefficients
        return optimum.getPointRef();
    }
View Full Code Here

            @Override
            protected PointVectorValuePair doOptimize() {
                final double[] params = getStartPoint();
                final double[] res = computeResiduals(computeObjectiveValue(params));
                setCost(computeCost(res));
                return new PointVectorValuePair(params, null);
            }
        };
    }
View Full Code Here

        final double[] y = dataset.getData()[1];
        final double[] w = new double[y.length];
        Arrays.fill(w, 1.0);

        final int dof = y.length - a.length;
        final PointVectorValuePair optimum = optimizer.optimize(1, dataset.getLeastSquaresProblem(), y, w, a);
        final double[] sig = optimizer.computeSigma(optimum.getPoint(), 1e-14);
        final double[] expected = dataset.getParametersStandardDeviations();
        for (int i = 0; i < sig.length; i++) {
            final double actual = FastMath.sqrt(optimizer.getChiSquare() / dof) * sig[i];
            Assert.assertEquals(dataset.getName() + ", parameter #" + i,
                                expected[i], actual, 1e-7 * expected[i]);
 
View Full Code Here

            // Direct solution (using simple regression).
            final double[] regress = problem.solve();

            // Estimation of the standard deviation (diagonal elements of the
            // covariance matrix).
            final PointVectorValuePair optimum = optim.optimize(Integer.MAX_VALUE,
                           problem, problem.target(), problem.weight(), init);
            final double[] sigma = optim.computeSigma(optimum.getPoint(), 1e-14);

            // Accumulate statistics.
            for (int i = 0; i < numParams; i++) {
                paramsFoundByDirectSolution[i].addValue(regress[i]);
                sigmaEstimate[i].addValue(sigma[i]);
View Full Code Here

          = new LevenbergMarquardtOptimizer(FastMath.sqrt(2.22044604926e-16),
                                            FastMath.sqrt(2.22044604926e-16),
                                            2.22044604926e-16);
//      Assert.assertTrue(function.checkTheoreticalStartCost(optimizer.getRMS()));
      try {
          PointVectorValuePair optimum =
              optimizer.optimize(400 * (function.getN() + 1), function,
                                 function.getTarget(), function.getWeight(),
                                 function.getStartPoint());
          Assert.assertFalse(exceptionExpected);
          function.checkTheoreticalMinCost(optimizer.getRMS());
View Full Code Here

            new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });

        GaussNewtonOptimizer optimizer
            = new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));

        PointVectorValuePair optimum =
            optimizer.optimize(100, problem, problem.target, new double[] { 1 }, new double[] { 0 });
        Assert.assertEquals(0, optimizer.getRMS(), 1.0e-10);
        Assert.assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
        Assert.assertEquals(3.0, optimum.getValue()[0], 1.0e-10);
    }
View Full Code Here

                              new double[] { 4.0, 6.0, 1.0 });

        GaussNewtonOptimizer optimizer
            = new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));

        PointVectorValuePair optimum =
            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new double[] { 0, 0 });
        Assert.assertEquals(0, optimizer.getRMS(), 1.0e-10);
        Assert.assertEquals(7.0, optimum.getPoint()[0], 1.0e-10);
        Assert.assertEquals(3.0, optimum.getPoint()[1], 1.0e-10);
        Assert.assertEquals(4.0, optimum.getValue()[0], 1.0e-10);
        Assert.assertEquals(6.0, optimum.getValue()[1], 1.0e-10);
        Assert.assertEquals(1.0, optimum.getValue()[2], 1.0e-10);

    }
View Full Code Here

        }, new double[] { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5 });

        GaussNewtonOptimizer optimizer
            = new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));

        PointVectorValuePair optimum =
            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1, 1 },
                               new double[] { 0, 0, 0, 0, 0, 0 });
        Assert.assertEquals(0, optimizer.getRMS(), 1.0e-10);
        for (int i = 0; i < problem.target.length; ++i) {
            Assert.assertEquals(0.55 * i, optimum.getPoint()[i], 1.0e-10);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.optimization.PointVectorValuePair$DataTransferObject

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.