Package org.apache.commons.math.optimization

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


          }
      }, new double[] { 2.0, -3.0 }, new double[] { 10.0, 0.1 });
      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], 5.0e-5);
      assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4);
      assertTrue(optimizer.getEvaluations() > 60);
      assertTrue(optimizer.getEvaluations() < 80);
      assertTrue(optimum.getValue() < 1.0e-6);
  }
View Full Code Here


          { 1.0, 1.2 }, { 1.2, 2.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], 2.0e-3);
      assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4);
      assertTrue(optimizer.getEvaluations() > 60);
      assertTrue(optimizer.getEvaluations() < 80);
      assertTrue(optimum.getValue() < 1.0e-6);
  }
View Full Code Here

            new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
        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[] { 0 });
        assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
        assertEquals(0.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[] { 0, 0 });
        assertEquals(7.0, optimum.getPoint()[0], 1.0e-10);
        assertEquals(3.0, optimum.getPoint()[1], 1.0e-10);
        assertEquals(0.0, optimum.getValue(), 1.0e-10);

    }
View Full Code Here

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

      // minimization
      optimum = optimizer.optimize(fourExtrema, GoalType.MINIMIZE, new double[] { -3.0, 0 });
      Assert.assertEquals(xM,        optimum.getPoint()[0], 4.0e-6);
      Assert.assertEquals(yP,        optimum.getPoint()[1], 3.0e-6);
      Assert.assertEquals(valueXmYp, optimum.getValue(),    8.0e-13);
      Assert.assertTrue(optimizer.getEvaluations() > 120);
      Assert.assertTrue(optimizer.getEvaluations() < 150);

      optimum = optimizer.optimize(fourExtrema, GoalType.MINIMIZE, new double[] { +1, 0 });
      Assert.assertEquals(xP,        optimum.getPoint()[0], 2.0e-8);
      Assert.assertEquals(yM,        optimum.getPoint()[1], 3.0e-6);
      Assert.assertEquals(valueXpYm, optimum.getValue(),    2.0e-12);
      Assert.assertTrue(optimizer.getEvaluations() > 120);
      Assert.assertTrue(optimizer.getEvaluations() < 150);

      // maximization
      optimum = optimizer.optimize(fourExtrema, GoalType.MAXIMIZE, new double[] { -3.0, 0.0 });
      Assert.assertEquals(xM,        optimum.getPoint()[0], 7.0e-7);
      Assert.assertEquals(yM,        optimum.getPoint()[1], 3.0e-7);
      Assert.assertEquals(valueXmYm, optimum.getValue(),    2.0e-14);
      Assert.assertTrue(optimizer.getEvaluations() > 120);
      Assert.assertTrue(optimizer.getEvaluations() < 150);

      optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-15, 1.0e-30));
      optimum = optimizer.optimize(fourExtrema, GoalType.MAXIMIZE, new double[] { +1, 0 });
      Assert.assertEquals(xP,        optimum.getPoint()[0], 2.0e-8);
      Assert.assertEquals(yP,        optimum.getPoint()[1], 3.0e-6);
      Assert.assertEquals(valueXpYp, optimum.getValue(),    2.0e-12);
      Assert.assertTrue(optimizer.getEvaluations() > 180);
      Assert.assertTrue(optimizer.getEvaluations() < 220);

  }
View Full Code Here

        }, new double[] { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5 });
        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[] { 0, 0, 0, 0, 0, 0 });
        for (int i = 0; i < problem.target.length; ++i) {
            assertEquals(0.55 * i, optimum.getPoint()[i], 1.0e-10);
        }
    }
View Full Code Here

        }, new double[] { 1, 1, 1});
        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[] { 0, 0, 0 });
        assertEquals(1.0, optimum.getPoint()[0], 1.0e-10);
        assertEquals(2.0, optimum.getPoint()[1], 1.0e-10);
        assertEquals(3.0, optimum.getPoint()[2], 1.0e-10);

    }
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 });

    Assert.assertEquals(count, optimizer.getEvaluations());
    Assert.assertTrue(optimizer.getEvaluations() > 50);
    Assert.assertTrue(optimizer.getEvaluations() < 100);
    Assert.assertTrue(optimum.getValue() > 1.0e-2);

  }
View Full Code Here

                return d;
            }
        });
        optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-13, 1.0e-13));

        RealPointValuePair optimum =
            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0, 0, 0, 0, 0, 0 });
        assertEquals( 3.0, optimum.getPoint()[0], 1.0e-10);
        assertEquals( 4.0, optimum.getPoint()[1], 1.0e-10);
        assertEquals(-1.0, optimum.getPoint()[2], 1.0e-10);
        assertEquals(-2.0, optimum.getPoint()[3], 1.0e-10);
        assertEquals( 1.0 + epsilon, optimum.getPoint()[4], 1.0e-10);
        assertEquals( 1.0 - epsilon, optimum.getPoint()[5], 1.0e-10);

    }
View Full Code Here

    count = 0;
    MultiDirectional optimizer = new MultiDirectional();
    optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-3));
    optimizer.setMaxIterations(1000);
    RealPointValuePair optimum =
      optimizer.optimize(powell, GoalType.MINIMIZE, new double[] { 3.0, -1.0, 0.0, 1.0 });
    Assert.assertEquals(count, optimizer.getEvaluations());
    Assert.assertTrue(optimizer.getEvaluations() > 800);
    Assert.assertTrue(optimizer.getEvaluations() < 900);
    Assert.assertTrue(optimum.getValue() > 1.0e-2);

  }
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.