Package org.apache.commons.math.optimization

Examples of org.apache.commons.math.optimization.RealPointValuePair


                        double pointTol)
        throws MathException {
        final PowellOptimizer optim = new PowellOptimizer(xTol);
        optim.setConvergenceChecker(new SimpleScalarValueChecker(fTol, -1));

        final RealPointValuePair result = optim.optimize(func, goal, init);
        final double[] found = result.getPoint();

        for (int i = 0, dim = optimum.length; i < dim; i++) {
            Assert.assertEquals(optimum[i], found[i], pointTol);
        }
    }
View Full Code Here


        NonLinearConjugateGradientOptimizer optimizer =
            new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
        optimizer.setMaxIterations(100);
        optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
        RealPointValuePair optimum =
            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 7, 6, 5, 4 });
        assertEquals(0, optimum.getValue(), 1.0e-10);

    }
View Full Code Here

        }, new double[] { 3.0, 12.0, -1.0, 7.0, 1.0 });
        NonLinearConjugateGradientOptimizer optimizer =
            new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
        optimizer.setMaxIterations(100);
        optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
        RealPointValuePair optimum =
            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 2, 2, 2, 2, 2, 2 });
        assertEquals(0, optimum.getValue(), 1.0e-10);
    }
View Full Code Here

        NonLinearConjugateGradientOptimizer optimizer =
            new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
        optimizer.setMaxIterations(100);
        optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
        RealPointValuePair optimum =
            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 1, 1 });
        assertEquals(2.0, optimum.getPoint()[0], 1.0e-8);
        assertEquals(1.0, optimum.getPoint()[1], 1.0e-8);

    }
View Full Code Here

        NonLinearConjugateGradientOptimizer optimizer =
            new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
        optimizer.setMaxIterations(100);
        optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
        RealPointValuePair optimum =
            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 1, 1 });
        assertTrue(optimum.getValue() > 0.1);

    }
View Full Code Here

        optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-30, 1.0e-30));
        BrentSolver solver = new BrentSolver();
        solver.setAbsoluteAccuracy(1.0e-13);
        solver.setRelativeAccuracy(1.0e-15);
        optimizer.setLineSearchSolver(solver);
        RealPointValuePair optimum =
            optimizer.optimize(circle, GoalType.MINIMIZE, new double[] { 98.680, 47.345 });
        Point2D.Double center = new Point2D.Double(optimum.getPointRef()[0], optimum.getPointRef()[1]);
        assertEquals(69.960161753, circle.getRadius(center), 1.0e-8);
        assertEquals(96.075902096, center.x, 1.0e-8);
        assertEquals(48.135167894, center.y, 1.0e-8);
    }
View Full Code Here

      NelderMead optimizer = new NelderMead();
      optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-10, 1.0e-30));
      optimizer.setMaxIterations(100);
      optimizer.setStartConfiguration(new double[] { 0.2, 0.2 });
      RealPointValuePair optimum;

      // minimization
      optimum = optimizer.optimize(fourExtrema, GoalType.MINIMIZE, new double[] { -3.0, 0 });
      assertEquals(xM,        optimum.getPoint()[0], 2.0e-7);
      assertEquals(yP,        optimum.getPoint()[1], 2.0e-5);
      assertEquals(valueXmYp, optimum.getValue(),    6.0e-12);
      assertTrue(optimizer.getEvaluations() > 60);
      assertTrue(optimizer.getEvaluations() < 90);

      optimum = optimizer.optimize(fourExtrema, GoalType.MINIMIZE, new double[] { +1, 0 });
      assertEquals(xP,        optimum.getPoint()[0], 5.0e-6);
      assertEquals(yM,        optimum.getPoint()[1], 6.0e-6);
      assertEquals(valueXpYm, optimum.getValue(),    1.0e-11);
      assertTrue(optimizer.getEvaluations() > 60);
      assertTrue(optimizer.getEvaluations() < 90);

      // maximization
      optimum = optimizer.optimize(fourExtrema, GoalType.MAXIMIZE, new double[] { -3.0, 0.0 });
      assertEquals(xM,        optimum.getPoint()[0], 1.0e-5);
      assertEquals(yM,        optimum.getPoint()[1], 3.0e-6);
      assertEquals(valueXmYm, optimum.getValue(),    3.0e-12);
      assertTrue(optimizer.getEvaluations() > 60);
      assertTrue(optimizer.getEvaluations() < 90);

      optimum = optimizer.optimize(fourExtrema, GoalType.MAXIMIZE, new double[] { +1, 0 });
      assertEquals(xP,        optimum.getPoint()[0], 4.0e-6);
      assertEquals(yP,        optimum.getPoint()[1], 5.0e-6);
      assertEquals(valueXpYp, optimum.getValue(),    7.0e-12);
      assertTrue(optimizer.getEvaluations() > 60);
      assertTrue(optimizer.getEvaluations() < 90);

  }
View Full Code Here

    optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1, 1.0e-3));
    optimizer.setMaxIterations(100);
    optimizer.setStartConfiguration(new double[][] {
            { -1.21.0 }, { 0.9, 1.2 } , 3.5, -2.3 }
    });
    RealPointValuePair optimum =
        optimizer.optimize(rosenbrock, GoalType.MINIMIZE, new double[] { -1.2, 1.0 });

    assertEquals(rosenbrock.getCount(), optimizer.getEvaluations());
    assertTrue(optimizer.getEvaluations() > 40);
    assertTrue(optimizer.getEvaluations() < 50);
    assertTrue(optimum.getValue() < 8.0e-4);

  }
View Full Code Here

    Powell powell = new Powell();
    NelderMead optimizer = new NelderMead();
    optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-3));
    optimizer.setMaxIterations(200);
    RealPointValuePair optimum =
      optimizer.optimize(powell, GoalType.MINIMIZE, new double[] { 3.0, -1.0, 0.0, 1.0 });
    assertEquals(powell.getCount(), optimizer.getEvaluations());
    assertTrue(optimizer.getEvaluations() > 110);
    assertTrue(optimizer.getEvaluations() < 130);
    assertTrue(optimum.getValue() < 2.0e-3);

  }
View Full Code Here

          }
      }, new double[] { 2.0, -3.0 });
      NelderMead optimizer = new NelderMead();
      optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6));
      optimizer.setMaxIterations(200);
      RealPointValuePair optimum =
          optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 });
      assertEquals( 2.0, optimum.getPointRef()[0], 3.0e-5);
      assertEquals(-3.0, optimum.getPointRef()[1], 4.0e-4);
      assertTrue(optimizer.getEvaluations() > 60);
      assertTrue(optimizer.getEvaluations() < 80);
      assertTrue(optimum.getValue() < 1.0e-6);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.optimization.RealPointValuePair

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.