Package org.apache.commons.math.optimization

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


  public void testRosenbrock()
    throws FunctionEvaluationException, ConvergenceException {

    Rosenbrock rosenbrock = new Rosenbrock();
    NelderMead optimizer = new NelderMead();
    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 =
View Full Code Here


  public void testPowell()
    throws FunctionEvaluationException, ConvergenceException {

    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);
View Full Code Here

          public double[] value(double[] variables) {
              return factors.operate(variables);
          }
      }, 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);
View Full Code Here

          public double[] value(double[] variables) {
              return factors.operate(variables);
          }
      }, 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);
View Full Code Here

          }
      }, new double[] { 2.0, -3.0 }, new Array2DRowRealMatrix(new double [][] {
          { 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);
View Full Code Here

  @Test(expected = MaxIterationsExceededException.class)
  public void testMaxIterations() throws MathException {
      try {
          Powell powell = new Powell();
          NelderMead optimizer = new NelderMead();
          optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-3));
          optimizer.setMaxIterations(20);
          optimizer.optimize(powell, GoalType.MINIMIZE, new double[] { 3.0, -1.0, 0.0, 1.0 });
      } catch (OptimizationException oe) {
          if (oe.getCause() instanceof ConvergenceException) {
              throw (ConvergenceException) oe.getCause();
View Full Code Here

              return ((x == 0) || (y == 0)) ? 0 : (Math.atan(x) * Math.atan(x + 2) * Math.atan(y) * Math.atan(y) / (x * y));
          }
      };

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

      // minimization
View Full Code Here

        }
      };

    count = 0;
    MultiDirectional optimizer = new MultiDirectional();
    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 =
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 });
    assertEquals(count, optimizer.getEvaluations());
    assertTrue(optimizer.getEvaluations() > 800);
View Full Code Here

        LinearProblem problem =
            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

TOP

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

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.