• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ConvergenceChecker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
/**
 * Create a {@link org.apache.commons.math3.fitting.leastsquares.LeastSquaresProblem}
 * from the given elements. There will be no weights applied (unit weights).
 *
 * @param model          the model function. Produces the computed values.
 * @param observed       the observed (target) values
 * @param start          the initial guess.
 * @param weight         the weight matrix
 * @param checker        convergence checker
 * @param maxEvaluations the maximum number of times to evaluate the model
 * @param maxIterations  the maximum number to times to iterate in the algorithm
 * @param lazyEvaluation Whether the call to {@link Evaluation#evaluate(RealVector)}
 * will defer the evaluation until access to the value is requested.
 * @param paramValidator Model parameters validator.
 * @return the specified General Least Squares problem.
 *
 * @since 3.4
 */
public static LeastSquaresProblem create(final MultivariateJacobianFunction model,
                                         final RealVector observed,
                                         final RealVector start,
                                         final RealMatrix weight,
                                         final ConvergenceChecker<Evaluation> checker,
                                         final int maxEvaluations,
                                         final int maxIterations,
                                         final boolean lazyEvaluation,
                                         final ParameterValidator paramValidator) {
    final LeastSquaresProblem p = new LocalLeastSquaresProblem(model,
                                                               observed,
                                                               start,
                                                               checker,
                                                               maxEvaluations,
                                                               maxIterations,
                                                               lazyEvaluation,
                                                               paramValidator);
    if (weight != null) {
        return weightMatrix(p, weight);
    } else {
        return p;
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:42,代码来源:LeastSquaresFactory.java


示例2: evaluationChecker

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
/**
 * View a convergence checker specified for a {@link PointVectorValuePair} as one
 * specified for an {@link Evaluation}.
 *
 * @param checker the convergence checker to adapt.
 * @return a convergence checker that delegates to {@code checker}.
 */
public static ConvergenceChecker<Evaluation> evaluationChecker(final ConvergenceChecker<PointVectorValuePair> checker) {
    return new ConvergenceChecker<Evaluation>() {
        /** {@inheritDoc} */
        public boolean converged(final int iteration,
                                 final Evaluation previous,
                                 final Evaluation current) {
            return checker.converged(
                    iteration,
                    new PointVectorValuePair(
                            previous.getPoint().toArray(),
                            previous.getResiduals().toArray(),
                            false),
                    new PointVectorValuePair(
                            current.getPoint().toArray(),
                            current.getResiduals().toArray(),
                            false)
            );
        }
    };
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:28,代码来源:LeastSquaresFactory.java


示例3: LocalLeastSquaresProblem

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
/**
 * Create a {@link LeastSquaresProblem} from the given data.
 *
 * @param model          the model function
 * @param target         the observed data
 * @param start          the initial guess
 * @param checker        the convergence checker
 * @param maxEvaluations the allowed evaluations
 * @param maxIterations  the allowed iterations
 * @param lazyEvaluation Whether the call to {@link Evaluation#evaluate(RealVector)}
 * will defer the evaluation until access to the value is requested.
 * @param paramValidator Model parameters validator.
 */
LocalLeastSquaresProblem(final MultivariateJacobianFunction model,
                         final RealVector target,
                         final RealVector start,
                         final ConvergenceChecker<Evaluation> checker,
                         final int maxEvaluations,
                         final int maxIterations,
                         final boolean lazyEvaluation,
                         final ParameterValidator paramValidator) {
    super(maxEvaluations, maxIterations, checker);
    this.target = target;
    this.model = model;
    this.start = start;
    this.lazyEvaluation = lazyEvaluation;
    this.paramValidator = paramValidator;

    if (lazyEvaluation &&
        !(model instanceof ValueAndJacobianFunction)) {
        // Lazy evaluation requires that value and Jacobian
        // can be computed separately.
        throw new MathIllegalStateException(LocalizedFormats.INVALID_IMPLEMENTATION,
                                            model.getClass().getName());
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:37,代码来源:LeastSquaresFactory.java


示例4: NonLinearConjugateGradientOptimizer

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
/**
 * @param updateFormula formula to use for updating the &beta; parameter,
 * must be one of {@link Formula#FLETCHER_REEVES} or
 * {@link Formula#POLAK_RIBIERE}.
 * @param checker Convergence checker.
 * @param preconditioner Preconditioner.
 * @param relativeTolerance Relative threshold for line search.
 * @param absoluteTolerance Absolute threshold for line search.
 * @param initialBracketingRange Extent of the initial interval used to
 * find an interval that brackets the optimum in order to perform the
 * line search.
 *
 * @see LineSearch#LineSearch(MultivariateOptimizer,double,double,double)
 * @since 3.3
 */
public NonLinearConjugateGradientOptimizer(final Formula updateFormula,
                                           ConvergenceChecker<PointValuePair> checker,
                                           double relativeTolerance,
                                           double absoluteTolerance,
                                           double initialBracketingRange,
                                           final Preconditioner preconditioner) {
    super(checker);

    this.updateFormula = updateFormula;
    this.preconditioner = preconditioner;
    line = new LineSearch(this,
                          relativeTolerance,
                          absoluteTolerance,
                          initialBracketingRange);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:31,代码来源:NonLinearConjugateGradientOptimizer.java


示例5: PowellOptimizer

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
/**
 * This constructor allows to specify a user-defined convergence checker,
 * in addition to the parameters that control the default convergence
 * checking procedure and the line search tolerances.
 *
 * @param rel Relative threshold for this optimizer.
 * @param abs Absolute threshold for this optimizer.
 * @param lineRel Relative threshold for the internal line search optimizer.
 * @param lineAbs Absolute threshold for the internal line search optimizer.
 * @param checker Convergence checker.
 * @throws NotStrictlyPositiveException if {@code abs <= 0}.
 * @throws NumberIsTooSmallException if {@code rel < 2 * Math.ulp(1d)}.
 */
public PowellOptimizer(double rel,
                       double abs,
                       double lineRel,
                       double lineAbs,
                       ConvergenceChecker<PointValuePair> checker) {
    super(checker);

    if (rel < MIN_RELATIVE_TOLERANCE) {
        throw new NumberIsTooSmallException(rel, MIN_RELATIVE_TOLERANCE, true);
    }
    if (abs <= 0) {
        throw new NotStrictlyPositiveException(abs);
    }
    relativeThreshold = rel;
    absoluteThreshold = abs;

    // Create the line search optimizer.
    line = new LineSearch(this,
                          lineRel,
                          lineAbs,
                          1d);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:36,代码来源:PowellOptimizer.java


示例6: CMAESOptimizer

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
/**
 * @param maxIterations Maximal number of iterations.
 * @param stopFitness Whether to stop if objective function value is smaller than
 * {@code stopFitness}.
 * @param isActiveCMA Chooses the covariance matrix update method.
 * @param diagonalOnly Number of initial iterations, where the covariance matrix
 * remains diagonal.
 * @param checkFeasableCount Determines how often new random objective variables are
 * generated in case they are out of bounds.
 * @param random Random generator.
 * @param generateStatistics Whether statistic data is collected.
 * @param checker Convergence checker.
 *
 * @since 3.1
 */
public CMAESOptimizer(int maxIterations,
                      double stopFitness,
                      boolean isActiveCMA,
                      int diagonalOnly,
                      int checkFeasableCount,
                      RandomGenerator random,
                      boolean generateStatistics,
                      ConvergenceChecker<PointValuePair> checker) {
    super(checker);
    this.maxIterations = maxIterations;
    this.stopFitness = stopFitness;
    this.isActiveCMA = isActiveCMA;
    this.diagonalOnly = diagonalOnly;
    this.checkFeasableCount = checkFeasableCount;
    this.random = random;
    this.generateStatistics = generateStatistics;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:33,代码来源:CMAESOptimizer.java


示例7: evaluationChecker

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
/**
 * View a convergence checker specified for a {@link PointVectorValuePair} as one
 * specified for an {@link Evaluation}.
 *
 * @param checker the convergence checker to adapt.
 * @return a convergence checker that delegates to {@code checker}.
 */
public static ConvergenceChecker<Evaluation> evaluationChecker(final ConvergenceChecker<PointVectorValuePair> checker) {
    return new ConvergenceChecker<Evaluation>() {
        public boolean converged(final int iteration,
                                 final Evaluation previous,
                                 final Evaluation current) {
            return checker.converged(
                    iteration,
                    new PointVectorValuePair(
                            previous.getPoint().toArray(),
                            previous.getResiduals().toArray(),
                            false),
                    new PointVectorValuePair(
                            current.getPoint().toArray(),
                            current.getResiduals().toArray(),
                            false)
            );
        }
    };
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:LeastSquaresFactory.java


示例8: testEvaluationCount

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
@Test
public void testEvaluationCount() {
    //setup
    LeastSquaresProblem lsp = new LinearProblem(new double[][] {{1}}, new double[] {1})
            .getBuilder()
            .checker(new ConvergenceChecker<Evaluation>() {
                public boolean converged(int iteration, Evaluation previous, Evaluation current) {
                    return true;
                }
            })
            .build();

    //action
    Optimum optimum = optimizer.optimize(lsp);

    //verify
    //check iterations and evaluations are not switched.
    Assert.assertThat(optimum.getIterations(), is(1));
    Assert.assertThat(optimum.getEvaluations(), is(2));
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:21,代码来源:LevenbergMarquardtOptimizerTest.java


示例9: testPointCopy

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
@Test
public void testPointCopy() {
    LinearProblem problem = new LinearProblem(new double[][]{
            {1, 0, 0},
            {-1, 1, 0},
            {0, -1, 1}
    }, new double[]{1, 1, 1});
    //mutable boolean
    final boolean[] checked = {false};

    final LeastSquaresBuilder builder = problem.getBuilder()
            .checker(new ConvergenceChecker<Evaluation>() {
                public boolean converged(int iteration, Evaluation previous, Evaluation current) {
                    Assert.assertThat(
                            previous.getPoint(),
                            not(sameInstance(current.getPoint())));
                    Assert.assertArrayEquals(new double[3], previous.getPoint().toArray(), 0);
                    Assert.assertArrayEquals(new double[] {1, 2, 3}, current.getPoint().toArray(), TOl);
                    checked[0] = true;
                    return true;
                }
            });
    optimizer.optimize(builder.build());

    Assert.assertThat(checked[0], is(true));
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java


示例10: testConverged

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
/** check {@link ConvergenceChecker#converged(int, Object, Object)}. */
@Test
public void testConverged() {
    //setup
    ConvergenceChecker<Evaluation> checker = new EvaluationRmsChecker(0.1, 1);
    Evaluation e200 = mockEvaluation(200);
    Evaluation e1 = mockEvaluation(1);

    //action + verify
    //just matches rel tol
    Assert.assertEquals(true, checker.converged(0, e200, mockEvaluation(210)));
    //just matches abs tol
    Assert.assertEquals(true, checker.converged(0, e1, mockEvaluation(1.9)));
    //matches both
    Assert.assertEquals(true, checker.converged(0, e1, mockEvaluation(1.01)));
    //matches neither
    Assert.assertEquals(false, checker.converged(0, e200, mockEvaluation(300)));
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:19,代码来源:EvaluationRmsCheckerTest.java


示例11: PowellOptimizer

import org.apache.commons.math3.optim.ConvergenceChecker; //导入依赖的package包/类
/**
 * This constructor allows to specify a user-defined convergence checker,
 * in addition to the parameters that control the default convergence
 * checking procedure and the line search tolerances.
 *
 * @param rel Relative threshold for this optimizer.
 * @param abs Absolute threshold for this optimizer.
 * @param lineRel Relative threshold for the internal line search optimizer.
 * @param lineAbs Absolute threshold for the internal line search optimizer.
 * @param checker Convergence checker.
 * @throws NotStrictlyPositiveException if {@code abs <= 0}.
 * @throws NumberIsTooSmallException if {@code rel < 2 * Math.ulp(1d)}.
 */
public PowellOptimizer(double rel,
                       double abs,
                       double lineRel,
                       double lineAbs,
                       ConvergenceChecker<PointValuePair> checker) {
    super(checker);

    if (rel < MIN_RELATIVE_TOLERANCE) {
        throw new NumberIsTooSmallException(rel, MIN_RELATIVE_TOLERANCE, true);
    }
    if (abs <= 0) {
        throw new NotStrictlyPositiveException(abs);
    }
    relativeThreshold = rel;
    absoluteThreshold = abs;

    // Create the line search optimizer.
    line = new LineSearch(lineRel,
                          lineAbs);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:34,代码来源:PowellOptimizer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Scheduler类代码示例发布时间:2022-05-22
下一篇:
Java RealmCallback类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap