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


Java NoBracketingException类代码示例

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


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

示例1: integrate

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
/** {@inheritDoc} */
public double integrate(final FirstOrderDifferentialEquations equations,
                        final double t0, final double[] y0, final double t, final double[] y)
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    if (y0.length != equations.getDimension()) {
        throw new DimensionMismatchException(y0.length, equations.getDimension());
    }
    if (y.length != equations.getDimension()) {
        throw new DimensionMismatchException(y.length, equations.getDimension());
    }

    // prepare expandable stateful equations
    final ExpandableStatefulODE expandableODE = new ExpandableStatefulODE(equations);
    expandableODE.setTime(t0);
    expandableODE.setPrimaryState(y0);

    // perform integration
    integrate(expandableODE, t);

    // extract results back from the stateful equations
    System.arraycopy(expandableODE.getPrimaryState(), 0, y, 0, y.length);
    return expandableODE.getTime();

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:AbstractIntegrator.java

示例2: verifyBracketing

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
/**
 * Check that the endpoints specify an interval and the end points
 * bracket a root.
 *
 * @param function Function.
 * @param lower Lower endpoint.
 * @param upper Upper endpoint.
 * @throws NoBracketingException if the function has the same sign at the
 * endpoints.
 * @throws NullArgumentException if {@code function} is {@code null}.
 */
