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

Java TooManyIterationsException类代码示例

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

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



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

示例1: ksSum

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
/**
 * Computes \( 1 + 2 \sum_{i=1}^\infty (-1)^i e^{-2 i^2 t^2} \) stopping when successive partial
 * sums are within {@code tolerance} of one another, or when {@code maxIterations} partial sums
 * have been computed. If the sum does not converge before {@code maxIterations} iterations a
 * {@link TooManyIterationsException} is thrown.
 *
 * @param t argument
 * @param tolerance Cauchy criterion for partial sums
 * @param maxIterations maximum number of partial sums to compute
 * @return Kolmogorov sum evaluated at t
 * @throws TooManyIterationsException if the series does not converge
 */
public double ksSum(double t, double tolerance, int maxIterations) {
    if (t == 0.0) {
        return 0.0;
    }

    // TODO: for small t (say less than 1), the alternative expansion in part 3 of [1]
    // from class javadoc should be used.

    final double x = -2 * t * t;
    int sign = -1;
    long i = 1;
    double partialSum = 0.5d;
    double delta = 1;
    while (delta > tolerance && i < maxIterations) {
        delta = FastMath.exp(x * i * i);
        partialSum += sign * delta;
        sign *= -1;
        i++;
    }
    if (i == maxIterations) {
        throw new TooManyIterationsException(maxIterations);
    }
    return partialSum * 2;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:37,代码来源:KolmogorovSmirnovTest.java


示例2: solvePhase1

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
/**
 * Solves Phase 1 of the Simplex method.
 *
 * @param tableau Simple tableau for the problem.
 * @throws TooManyIterationsException if the allowed number of iterations has been exhausted.
 * @throws UnboundedSolutionException if the model is found not to have a bounded solution.
 * @throws NoFeasibleSolutionException if there is no feasible solution?
 */
protected void solvePhase1(final SimplexTableau tableau)
    throws TooManyIterationsException,
           UnboundedSolutionException,
           NoFeasibleSolutionException {

    // make sure we're in Phase 1
    if (tableau.getNumArtificialVariables() == 0) {
        return;
    }

    while (!tableau.isOptimal()) {
        doIteration(tableau);
    }

    // if W is not zero then we have no feasible solution
    if (!Precision.equals(tableau.getEntry(0, tableau.getRhsOffset()), 0d, epsilon)) {
        throw new NoFeasibleSolutionException();
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:28,代码来源:SimplexSolver.java


示例3: ksSum

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
/**
 * Computes \( 1 + 2 \sum_{i=1}^\infty (-1)^i e^{-2 i^2 t^2} \) stopping when successive partial
 * sums are within {@code tolerance} of one another, or when {@code maxIterations} partial sums
 * have been computed. If the sum does not converge before {@code maxIterations} iterations a
 * {@link TooManyIterationsException} is thrown.
 *
 * @param t argument
 * @param tolerance Cauchy criterion for partial sums
 * @param maxIterations maximum number of partial sums to compute
 * @return Kolmogorov sum evaluated at t
 * @throws TooManyIterationsException if the series does not converge
 */
public double ksSum(double t, double tolerance, int maxIterations) {
    // TODO: for small t (say less than 1), the alternative expansion in part 3 of [1]
    // from class javadoc should be used.
    final double x = -2 * t * t;
    int sign = -1;
    long i = 1;
    double partialSum = 0.5d;
    double delta = 1;
    while (delta > tolerance && i < maxIterations) {
        delta = FastMath.exp(x * i * i);
        partialSum += sign * delta;
        sign *= -1;
        i++;
    }
    if (i == maxIterations) {
        throw new TooManyIterationsException(maxIterations);
    }
    return partialSum * 2;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:32,代码来源:KolmogorovSmirnovTest.java


示例4: doIteration

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
/**
 * Runs one iteration of the Simplex method on the given model.
 *
 * @param tableau Simple tableau for the problem.
 * @throws TooManyIterationsException if the allowed number of iterations has been exhausted.
 * @throws UnboundedSolutionException if the model is found not to have a bounded solution.
 */
protected void doIteration(final SimplexTableau tableau)
    throws TooManyIterationsException,
           UnboundedSolutionException {

    incrementIterationCount();

    Integer pivotCol = getPivotColumn(tableau);
    Integer pivotRow = getPivotRow(tableau, pivotCol);
    if (pivotRow == null) {
        throw new UnboundedSolutionException();
    }

    // set the pivot element to 1
    double pivotVal = tableau.getEntry(pivotRow, pivotCol);
    tableau.divideRow(pivotRow, pivotVal);

    // set the rest of the pivot column to 0
    for (int i = 0; i < tableau.getHeight(); i++) {
        if (i != pivotRow) {
            final double multiplier = tableau.getEntry(i, pivotCol);
            tableau.subtractRow(i, pivotRow, multiplier);
        }
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:32,代码来源:SimplexSolver.java


示例5: doOptimize

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public PointValuePair doOptimize()
    throws TooManyIterationsException,
           UnboundedSolutionException,
           NoFeasibleSolutionException {
    final SimplexTableau tableau =
        new SimplexTableau(getFunction(),
                           getConstraints(),
                           getGoalType(),
                           isRestrictedToNonNegative(),
                           epsilon,
                           maxUlps,
                           cutOff);

    solvePhase1(tableau);
    tableau.dropPhase1Objective();

    while (!tableau.isOptimal()) {
        doIteration(tableau);
    }
    return tableau.getSolution();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:24,代码来源:SimplexSolver.java


示例6: doOptimize

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public PointValuePair doOptimize()
    throws TooManyIterationsException,
           UnboundedSolutionException,
           NoFeasibleSolutionException {
    final SimplexTableau tableau =
        new SimplexTableau(getFunction(),
                           getConstraints(),
                           getGoalType(),
                           isRestrictedToNonNegative(),
                           epsilon,
                           maxUlps);

    solvePhase1(tableau);
    tableau.dropPhase1Objective();

    while (!tableau.isOptimal()) {
        doIteration(tableau);
    }
    return tableau.getSolution();
}
 
开发者ID:charles-cooper,项目名称:idylfin,代码行数:23,代码来源:SimplexSolver.java


示例7: optimize

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
/**
 * Performs the optimization.
 *
 * @return a point/value pair that satisfies the convergence criteria.
 * @throws TooManyEvaluationsException if the maximal number of
 * evaluations is exceeded.
 * @throws TooManyIterationsException if the maximal number of
 * iterations is exceeded.
 */
public PAIR optimize()
    throws TooManyEvaluationsException,
           TooManyIterationsException {
    // Reset counters.
    evaluations.resetCount();
    iterations.resetCount();
    // Perform optimization.
    return doOptimize();
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:19,代码来源:BaseOptimizer.java


示例8: doIteration

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
/**
 * Runs one iteration of the Simplex method on the given model.
 *
 * @param tableau Simple tableau for the problem.
 * @throws TooManyIterationsException if the allowed number of iterations has been exhausted.
 * @throws UnboundedSolutionException if the model is found not to have a bounded solution.
 */
protected void doIteration(final SimplexTableau tableau)
    throws TooManyIterationsException,
           UnboundedSolutionException {

    incrementIterationCount();

    Integer pivotCol = getPivotColumn(tableau);
    Integer pivotRow = getPivotRow(tableau, pivotCol);
    if (pivotRow == null) {
        throw new UnboundedSolutionException();
    }

    tableau.performRowOperations(pivotCol, pivotRow);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:22,代码来源:SimplexSolver.java


示例9: testWithMaxIterations2

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
@Test(expected=TooManyIterationsException.class)
public void testWithMaxIterations2() {
    final int maxIter = 1; // Too few iterations.
    final double[] init = { 3.5e6, 4.2, 0.1 };

    GaussianCurveFitter fitter = GaussianCurveFitter.create();
    fitter.withMaxIterations(maxIter)
          .withStartPoint(init)
          .fit(createDataset(DATASET1).toList());
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:11,代码来源:GaussianCurveFitterTest.java


示例10: testSolutionCallback

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
@Test
public void testSolutionCallback() {
    // re-use the problem from testcase for MATH-288
    // it normally requires 5 iterations
    
    LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 7, 3, 0, 0 }, 0 );

    List<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
    constraints.add(new LinearConstraint(new double[] { 3, 0, -5, 0 }, Relationship.LEQ, 0.0));
    constraints.add(new LinearConstraint(new double[] { 2, 0, 0, -5 }, Relationship.LEQ, 0.0));
    constraints.add(new LinearConstraint(new double[] { 0, 3, 0, -5 }, Relationship.LEQ, 0.0));
    constraints.add(new LinearConstraint(new double[] { 1, 0, 0, 0 }, Relationship.LEQ, 1.0));
    constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 0 }, Relationship.LEQ, 1.0));

    final SimplexSolver solver = new SimplexSolver();
    final SolutionCallback callback = new SolutionCallback();
    
    Assert.assertNull(callback.getSolution());
    Assert.assertFalse(callback.isSolutionOptimal());

    try {
        solver.optimize(new MaxIter(3), f, new LinearConstraintSet(constraints),
                        GoalType.MAXIMIZE, new NonNegativeConstraint(true), callback);
        Assert.fail("expected TooManyIterationsException");
    } catch (TooManyIterationsException ex) {
        // expected
    }
    
    final PointValuePair solution = callback.getSolution();
    Assert.assertNotNull(solution);
    Assert.assertTrue(validSolution(solution, constraints, 1e-4));
    Assert.assertFalse(callback.isSolutionOptimal());
    // the solution is clearly not optimal: optimal = 10.0
    Assert.assertEquals(7.0, solution.getValue(), 1e-4);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:36,代码来源:SimplexSolverTest.java


示例11: optimize

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
/**
 * Performs the optimization.
 *
 * @return a point/value pair that satifies the convergence criteria.
 * @throws TooManyEvaluationsException if the maximal number of
 * evaluations is exceeded.
 * @throws TooManyIterationsException if the maximal number of
 * iterations is exceeded.
 */
public PAIR optimize()
    throws TooManyEvaluationsException,
           TooManyIterationsException {
    // Reset counters.
    evaluations.resetCount();
    iterations.resetCount();
    // Perform optimization.
    return doOptimize();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:AbstractOptimizer.java


示例12: testWithMaxIterations2

import org.apache.commons.math3.exception.TooManyIterationsException; //导入依赖的package包/类
@Test(expected=TooManyIterationsException.class)
public void testWithMaxIterations2() {
    final int maxIter = 1; // Too few iterations.
    final double[] init = { 3.5e6, 4.2, 0.1 };

    GaussianCurveFitter fitter = GaussianCurveFitter.create();
    double[] parameters = fitter
        .withMaxIterations(maxIter)
        .withStartPoint(init)
        .fit(createDataset(DATASET1).toList());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:12,代码来源:GaussianCurveFitterTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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