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


Java MultivariateRealOptimizer类代码示例

本文整理汇总了Java中org.apache.commons.math.optimization.MultivariateRealOptimizer的典型用法代码示例。如果您正苦于以下问题:Java MultivariateRealOptimizer类的具体用法?Java MultivariateRealOptimizer怎么用?Java MultivariateRealOptimizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MultivariateRealOptimizer类属于org.apache.commons.math.optimization包,在下文中一共展示了MultivariateRealOptimizer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doTest

import org.apache.commons.math.optimization.MultivariateRealOptimizer; //导入依赖的package包/类
/**
 * @param func Function to optimize.
 * @param optimum Expected optimum.
 * @param init Starting point.
 * @param goal Minimization or maximization.
 * @param fTol Tolerance (relative error on the objective function) for
 * "Powell" algorithm.
 * @param pointTol Tolerance for checking that the optimum is correct.
 */
private void doTest(MultivariateRealFunction func,
                    double[] optimum,
                    double[] init,
                    GoalType goal,
                    double fTol,
                    double pointTol) {
    final MultivariateRealOptimizer optim = new PowellOptimizer(fTol, Math.ulp(1d));

    final RealPointValuePair result = optim.optimize(1000, 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);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:PowellOptimizerTest.java

示例2: doTest

import org.apache.commons.math.optimization.MultivariateRealOptimizer; //导入依赖的package包/类
/**
 * @param func Function to optimize.
 * @param startPoint Starting point.
 * @param inSigma Individual input sigma.
 * @param boundaries Upper / lower point limit.
 * @param goal Minimization or maximization.
 * @param lambda Population size used for offspring.
 * @param isActive Covariance update mechanism.
 * @param diagonalOnly Simplified covariance update.
 * @param stopValue Termination criteria for optimization.
 * @param fTol Tolerance relative error on the objective function.
 * @param pointTol Tolerance for checking that the optimum is correct.
 * @param maxEvaluations Maximum number of evaluations.
 * @param expected Expected point / value.
 */
private void doTest(MultivariateRealFunction func,
        double[] startPoint,
        double[] inSigma,
        double[][] boundaries,
        GoalType goal,
        int lambda,
        boolean isActive,
        int diagonalOnly, 
        double stopValue,
        double fTol,
        double pointTol,
        int maxEvaluations,
        RealPointValuePair expected)
throws MathException {
    int dim = startPoint.length;
    // test diagonalOnly = 0 - slow but normally fewer feval#
    MultivariateRealOptimizer optim =
        new CMAESOptimizer(
                lambda, inSigma, boundaries, 30000,
                stopValue, isActive, diagonalOnly, 0, new MersenneTwister(),false);
    RealPointValuePair result = optim.optimize(maxEvaluations, func, goal, startPoint);
    Assert.assertEquals(expected.getValue(),
            result.getValue(), fTol);
    for (int i = 0; i < dim; i++) {
        Assert.assertEquals(expected.getPoint()[i],
                result.getPoint()[i], pointTol);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:44,代码来源:CMAESOptimizerTest.java

示例3: doTest

import org.apache.commons.math.optimization.MultivariateRealOptimizer; //导入依赖的package包/类
/**
 * @param func Function to optimize.
 * @param startPoint Starting point.
 * @param inSigma Individual input sigma.
 * @param boundaries Upper / lower point limit.
 * @param goal Minimization or maximization.
 * @param lambda Population size used for offspring.
 * @param isActive Covariance update mechanism.
 * @param diagonalOnly Simplified covariance update.
 * @param stopValue Termination criteria for optimization.
 * @param fTol Tolerance relative error on the objective function.
 * @param pointTol Tolerance for checking that the optimum is correct.
 * @param maxEvaluations Maximum number of evaluations.
 * @param expected Expected point / value.
 */
private void doTest(MultivariateRealFunction func,
        double[] startPoint,
        double[] inSigma,
        double[][] boundaries,
        GoalType goal,
        int lambda,
        boolean isActive,
        int diagonalOnly, 
        double stopValue,
        double fTol,
        double pointTol,
        int maxEvaluations,
        RealPointValuePair expected) {
    int dim = startPoint.length;
    // test diagonalOnly = 0 - slow but normally fewer feval#
    MultivariateRealOptimizer optim =
        new CMAESOptimizer(
                lambda, inSigma, boundaries, 30000,
                stopValue, isActive, diagonalOnly, 0, new MersenneTwister(),false);
    RealPointValuePair result = optim.optimize(maxEvaluations, func, goal, startPoint);
    Assert.assertEquals(expected.getValue(),
            result.getValue(), fTol);
    for (int i = 0; i < dim; i++) {
        Assert.assertEquals(expected.getPoint()[i],
                result.getPoint()[i], pointTol);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:43,代码来源:CMAESOptimizerTest.java

示例4: doTest

import org.apache.commons.math.optimization.MultivariateRealOptimizer; //导入依赖的package包/类
/**
     * @param func Function to optimize.
     * @param startPoint Starting point.
     * @param boundaries Upper / lower point limit.
     * @param goal Minimization or maximization.
     * @param fTol Tolerance relative error on the objective function.
     * @param pointTol Tolerance for checking that the optimum is correct.
     * @param maxEvaluations Maximum number of evaluations.
     * @param expected Expected point / value.
     */
    private void doTest(MultivariateRealFunction func,
            double[] startPoint,
            double[][] boundaries,
            GoalType goal,
            double fTol,
            double pointTol,
            int maxEvaluations,
            RealPointValuePair expected) {

        System.out.println(func.getClass().getName() + " BEGIN"); // XXX

        int dim = startPoint.length;
//        MultivariateRealOptimizer optim =
//            new PowellOptimizer(1e-13, Math.ulp(1d));
//        RealPointValuePair result = optim.optimize(100000, func, goal, startPoint);
        final double[] lB = boundaries == null ? null : boundaries[0];
        final double[] uB = boundaries == null ? null : boundaries[1];
        MultivariateRealOptimizer optim =
            new BOBYQAOptimizer(2 * dim + 1, lB, uB);
        RealPointValuePair result = optim.optimize(maxEvaluations, func, goal, startPoint);        
//        System.out.println(func.getClass().getName() + " = " 
//        		+ optim.getEvaluations() + " f(");
//        for (double x: result.getPoint())  System.out.print(x + " ");
//        System.out.println(") = " +  result.getValue());
        Assert.assertEquals(expected.getValue(),
                result.getValue(), fTol);
        for (int i = 0; i < dim; i++) {
            Assert.assertEquals(expected.getPoint()[i],
                    result.getPoint()[i], pointTol);
        }

        System.out.println(func.getClass().getName() + " END"); // XXX
    }
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:44,代码来源:BOBYQAOptimizerTest.java


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