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


Java MaxIterationsExceededException类代码示例

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


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

示例1: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a real root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 * 
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * or the solver detects convergence problems otherwise
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(double min, double max, double initial) throws
    MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(min, initial);
    } else {
        return solve(initial, max);
    }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:32,代码来源:MullerSolver.java

示例2: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a zero in the given interval.
 * <p>
 * Requires that the values of the function at the endpoints have opposite
 * signs. An <code>IllegalArgumentException</code> is thrown if this is not
 * the case.</p>
 * 
 * @param min the lower bound for the interval.
 * @param max the upper bound for the interval.
 * @return the value where the function is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function 
 * @throws IllegalArgumentException if min is not less than max or the
 * signs of the values of the function at the endpoints are not opposites
 */
public double solve(double min, double max) throws MaxIterationsExceededException, 
    FunctionEvaluationException {
    
    clearResult();
    verifyInterval(min, max);
    
    double yMin = f.value(min);
    double yMax = f.value(max);
    
    // Verify bracketing
    if (yMin * yMax >= 0) {
        throw new IllegalArgumentException
        ("Function values at endpoints do not have different signs." +
                "  Endpoints: [" + min + "," + max + "]" + 
                "  Values: [" + yMin + "," + yMax + "]");       
    }

    // solve using only the first endpoint as initial guess
    return solve(min, yMin, max, yMax, min, yMin);

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:38,代码来源:BrentSolver.java

示例3: integrate

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Integrate the function in the given interval.
 * 
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @return the value of integral
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * or the integrator detects convergence problems otherwise
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double integrate(double min, double max) throws MaxIterationsExceededException,
    FunctionEvaluationException, IllegalArgumentException {
    
    int i = 1;
    double t, oldt;
    
    clearResult();
    verifyInterval(min, max);
    verifyIterationCount();

    oldt = stage(min, max, 0);
    while (i <= maximalIterationCount) {
        t = stage(min, max, i);
        if (i >= minimalIterationCount) {
            if (Math.abs(t - oldt) <= Math.abs(relativeAccuracy * oldt)) {
                setResult(t, i);
                return result;
            }
        }
        oldt = t;
        i++;
    }
    throw new MaxIterationsExceededException(maximalIterationCount);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:37,代码来源:TrapezoidIntegrator.java

示例4: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 * 
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(double min, double max, double initial) throws
    MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(min, initial);
    } else {
        return solve(initial, max);
    }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:31,代码来源:RiddersSolver.java

示例5: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a zero near the value <code>startValue</code>.
 * 
 * @param min the lower bound for the interval (ignored).
 * @param max the upper bound for the interval (ignored).
 * @param startValue the start value to use.
 * @return the value where the function is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded 
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function or derivative
 * @throws IllegalArgumentException if startValue is not between min and max
 */
public double solve(double min, double max, double startValue)
    throws MaxIterationsExceededException, FunctionEvaluationException {
    
    clearResult();
    verifySequence(min, startValue, max);

    double x0 = startValue;
    double x1;
    
    int i = 0;
    while (i < maximalIterationCount) {
        x1 = x0 - (f.value(x0) / derivative.value(x0));
        if (Math.abs(x1 - x0) <= absoluteAccuracy) {
            
            setResult(x1, i);
            return x1;
        }
        
        x0 = x1;
        ++i;
    }
    
    throw new MaxIterationsExceededException(maximalIterationCount);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:37,代码来源:NewtonSolver.java

示例6: calculateThreshold

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected static double calculateThreshold(int[][] samples, int nClusters) throws MaxIterationsExceededException,
		FunctionEvaluationException
{
	int maxDistance = 0;
	for (int i = 0; i < samples.length; i++) {
		for (int j = i + 1; j < samples.length; j++) {
			distances[i][j] = distanceEuclidianSquared(samples[i], samples[j]);
			distances[j][i] = distances[i][j];
			if (distances[i][j] > maxDistance)
				maxDistance = distances[i][j];
		}
	}
	System.out.println("Distance matrix calculated");
	final BisectionSolver b = new BisectionSolver();
	b.setAbsoluteAccuracy(100.0);
	return b.solve(100, new ClusterMinimisationFunction(samples, distances, nClusters), 0, maxDistance);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:IntRAC.java

示例7: integrate

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
    * {@inheritDoc}
    */
   @Override
public double integrate(final UnivariateRealFunction f,
                           final double min, final double max)
           throws MaxIterationsExceededException, FunctionEvaluationException, IllegalArgumentException {

       clearResult();
       verifyInterval(min, max);
       verifyIterationCount();

       double oldt = stage(f, min, max, 0);
       for (int i = 1; i <= maximalIterationCount; ++i) {
           final double t = stage(f, min, max, i);
           if (i >= minimalIterationCount) {
               final double delta = Math.abs(t - oldt);
               final double rLimit =
                       relativeAccuracy * (Math.abs(oldt) + Math.abs(t)) * 0.5;
               if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
                   setResult(t, i);
                   return result;
               }
           }
           oldt = t;
       }
       throw new MaxIterationsExceededException(maximalIterationCount);
   }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:29,代码来源:TrapezoidIntegrator.java

示例8: integrate

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/** {@inheritDoc} */
public double integrate(final UnivariateRealFunction f,
                        final double min, final double max)
    throws MaxIterationsExceededException, FunctionEvaluationException, IllegalArgumentException {

    clearResult();
    verifyInterval(min, max);
    verifyIterationCount();

    double oldt = stage(f, min, max, 0);
    for (int i = 1; i <= maximalIterationCount; ++i) {
        final double t = stage(f, min, max, i);
        if (i >= minimalIterationCount) {
            final double delta = Math.abs(t - oldt);
            final double rLimit =
                relativeAccuracy * (Math.abs(oldt) + Math.abs(t)) * 0.5;
            if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
                setResult(t, i);
                return result;
            }
        }
        oldt = t;
    }
    throw new MaxIterationsExceededException(maximalIterationCount);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:TrapezoidIntegrator.java

示例9: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 * 
 * @param f the function to solve
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(final UnivariateRealFunction f,
                    final double min, final double max, final double initial)
    throws MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(f, min, initial);
    } else {
        return solve(f, initial, max);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:RiddersSolver.java

示例10: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
    * Find a real root in the given interval with initial value.
    * <p>
    * Requires bracketing condition.</p>
    *
    * @param f       the function to solve
    * @param min     the lower bound for the interval
    * @param max     the upper bound for the interval
    * @param initial the start value to use
    * @return the point at which the function value is zero
    * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
    *                                        or the solver detects convergence problems otherwise
    * @throws FunctionEvaluationException    if an error occurs evaluating the
    *                                        function
    * @throws IllegalArgumentException       if any parameters are invalid
    */
   @Override
public double solve(final UnivariateRealFunction f,
                       final double min, final double max, final double initial)
           throws MaxIterationsExceededException, FunctionEvaluationException {

       // check for zeros before verifying bracketing
       if (f.value(min) == 0.0) {
           return min;
       }
       if (f.value(max) == 0.0) {
           return max;
       }
       if (f.value(initial) == 0.0) {
           return initial;
       }

       verifyBracketing(min, max, f);
       verifySequence(min, initial, max);
       if (isBracketing(min, initial, f)) {
           return solve(f, min, initial);
       } else {
           return solve(f, initial, max);
       }
   }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:41,代码来源:MullerSolver.java

示例11: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 *
 * @param f the function to solve
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(final UnivariateRealFunction f,
                    final double min, final double max, final double initial)
    throws MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(f, min, initial);
    } else {
        return solve(f, initial, max);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:RiddersSolver.java

示例12: testQuinticMax

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
@Test
public void testQuinticMax() throws MathException {
    // The quintic function has zeros at 0, +-0.5 and +-1.
    // The function has extrema (first derivative is zero) at 0.27195613 and 0.82221643,
    UnivariateRealFunction f = new QuinticFunction();
    UnivariateRealOptimizer minimizer = new BrentOptimizer();
    assertEquals(0.27195613, minimizer.optimize(f, GoalType.MAXIMIZE, 0.2, 0.3), 1.0e-8);
    minimizer.setMaximalIterationCount(30);
    try {
        minimizer.optimize(f, GoalType.MAXIMIZE, 0.2, 0.3);
        fail("an exception should have been thrown");
    } catch (MaxIterationsExceededException miee) {
        // expected
    } catch (Exception e) {
        fail("wrong exception caught");
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:BrentMinimizerTest.java

示例13: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a real root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 *
 * @param f the function to solve
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * or the solver detects convergence problems otherwise
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(final UnivariateRealFunction f,
                    final double min, final double max, final double initial)
    throws MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(f, min, initial);
    } else {
        return solve(f, initial, max);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:34,代码来源:MullerSolver.java

示例14: cumulativeProbability

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * For this disbution, X, this method returns P(X &lt; <code>x</code>).
 * @param x the value at which the CDF is evaluated.
 * @return CDF evaluted at <code>x</code>. 
 * @throws MathException if the algorithm fails to converge; unless
 * x is more than 20 standard deviations from the mean, in which case the
 * convergence exception is caught and 0 or 1 is returned.
 */
public double cumulativeProbability(double x) throws MathException {
    try {
        return 0.5 * (1.0 + Erf.erf((x - mean) /
                (standardDeviation * Math.sqrt(2.0))));
    } catch (MaxIterationsExceededException ex) {
        if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38
            return 0.0d;
        } else if (x > (mean + 20 * standardDeviation)) {
            return 1.0d;
        } else {
            throw ex;
        }
    }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:NormalDistributionImpl.java

示例15: regularizedGammaP

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Returns the regularized gamma function P(a, x).
 * 
 * The implementation of this method is based on:
 * <ul>
 * <li>
 * <a href="http://mathworld.wolfram.com/RegularizedGammaFunction.html">
 * Regularized Gamma Function</a>, equation (1).</li>
 * <li>
 * <a href="http://mathworld.wolfram.com/IncompleteGammaFunction.html">
 * Incomplete Gamma Function</a>, equation (4).</li>
 * <li>
 * <a href="http://mathworld.wolfram.com/ConfluentHypergeometricFunctionoftheFirstKind.html">
 * Confluent Hypergeometric Function of the First Kind</a>, equation (1).
 * </li>
 * </ul>
 * 
 * @param a the a parameter.
 * @param x the value.
 * @param epsilon When the absolute value of the nth item in the
 *                series is less than epsilon the approximation ceases
 *                to calculate further elements in the series.
 * @param maxIterations Maximum number of "iterations" to complete. 
 * @return the regularized gamma function P(a, x)
 * @throws MathException if the algorithm fails to converge.
 */
public static double regularizedGammaP(double a, 
                                       double x, 
                                       double epsilon, 
                                       int maxIterations) 
    throws MathException
{
    double ret;

    if (Double.isNaN(a) || Double.isNaN(x) || (a <= 0.0) || (x < 0.0)) {
        ret = Double.NaN;
    } else if (x == 0.0) {
        ret = 0.0;
    } else if (a >= 1.0 && x > a) {
        // use regularizedGammaQ because it should converge faster in this
        // case.
        ret = 1.0 - regularizedGammaQ(a, x, epsilon, maxIterations);
    } else {
        // calculate series
        double n = 0.0; // current element index
        double an = 1.0 / a; // n-th element in the series
        double sum = an; // partial sum
        while (Math.abs(an) > epsilon && n < maxIterations) {
            // compute next element in the series
            n = n + 1.0;
            an = an * (x / (a + n));

            // update partial sum
            sum = sum + an;
        }
        if (n >= maxIterations) {
            throw new MaxIterationsExceededException(maxIterations);
        } else {
            ret = Math.exp(-x + (a * Math.log(x)) - logGamma(a)) * sum;
        }
    }

    return ret;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:65,代码来源:Gamma.java


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