public static void verifyBracketing(UnivariateFunction function,
                                    final double lower,
                                    final double upper)
    throws NullArgumentException,
           NoBracketingException {
    if (function == null) {
        throw new NullArgumentException(LocalizedFormats.FUNCTION);
    }
    verifyInterval(lower, upper);
    if (!isBracketing(function, lower, upper)) {
        throw new NoBracketingException(lower, upper,
                                        function.value(lower),
                                        function.value(upper));
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:UnivariateSolverUtils.java

示例3: solve

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
/**
 * Solve for a zero in the given interval, start at {@code startValue}.
 * A solver may require that the interval brackets a single zero root.
 * Solvers that do require bracketing should be able to handle the case
 * where one of the endpoints is itself a root.
 *
 * @param maxEval Maximum number of evaluations.
 * @param f Function to solve.
 * @param min Lower bound for the interval.
 * @param max Upper bound for the interval.
 * @param startValue Start value to use.
 * @param allowedSolution The kind of solutions that the root-finding algorithm may
 * accept as solutions.
 * @return a value where the function is zero.
 * @exception NullArgumentException if f is null.
 * @exception NoBracketingException if root cannot be bracketed
 */
public Dfp solve(final int maxEval, final UnivariateDfpFunction f,
                 final Dfp min, final Dfp max, final Dfp startValue,
                 final AllowedSolution allowedSolution)
    throws NullArgumentException, NoBracketingException {

    // checks
    MathUtils.checkNotNull(f);

    // wrap the function
    RealFieldUnivariateFunction<Dfp> fieldF = new RealFieldUnivariateFunction<Dfp>() {

        /** {@inheritDoc} */
        public Dfp value(final Dfp x) {
            return f.value(x);
        }
    };

    // delegate to general field solver
    return solve(maxEval, fieldF, min, max, startValue, allowedSolution);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:39,代码来源:BracketingNthOrderBrentSolverDFP.java

示例4: testSmallLastStep

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testSmallLastStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

  TestProblemAbstract pb = new TestProblem5();
  double minStep = 1.25;
  double maxStep = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
  double scalAbsoluteTolerance = 6.0e-4;
  double scalRelativeTolerance = 6.0e-4;

  AdaptiveStepsizeIntegrator integ =
    new DormandPrince54Integrator(minStep, maxStep,
                                  scalAbsoluteTolerance,
                                  scalRelativeTolerance);

  DP54SmallLastHandler handler = new DP54SmallLastHandler(minStep);
  integ.addStepHandler(handler);
  integ.setInitialStepSize(1.7);
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);
  Assert.assertTrue(handler.wasLastSeen());
  Assert.assertEquals("Dormand-Prince 5(4)", integ.getName());

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:DormandPrince54IntegratorTest.java

示例5: doSolve

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Override
protected double doSolve() throws TooManyEvaluationsException, NoBracketingException {
    final double min = getMin();
    final double max = getMax();
    final double[] xSearchGrid = createHybridSearchGrid(min, max, numBisections, depth);
    final double[] fSearchGrid = Arrays.stream(xSearchGrid).map(this::computeObjectiveValue).toArray();

    /* find bracketing intervals on the search grid */
    final List<Bracket> bracketsList = detectBrackets(xSearchGrid, fSearchGrid);
    if (bracketsList.isEmpty()) {
        throw new NoBracketingException(min, max, fSearchGrid[0], fSearchGrid[fSearchGrid.length-1]);
    }
    final BrentSolver solver = new BrentSolver(getRelativeAccuracy(), getAbsoluteAccuracy(), getFunctionValueAccuracy());
    final List<Double> roots = bracketsList.stream()
            .map(b -> solver.solve(getMaxEvaluations(), this::computeObjectiveValue, b.min, b.max, 0.5 * (b.min + b.max)))
            .collect(Collectors.toList());
    if (roots.size() == 1 || meritFunc == null) {
        return roots.get(0);
    }
    final double[] merits = roots.stream().mapToDouble(meritFunc::value).toArray();
    final int bestRootIndex = IntStream.range(0, roots.size())
            .boxed()
            .max((i, j) -> (int) (merits[i] - merits[j]))
            .get();
    return roots.get(bestRootIndex);
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:27,代码来源:RobustBrentSolver.java

示例6: testKepler

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testKepler()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

  final TestProblem3 pb  = new TestProblem3(0.9);
  double minStep = 0;
  double maxStep = pb.getFinalTime() - pb.getInitialTime();
  double scalAbsoluteTolerance = 1.0e-8;
  double scalRelativeTolerance = scalAbsoluteTolerance;

  FirstOrderIntegrator integ = new DormandPrince54Integrator(minStep, maxStep,
                                                             scalAbsoluteTolerance,
                                                             scalRelativeTolerance);
  integ.addStepHandler(new KeplerHandler(pb));
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  Assert.assertEquals(integ.getEvaluations(), pb.getCalls());
  Assert.assertTrue(pb.getCalls() < 2800);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:24,代码来源:DormandPrince54IntegratorTest.java

示例7: testBigStep

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testBigStep()
        throws DimensionMismatchException, NumberIsTooSmallException,
        MaxCountExceededException, NoBracketingException {

    TestProblem1 pb = new TestProblem1();
    double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;

    FirstOrderIntegrator integ = new LutherIntegrator(step);
    TestProblemHandler handler = new TestProblemHandler(pb, integ);
    integ.addStepHandler(handler);
    integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                    pb.getFinalTime(), new double[pb.getDimension()]);

    Assert.assertTrue(handler.getLastError() > 0.00002);
    Assert.assertTrue(handler.getMaximalValueError() > 0.001);
    Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:LutherIntegratorTest.java

示例8: testBackward

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testBackward()
        throws DimensionMismatchException, NumberIsTooSmallException,
        MaxCountExceededException, NoBracketingException {

    TestProblem5 pb = new TestProblem5();
    double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;

    FirstOrderIntegrator integ = new LutherIntegrator(step);
    TestProblemHandler handler = new TestProblemHandler(pb, integ);
    integ.addStepHandler(handler);
    integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                    pb.getFinalTime(), new double[pb.getDimension()]);

    Assert.assertTrue(handler.getLastError() < 3.0e-13);
    Assert.assertTrue(handler.getMaximalValueError() < 5.0e-13);
    Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
    Assert.assertEquals("Luther", integ.getName());
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:LutherIntegratorTest.java

示例9: testSmallStep

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testSmallStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

  TestProblem1 pb  = new TestProblem1();
  double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;

  FirstOrderIntegrator integ = new MidpointIntegrator(step);
  TestProblemHandler handler = new TestProblemHandler(pb, integ);
  integ.addStepHandler(handler);
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  Assert.assertTrue(handler.getLastError() < 2.0e-7);
  Assert.assertTrue(handler.getMaximalValueError() < 1.0e-6);
  Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
  Assert.assertEquals("midpoint", integ.getName());

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:22,代码来源:MidpointIntegratorTest.java

示例10: testBigStep

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testBigStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

  TestProblem1 pb  = new TestProblem1();
  double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;

  FirstOrderIntegrator integ = new MidpointIntegrator(step);
  TestProblemHandler handler = new TestProblemHandler(pb, integ);
  integ.addStepHandler(handler);
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  Assert.assertTrue(handler.getLastError() > 0.01);
  Assert.assertTrue(handler.getMaximalValueError() > 0.05);
  Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:21,代码来源:MidpointIntegratorTest.java

示例11: testBackward

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testBackward()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

    TestProblem5 pb = new TestProblem5();
    double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;

    FirstOrderIntegrator integ = new MidpointIntegrator(step);
    TestProblemHandler handler = new TestProblemHandler(pb, integ);
    integ.addStepHandler(handler);
    integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                    pb.getFinalTime(), new double[pb.getDimension()]);

    Assert.assertTrue(handler.getLastError() < 6.0e-4);
    Assert.assertTrue(handler.getMaximalValueError() < 6.0e-4);
    Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
    Assert.assertEquals("midpoint", integ.getName());
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:MidpointIntegratorTest.java

示例12: testBigStep

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testBigStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

  TestProblem1 pb = new TestProblem1();
  double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;

  FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
  TestProblemHandler handler = new TestProblemHandler(pb, integ);
  integ.addStepHandler(handler);
  integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  Assert.assertTrue(handler.getLastError() > 0.0004);
  Assert.assertTrue(handler.getMaximalValueError() > 0.005);
  Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:ThreeEighthesIntegratorTest.java

示例13: testDecreasingSteps

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testDecreasingSteps()
    throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {

  double previousError = Double.NaN;
  for (int i = 0; i < 10; ++i) {

    double step  = FastMath.pow(2.0, -(i + 1));
    double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, step)
                 - FastMath.sin(4.0);
    if (i > 0) {
      Assert.assertTrue(FastMath.abs(error) < FastMath.abs(previousError));
    }
    previousError = error;

  }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:18,代码来源:FirstOrderConverterTest.java

示例14: testSmallStep

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testSmallStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

  TestProblem1 pb = new TestProblem1();
  double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;

  FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
  TestProblemHandler handler = new TestProblemHandler(pb, integ);
  integ.addStepHandler(handler);
  integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  Assert.assertTrue(handler.getLastError() < 2.0e-13);
  Assert.assertTrue(handler.getMaximalValueError() < 4.0e-12);
  Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
  Assert.assertEquals("classical Runge-Kutta", integ.getName());
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:ClassicalRungeKuttaIntegratorTest.java

示例15: testBigStep

import org.apache.commons.math3.exception.NoBracketingException; //导入依赖的package包/类
@Test
public void testBigStep()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {

  TestProblem1 pb = new TestProblem1();
  double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;

  FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
  TestProblemHandler handler = new TestProblemHandler(pb, integ);
  integ.addStepHandler(handler);
  integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  Assert.assertTrue(handler.getLastError() > 0.0004);
  Assert.assertTrue(handler.getMaximalValueError() > 0.005);
  Assert.assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:ClassicalRungeKuttaIntegratorTest.java


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