org.apache.commons.math.exception.MathIllegalStateException Java Examples

The following examples show how to use org.apache.commons.math.exception.MathIllegalStateException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Math_44_AbstractIntegrator_t.java    From coming with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
public double integrate(final FirstOrderDifferentialEquations equations,
                        final double t0, final double[] y0, final double t, final double[] y)
    throws MathIllegalStateException, MathIllegalArgumentException {

    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();

}
 
Example #2
Source File: Nopol2017_0071_t.java    From coming with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
public double integrate(final FirstOrderDifferentialEquations equations,
                        final double t0, final double[] y0, final double t, final double[] y)
    throws MathIllegalStateException, MathIllegalArgumentException {

    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();

}
 
Example #3
Source File: Nopol2017_0071_s.java    From coming with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
public double integrate(final FirstOrderDifferentialEquations equations,
                        final double t0, final double[] y0, final double t, final double[] y)
    throws MathIllegalStateException, MathIllegalArgumentException {

    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();

}
 
Example #4
Source File: Math_44_AbstractIntegrator_s.java    From coming with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
public double integrate(final FirstOrderDifferentialEquations equations,
                        final double t0, final double[] y0, final double t, final double[] y)
    throws MathIllegalStateException, MathIllegalArgumentException {

    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();

}
 
Example #5
Source File: MultiStartDifferentiableMultivariateVectorialOptimizerTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTrivial() {
    LinearProblem problem =
        new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
    DifferentiableMultivariateVectorialOptimizer underlyingOptimizer =
        new GaussNewtonOptimizer(true);
    JDKRandomGenerator g = new JDKRandomGenerator();
    g.setSeed(16069223052l);
    RandomVectorGenerator generator =
        new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
    MultiStartDifferentiableMultivariateVectorialOptimizer optimizer =
        new MultiStartDifferentiableMultivariateVectorialOptimizer(underlyingOptimizer,
                                                                   10, generator);
    optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));

    // no optima before first optimization attempt
    try {
        optimizer.getOptima();
        Assert.fail("an exception should have been thrown");
    } catch (MathIllegalStateException ise) {
        // expected
    }
    VectorialPointValuePair optimum =
        optimizer.optimize(100, problem, problem.target, new double[] { 1 }, new double[] { 0 });
    Assert.assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
    Assert.assertEquals(3.0, optimum.getValue()[0], 1.0e-10);
    VectorialPointValuePair[] optima = optimizer.getOptima();
    Assert.assertEquals(10, optima.length);
    for (int i = 0; i < optima.length; ++i) {
        Assert.assertEquals(1.5, optima[i].getPoint()[0], 1.0e-10);
        Assert.assertEquals(3.0, optima[i].getValue()[0], 1.0e-10);
    }
    Assert.assertTrue(optimizer.getEvaluations() > 20);
    Assert.assertTrue(optimizer.getEvaluations() < 50);
    Assert.assertEquals(100, optimizer.getMaxEvaluations());
}
 
