当前位置: 首页>>代码示例>>Java>>正文


Java PointValuePair.getPointRef方法代码示例

本文整理汇总了Java中org.apache.commons.math3.optim.PointValuePair.getPointRef方法的典型用法代码示例。如果您正苦于以下问题:Java PointValuePair.getPointRef方法的具体用法?Java PointValuePair.getPointRef怎么用?Java PointValuePair.getPointRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.optim.PointValuePair的用法示例。


在下文中一共展示了PointValuePair.getPointRef方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCircleFitting

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
@Test
public void testCircleFitting() {
    CircleScalar problem = new CircleScalar();
    problem.addPoint( 30.0,  68.0);
    problem.addPoint( 50.0,  -6.0);
    problem.addPoint(110.0, -20.0);
    problem.addPoint( 35.0,  15.0);
    problem.addPoint( 45.0,  97.0);
    NonLinearConjugateGradientOptimizer optimizer
       = new NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
                                                 new SimpleValueChecker(1e-30, 1e-30),
                                                 1e-15, 1e-13, 1);
    PointValuePair optimum
        = optimizer.optimize(new MaxEval(100),
                             problem.getObjectiveFunction(),
                             problem.getObjectiveFunctionGradient(),
                             GoalType.MINIMIZE,
                             new InitialGuess(new double[] { 98.680, 47.345 }));
    Vector2D center = new Vector2D(optimum.getPointRef()[0], optimum.getPointRef()[1]);
    Assert.assertEquals(69.960161753, problem.getRadius(center), 1.0e-8);
    Assert.assertEquals(96.075902096, center.getX(), 1.0e-7);
    Assert.assertEquals(48.135167894, center.getY(), 1.0e-6);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:24,代码来源:NonLinearConjugateGradientOptimizerTest.java

示例2: evaluate

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
/**
 * Evaluate all the non-evaluated points of the simplex.
 *
 * @param evaluationFunction Evaluation function.
 * @param comparator Comparator to use to sort simplex vertices from best to worst.
 * @throws org.apache.commons.math3.exception.TooManyEvaluationsException
 * if the maximal number of evaluations is exceeded.
 */
public void evaluate(final MultivariateFunction evaluationFunction,
                     final Comparator<PointValuePair> comparator) {
    // Evaluate the objective function at all non-evaluated simplex points.
    for (int i = 0; i < simplex.length; i++) {
        final PointValuePair vertex = simplex[i];
        final double[] point = vertex.getPointRef();
        if (Double.isNaN(vertex.getValue())) {
            simplex[i] = new PointValuePair(point, evaluationFunction.value(point), false);
        }
    }

    // Sort the simplex from best to worst.
    Arrays.sort(simplex, comparator);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:23,代码来源:AbstractSimplex.java

示例3: testCircleFitting

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
@Test
public void testCircleFitting() {
    CircleScalar circle = new CircleScalar();
    circle.addPoint( 30.0,  68.0);
    circle.addPoint( 50.0,  -6.0);
    circle.addPoint(110.0, -20.0);
    circle.addPoint( 35.0,  15.0);
    circle.addPoint( 45.0,  97.0);
    // TODO: the wrapper around NonLinearConjugateGradientOptimizer is a temporary hack for
    // version 3.1 of the library. It should be removed when NonLinearConjugateGradientOptimizer
    // will officially be declared as implementing MultivariateDifferentiableOptimizer
    GradientMultivariateOptimizer underlying
        = new NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
                                                  new SimpleValueChecker(1e-10, 1e-10));
    JDKRandomGenerator g = new JDKRandomGenerator();
    g.setSeed(753289573253l);
    RandomVectorGenerator generator
        = new UncorrelatedRandomVectorGenerator(new double[] { 50, 50 },
                                                new double[] { 10, 10 },
                                                new GaussianRandomGenerator(g));
    int nbStarts = 10;
    MultiStartMultivariateOptimizer optimizer
        = new MultiStartMultivariateOptimizer(underlying, nbStarts, generator);
    PointValuePair optimum
        = optimizer.optimize(new MaxEval(1000),
                             circle.getObjectiveFunction(),
                             circle.getObjectiveFunctionGradient(),
                             GoalType.MINIMIZE,
                             new InitialGuess(new double[] { 98.680, 47.345 }));
    Assert.assertEquals(1000, optimizer.getMaxEvaluations());
    PointValuePair[] optima = optimizer.getOptima();
    Assert.assertEquals(nbStarts, optima.length);
    for (PointValuePair o : optima) {
        // we check the results of all intermediate restarts here (there are 10 such results)
        Vector2D center = new Vector2D(o.getPointRef()[0], o.getPointRef()[1]);
        Assert.assertTrue(69.9592 < circle.getRadius(center));
        Assert.assertTrue(69.9602 > circle.getRadius(center));
        Assert.assertTrue(96.0745 < center.getX());
        Assert.assertTrue(96.0762 > center.getX());
        Assert.assertTrue(48.1344 < center.getY());
        Assert.assertTrue(48.1354 > center.getY());
    }

    Assert.assertTrue(optimizer.getEvaluations() > 850);
    Assert.assertTrue(optimizer.getEvaluations() < 900);

    Assert.assertEquals(3.1267527, optimum.getValue(), 1e-8);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:49,代码来源:MultiStartMultivariateOptimizerTest.java


注:本文中的org.apache.commons.math3.optim.PointValuePair.getPointRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。