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

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


        PointVectorValuePair optimum =
            optimizer.optimize(new MaxEval(100),
                               problem.getModelFunction(),
                               problem.getModelFunctionJacobian(),
                               problem.getTarget(),
                               new Weight(new double[] { 1, 1 }),
                               new InitialGuess(new double[] { 0, 0 }));
        Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
        Assert.assertEquals(-1, optimum.getPoint()[0], 1e-10);
        Assert.assertEquals(1, optimum.getPoint()[1], 1e-10);

        optimizer.optimize(new MaxEval(100),
                           problem.getModelFunction(),
                           problem.getModelFunctionJacobian(),
                           problem.getTarget(),
                           new Weight(new double[] { 1 }),
                           new InitialGuess(new double[] { 0, 0 }));
    }
View Full Code Here


        PointVectorValuePair optimum
            = optimizer.optimize(new MaxEval(100),
                                 problem.getModelFunction(),
                                 problem.getModelFunctionJacobian(),
                                 problem.getTarget(),
                                 new Weight(new double[] { 1, 1 }),
                                 new InitialGuess(new double[] { 0, 0 }));
        Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
        Assert.assertEquals(-1, optimum.getPoint()[0], 1e-10);
        Assert.assertEquals(1, optimum.getPoint()[1], 1e-10);

        optimizer.optimize(new MaxEval(100),
                           problem.getModelFunction(),
                           problem.getModelFunctionJacobian(),
                           new Target(new double[] { 1 }),
                           new Weight(new double[] { 1 }),
                           new InitialGuess(new double[] { 0, 0 }));
    }
View Full Code Here

        PointVectorValuePair optimum
            = optimizer.optimize(new MaxEval(100),
                                 circle.getModelFunction(),
                                 circle.getModelFunctionJacobian(),
                                 new Target(new double[] { 0, 0, 0, 0, 0 }),
                                 new Weight(new double[] { 1, 1, 1, 1, 1 }),
                                 new InitialGuess(new double[] { 98.680, 47.345 }));
        Assert.assertTrue(optimizer.getEvaluations() < 10);
        double rms = optimizer.getRMS();
        Assert.assertEquals(1.768262623567235,  FastMath.sqrt(circle.getN()) * rms,  1e-10);
        Vector2D center = new Vector2D(optimum.getPointRef()[0], optimum.getPointRef()[1]);
        Assert.assertEquals(69.96016176931406, circle.getRadius(center), 1e-6);
        Assert.assertEquals(96.07590211815305, center.getX(),            1e-6);
        Assert.assertEquals(48.13516790438953, center.getY(),            1e-6);
        double[][] cov = optimizer.computeCovariances(optimum.getPoint(), 1e-14);
        Assert.assertEquals(1.839, cov[0][0], 0.001);
        Assert.assertEquals(0.731, cov[0][1], 0.001);
        Assert.assertEquals(cov[0][1], cov[1][0], 1e-14);
        Assert.assertEquals(0.786, cov[1][1], 0.001);

        // add perfect measurements and check errors are reduced
        double  r = circle.getRadius(center);
        for (double d= 0; d < 2 * FastMath.PI; d += 0.01) {
            circle.addPoint(center.getX() + r * FastMath.cos(d), center.getY() + r * FastMath.sin(d));
        }
        double[] target = new double[circle.getN()];
        Arrays.fill(target, 0);
        double[] weights = new double[circle.getN()];
        Arrays.fill(weights, 2);
        optimum = optimizer.optimize(new MaxEval(100),
                                     circle.getModelFunction(),
                                     circle.getModelFunctionJacobian(),
                                     new Target(target),
                                     new Weight(weights),
                                     new InitialGuess(new double[] { 98.680, 47.345 }));
        cov = optimizer.computeCovariances(optimum.getPoint(), 1e-14);
        Assert.assertEquals(0.0016, cov[0][0], 0.001);
        Assert.assertEquals(3.2e-7, cov[0][1], 1e-9);
        Assert.assertEquals(cov[0][1], cov[1][0], 1e-14);
View Full Code Here

        PointVectorValuePair optimum
            = optimizer.optimize(new MaxEval(100),
                                 circle.getModelFunction(),
                                 circle.getModelFunctionJacobian(),
                                 new Target(target),
                                 new Weight(weights),
                                 new InitialGuess(new double[] { -12, -12 }));
        Vector2D center = new Vector2D(optimum.getPointRef()[0], optimum.getPointRef()[1]);
        Assert.assertTrue(optimizer.getEvaluations() < 25);
        Assert.assertEquals( 0.043, optimizer.getRMS(), 1e-3);
        Assert.assertEquals( 0.292235,  circle.getRadius(center), 1e-6);
View Full Code Here

        PointVectorValuePair optimum =
            optimizer.optimize(new MaxEval(100),
                               circle.getModelFunction(),
                               circle.getModelFunctionJacobian(),
                               new Target(target),
                               new Weight(weights),
                               new InitialGuess(new double[] { 0, 0 }));
        Assert.assertEquals(-0.1517383071957963, optimum.getPointRef()[0], 1e-6);
        Assert.assertEquals(0.2074999736353867,  optimum.getPointRef()[1], 1e-6);
        Assert.assertEquals(0.04268731682389561, optimizer.getRMS(),       1e-8);
    }
View Full Code Here

        final PointVectorValuePair optimum
            = optimizer.optimize(new MaxEval(100),
                                 problem.getModelFunction(),
                                 problem.getModelFunctionJacobian(),
                                 new Target(data[1]),
                                 new Weight(w),
                                 new InitialGuess(initial));

        final double[] actual = optimum.getPoint();
        for (int i = 0; i < actual.length; i++) {
            double expected = dataset.getParameter(i);
View Full Code Here

    @Test(expected=MathUnsupportedOperationException.class)
    public void testConstraintsUnsupported() {
        createOptimizer().optimize(new MaxEval(100),
                                   new Target(new double[] { 2 }),
                                   new Weight(new double[] { 1 }),
                                   new InitialGuess(new double[] { 1, 2 }),
                                   new SimpleBounds(new double[] { -10, 0 },
                                                    new double[] { 20, 30 }));
    }
View Full Code Here

        optimizer.optimize(new MaxEval(100),
                           circle.getModelFunction(),
                           circle.getModelFunctionJacobian(),
                           new Target(new double[] { 0, 0, 0, 0, 0 }),
                           new Weight(new double[] { 1, 1, 1, 1, 1 }),
                           new InitialGuess(new double[] { 98.680, 47.345 }));
    }
View Full Code Here

            PointVectorValuePair optimum
                = optimizer.optimize(new MaxEval(400 * (function.getN() + 1)),
                                     function.getModelFunction(),
                                     function.getModelFunctionJacobian(),
                                     new Target(function.getTarget()),
                                     new Weight(function.getWeight()),
                                     new InitialGuess(function.getStartPoint()));
            Assert.assertFalse(exceptionExpected);
            function.checkTheoreticalMinCost(optimizer.getRMS());
            function.checkTheoreticalMinParams(optimum);
        } catch (TooManyEvaluationsException e) {
View Full Code Here

    @Test(expected=MathUnsupportedOperationException.class)
    public void testConstraintsUnsupported() {
        createOptimizer().optimize(new MaxEval(100),
                                   new Target(new double[] { 2 }),
                                   new Weight(new double[] { 1 }),
                                   new InitialGuess(new double[] { 1, 2 }),
                                   new SimpleBounds(new double[] { -10, 0 },
                                                    new double[] { 20, 30 }));
    }
View Full Code Here

TOP

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

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.