Example #6
Source File: Array2DRowFieldMatrix.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void setSubMatrix(final T[][] subMatrix, final int row, final int column) {
    if (data == null) {
        if (row > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
        }
        if (column > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
        }
        final int nRows = subMatrix.length;
        if (nRows == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }

        final int nCols = subMatrix[0].length;
        if (nCols == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        data = buildArray(getField(), subMatrix.length, nCols);
        for (int i = 0; i < data.length; ++i) {
            if (subMatrix[i].length != nCols) {
                throw new DimensionMismatchException(nCols, subMatrix[i].length);
            }
            System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
        }
    } else {
        super.setSubMatrix(subMatrix, row, column);
    }

}
 
Example #7
Source File: Array2DRowRealMatrix.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void setSubMatrix(final double[][] subMatrix,
                         final int row, final int column) {
    if (data == null) {
        if (row > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
        }
        if (column > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
        }
        final int nRows = subMatrix.length;
        if (nRows == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }

        final int nCols = subMatrix[0].length;
        if (nCols == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        data = new double[subMatrix.length][nCols];
        for (int i = 0; i < data.length; ++i) {
            if (subMatrix[i].length != nCols) {
                throw new DimensionMismatchException(subMatrix[i].length, nCols);
            }
            System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
        }
    } else {
        super.setSubMatrix(subMatrix, row, column);
    }

}
 
Example #8
Source File: PolynomialSplineFunctionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
*  Do linear search to find largest knot point less than or equal to x.
*  Implementation does binary search.
*/
protected int findKnot(double[] knots, double x) {
    if (x < knots[0] || x >= knots[knots.length -1]) {
        throw new OutOfRangeException(x, knots[0], knots[knots.length -1]);
    }
    for (int i = 0; i < knots.length; i++) {
        if (knots[i] > x) {
            return i - 1;
        }
    }
    throw new MathIllegalStateException();
}
 
Example #9
Source File: NonLinearConjugateGradientOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find the upper bound b ensuring bracketing of a root between a and b
 * @param f function whose root must be bracketed
 * @param a lower bound of the interval
 * @param h initial step to try
 * @return b such that f(a) and f(b) have opposite signs
 * @exception FunctionEvaluationException if the function cannot be computed
 * @exception MathIllegalStateException if no bracket can be found
 * @deprecated in 2.2 (must be replaced with "BracketFinder").
 */
private double findUpperBound(final UnivariateRealFunction f,
                              final double a, final double h)
    throws FunctionEvaluationException {
    final double yA = f.value(a);
    double yB = yA;
    for (double step = h; step < Double.MAX_VALUE; step *= FastMath.max(2, yA / yB)) {
        final double b = a + step;
        yB = f.value(b);
        if (yA * yB <= 0) {
            return b;
        }
    }
    throw new MathIllegalStateException(LocalizedFormats.UNABLE_TO_BRACKET_OPTIMUM_IN_LINE_SEARCH);
}
 
Example #10
Source File: NonLinearConjugateGradientOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find the upper bound b ensuring bracketing of a root between a and b.
 *
 * @param f function whose root must be bracketed.
 * @param a lower bound of the interval.
 * @param h initial step to try.
 * @return b such that f(a) and f(b) have opposite signs.
 * @throws MathIllegalStateException if no bracket can be found.
 * @throws org.apache.commons.math.exception.MathUserException if the
 * function throws one.
 */
private double findUpperBound(final UnivariateRealFunction f,
                              final double a, final double h) {
    final double yA = f.value(a);
    double yB = yA;
    for (double step = h; step < Double.MAX_VALUE; step *= FastMath.max(2, yA / yB)) {
        final double b = a + step;
        yB = f.value(b);
        if (yA * yB <= 0) {
            return b;
        }
    }
    throw new MathIllegalStateException(LocalizedFormats.UNABLE_TO_BRACKET_OPTIMUM_IN_LINE_SEARCH);
}
 
Example #11
Source File: Array2DRowFieldMatrix.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void setSubMatrix(final T[][] subMatrix, final int row, final int column) {
    if (data == null) {
        if (row > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
        }
        if (column > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
        }
        final int nRows = subMatrix.length;
        if (nRows == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }

        final int nCols = subMatrix[0].length;
        if (nCols == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        data = buildArray(getField(), subMatrix.length, nCols);
        for (int i = 0; i < data.length; ++i) {
            if (subMatrix[i].length != nCols) {
                throw new DimensionMismatchException(nCols, subMatrix[i].length);
            }
            System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
        }
    } else {
        super.setSubMatrix(subMatrix, row, column);
    }

}
 
Example #12
Source File: Array2DRowRealMatrix.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void setSubMatrix(final double[][] subMatrix,
                         final int row, final int column) {
    if (data == null) {
        if (row > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
        }
        if (column > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
        }
        MathUtils.checkNotNull(subMatrix);
        final int nRows = subMatrix.length;
        if (nRows == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }

        final int nCols = subMatrix[0].length;
        if (nCols == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        data = new double[subMatrix.length][nCols];
        for (int i = 0; i < data.length; ++i) {
            if (subMatrix[i].length != nCols) {
                throw new DimensionMismatchException(subMatrix[i].length, nCols);
            }
            System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
        }
    } else {
        super.setSubMatrix(subMatrix, row, column);
    }

}
 
Example #13
Source File: RetryRunnerTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Shows that a test that sometimes fail might succeed if it is retried.
 * In this case the high number of retries makes it quite unlikely that
 * the exception will be thrown by all of the calls.
 */
@Test
@Retry(100)
public void testRetryFailSometimes() {
    if (rng.nextBoolean()) {
        throw new MathIllegalStateException();
    }
}
 
Example #14
Source File: MultiStartDifferentiableMultivariateVectorialOptimizerTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTrivial() {
    LinearProblem problem =
        new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
    DifferentiableMultivariateVectorialOptimizer underlyingOptimizer =
        new GaussNewtonOptimizer(true);
    JDKRandomGenerator g = new JDKRandomGenerator();
    g.setSeed(16069223052l);
    RandomVectorGenerator generator =
        new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
    MultiStartDifferentiableMultivariateVectorialOptimizer optimizer =
        new MultiStartDifferentiableMultivariateVectorialOptimizer(underlyingOptimizer,
                                                                   10, generator);
    optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));

    // no optima before first optimization attempt
    try {
        optimizer.getOptima();
        fail("an exception should have been thrown");
    } catch (MathIllegalStateException ise) {
        // expected
    }
    VectorialPointValuePair optimum =
        optimizer.optimize(100, problem, problem.target, new double[] { 1 }, new double[] { 0 });
    assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
    assertEquals(3.0, optimum.getValue()[0], 1.0e-10);
    VectorialPointValuePair[] optima = optimizer.getOptima();
    assertEquals(10, optima.length);
    for (int i = 0; i < optima.length; ++i) {
        assertEquals(1.5, optima[i].getPoint()[0], 1.0e-10);
        assertEquals(3.0, optima[i].getValue()[0], 1.0e-10);
    }
    assertTrue(optimizer.getEvaluations() > 20);
    assertTrue(optimizer.getEvaluations() < 50);
    assertEquals(100, optimizer.getMaxEvaluations());
}
 
Example #15
Source File: PolynomialSplineFunctionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
*  Do linear search to find largest knot point less than or equal to x.
*  Implementation does binary search.
*/
protected int findKnot(double[] knots, double x) {
    if (x < knots[0] || x >= knots[knots.length -1]) {
        throw new OutOfRangeException(x, knots[0], knots[knots.length -1]);
    }
    for (int i = 0; i < knots.length; i++) {
        if (knots[i] > x) {
            return i - 1;
        }
    }
    throw new MathIllegalStateException();
}
 
Example #16
Source File: NonLinearConjugateGradientOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find the upper bound b ensuring bracketing of a root between a and b.
 *
 * @param f function whose root must be bracketed.
 * @param a lower bound of the interval.
 * @param h initial step to try.
 * @return b such that f(a) and f(b) have opposite signs.
 * @throws MathIllegalStateException if no bracket can be found.
 * @throws org.apache.commons.math.exception.MathUserException if the
 * function throws one.
 */
private double findUpperBound(final UnivariateRealFunction f,
                              final double a, final double h) {
    final double yA = f.value(a);
    double yB = yA;
    for (double step = h; step < Double.MAX_VALUE; step *= FastMath.max(2, yA / yB)) {
        final double b = a + step;
        yB = f.value(b);
        if (yA * yB <= 0) {
            return b;
        }
    }
    throw new MathIllegalStateException(LocalizedFormats.UNABLE_TO_BRACKET_OPTIMUM_IN_LINE_SEARCH);
}
 
Example #17
Source File: Array2DRowFieldMatrix.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void setSubMatrix(final T[][] subMatrix, final int row, final int column) {
    if (data == null) {
        if (row > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
        }
        if (column > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
        }
        final int nRows = subMatrix.length;
        if (nRows == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }

        final int nCols = subMatrix[0].length;
        if (nCols == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        data = buildArray(getField(), subMatrix.length, nCols);
        for (int i = 0; i < data.length; ++i) {
            if (subMatrix[i].length != nCols) {
                throw new DimensionMismatchException(nCols, subMatrix[i].length);
            }
            System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
        }
    } else {
        super.setSubMatrix(subMatrix, row, column);
    }

}
 
Example #18
Source File: Array2DRowRealMatrix.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void setSubMatrix(final double[][] subMatrix,
                         final int row, final int column) {
    if (data == null) {
        if (row > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
        }
        if (column > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
        }
        MathUtils.checkNotNull(subMatrix);
        final int nRows = subMatrix.length;
        if (nRows == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }

        final int nCols = subMatrix[0].length;
        if (nCols == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        data = new double[subMatrix.length][nCols];
        for (int i = 0; i < data.length; ++i) {
            if (subMatrix[i].length != nCols) {
                throw new DimensionMismatchException(subMatrix[i].length, nCols);
            }
            System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
        }
    } else {
        super.setSubMatrix(subMatrix, row, column);
    }

}
 
Example #19
Source File: RetryRunnerTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Shows that a test that sometimes fail might succeed if it is retried.
 * In this case the high number of retries makes it quite unlikely that
 * the exception will be thrown by all of the calls.
 */
@Test
@Retry(100)
public void testRetryFailSometimes() {
    if (rng.nextBoolean()) {
        throw new MathIllegalStateException();
    }
}
 
Example #20
Source File: MultiStartDifferentiableMultivariateVectorialOptimizerTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTrivial() {
    LinearProblem problem =
        new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
    DifferentiableMultivariateVectorialOptimizer underlyingOptimizer =
        new GaussNewtonOptimizer(true);
    JDKRandomGenerator g = new JDKRandomGenerator();
    g.setSeed(16069223052l);
    RandomVectorGenerator generator =
        new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
    MultiStartDifferentiableMultivariateVectorialOptimizer optimizer =
        new MultiStartDifferentiableMultivariateVectorialOptimizer(underlyingOptimizer,
                                                                   10, generator);
    optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));

    // no optima before first optimization attempt
    try {
        optimizer.getOptima();
        Assert.fail("an exception should have been thrown");
    } catch (MathIllegalStateException ise) {
        // expected
    }
    VectorialPointValuePair optimum =
        optimizer.optimize(100, problem, problem.target, new double[] { 1 }, new double[] { 0 });
    Assert.assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
    Assert.assertEquals(3.0, optimum.getValue()[0], 1.0e-10);
    VectorialPointValuePair[] optima = optimizer.getOptima();
    Assert.assertEquals(10, optima.length);
    for (int i = 0; i < optima.length; ++i) {
        Assert.assertEquals(1.5, optima[i].getPoint()[0], 1.0e-10);
        Assert.assertEquals(3.0, optima[i].getValue()[0], 1.0e-10);
    }
    Assert.assertTrue(optimizer.getEvaluations() > 20);
    Assert.assertTrue(optimizer.getEvaluations() < 50);
    Assert.assertEquals(100, optimizer.getMaxEvaluations());
}
 
Example #21
Source File: PolynomialSplineFunctionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
*  Do linear search to find largest knot point less than or equal to x.
*  Implementation does binary search.
*/
protected int findKnot(double[] knots, double x) {
    if (x < knots[0] || x >= knots[knots.length -1]) {
        throw new OutOfRangeException(x, knots[0], knots[knots.length -1]);
    }
    for (int i = 0; i < knots.length; i++) {
        if (knots[i] > x) {
            return i - 1;
        }
    }
    throw new MathIllegalStateException();
}
 
Example #22
Source File: NonLinearConjugateGradientOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find the upper bound b ensuring bracketing of a root between a and b.
 *
 * @param f function whose root must be bracketed.
 * @param a lower bound of the interval.
 * @param h initial step to try.
 * @return b such that f(a) and f(b) have opposite signs.
 * @throws MathIllegalStateException if no bracket can be found.
 * @throws org.apache.commons.math.exception.MathUserException if the
 * function throws one.
 */
private double findUpperBound(final UnivariateRealFunction f,
                              final double a, final double h) {
    final double yA = f.value(a);
    double yB = yA;
    for (double step = h; step < Double.MAX_VALUE; step *= FastMath.max(2, yA / yB)) {
        final double b = a + step;
        yB = f.value(b);
        if (yA * yB <= 0) {
            return b;
        }
    }
    throw new MathIllegalStateException(LocalizedFormats.UNABLE_TO_BRACKET_OPTIMUM_IN_LINE_SEARCH);
}
 
Example #23
Source File: Math_43_SummaryStatistics_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Throws IllegalStateException if n > 0.
 */
private void checkEmpty() {
    if (n > 0) {
        throw new MathIllegalStateException(
            LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC, n);
    }
}
 
Example #24
Source File: Math_43_SummaryStatistics_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Throws IllegalStateException if n > 0.
 */
private void checkEmpty() {
    if (n > 0) {
        throw new MathIllegalStateException(
            LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC, n);
    }
}
 
Example #25
Source File: RetryRunnerTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Shows that an always failing test will fail even if it is retried.
 */
@Test(expected=MathIllegalStateException.class)
@Retry
public void testRetryFailAlways() {
    throw new MathIllegalStateException();
}
 
Example #26
Source File: Nopol2017_0067_s.java    From coming with MIT License 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public abstract void integrate (ExpandableStatefulODE equations, double t)
  throws MathIllegalStateException, MathIllegalArgumentException;
 
Example #27
Source File: Nopol2017_0067_t.java    From coming with MIT License 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public abstract void integrate (ExpandableStatefulODE equations, double t)
  throws MathIllegalStateException, MathIllegalArgumentException;
 
Example #28
Source File: RetryRunnerTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Shows that an always failing test will fail even if it is retried.
 */
@Test(expected=MathIllegalStateException.class)
@Retry
public void testRetryFailAlways() {
    throw new MathIllegalStateException();
}
 
Example #29
Source File: Math_62_MultiStartUnivariateRealOptimizer_t.java    From coming with MIT License 3 votes vote down vote up
/**
 * Get all the optima found during the last call to {@link
 * #optimize(FUNC,GoalType,double,double) optimize}.
 * The optimizer stores all the optima found during a set of
 * restarts. The {@link #optimize(FUNC,GoalType,double,double) optimize}
 * method returns the best point only. This method returns all the points
 * found at the end of each starts, including the best one already
 * returned by the {@link #optimize(FUNC,GoalType,double,double) optimize}
 * method.
 * <br/>
 * The returned array as one element for each start as specified
 * in the constructor. It is ordered with the results from the
 * runs that did converge first, sorted from best to worst
 * objective value (i.e in ascending order if minimizing and in
 * descending order if maximizing), followed by {@code null} elements
 * corresponding to the runs that did not converge. This means all
 * elements will be {@code null} if the {@link
 * #optimize(FUNC,GoalType,double,double) optimize} method did throw a
 * {@link ConvergenceException}). This also means that if the first
 * element is not {@code null}, it is the best point found across all
 * starts.
 *
 * @return an array containing the optima.
 * @throws MathIllegalStateException if {@link
 * #optimize(FUNC,GoalType,double,double) optimize} has not been called.
 */
public UnivariateRealPointValuePair[] getOptima() {
    if (optima == null) {
        throw new MathIllegalStateException(LocalizedFormats.NO_OPTIMUM_COMPUTED_YET);
    }
    return optima.clone();
}
 
Example #30
Source File: Cardumen_0052_s.java    From coming with MIT License 3 votes vote down vote up
/**
 * Get all the optima found during the last call to {@link
 * #optimize(FUNC,GoalType,double,double) optimize}.
 * The optimizer stores all the optima found during a set of
 * restarts. The {@link #optimize(FUNC,GoalType,double,double) optimize}
 * method returns the best point only. This method returns all the points
 * found at the end of each starts, including the best one already
 * returned by the {@link #optimize(FUNC,GoalType,double,double) optimize}
 * method.
 * <br/>
 * The returned array as one element for each start as specified
 * in the constructor. It is ordered with the results from the
 * runs that did converge first, sorted from best to worst
 * objective value (i.e in ascending order if minimizing and in
 * descending order if maximizing), followed by {@code null} elements
 * corresponding to the runs that did not converge. This means all
 * elements will be {@code null} if the {@link
 * #optimize(FUNC,GoalType,double,double) optimize} method did throw a
 * {@link ConvergenceException}). This also means that if the first
 * element is not {@code null}, it is the best point found across all
 * starts.
 *
 * @return an array containing the optima.
 * @throws MathIllegalStateException if {@link
 * #optimize(FUNC,GoalType,double,double) optimize} has not been called.
 */
public UnivariateRealPointValuePair[] getOptima() {
    if (optima == null) {
        throw new MathIllegalStateException(LocalizedFormats.NO_OPTIMUM_COMPUTED_YET);
    }
    return optima.clone();
}