Search in sources :

Example 1 with MathUnsupportedOperationException

use of org.apache.commons.math3.exception.MathUnsupportedOperationException in project GDSC-SMLM by aherbert.

the class BFGSOptimizer method checkParameters.

/**
	 * Checks if there are lower or upper bounds that are not -Infinity or +Infinity
	 * 
	 * @throws MathUnsupportedOperationException
	 *             if invalid bounds were passed to the {@link #optimize(OptimizationData[]) optimize} method.
	 */
private void checkParameters() {
    lower = getLowerBound();
    upper = getUpperBound();
    isLower = checkArray(lower, Double.NEGATIVE_INFINITY);
    isUpper = checkArray(upper, Double.POSITIVE_INFINITY);
    // Check that the upper bound is above the lower bound
    if (isUpper && isLower) {
        for (int i = 0; i < lower.length; i++) if (lower[i] > upper[i])
            throw new MathUnsupportedOperationException(createError("Lower bound must be below upper bound"));
    }
    // Numerical Recipes set the position convergence very low
    if (positionChecker == null)
        positionChecker = new PositionChecker(4 * epsilon, 0);
    // Ensure that the step length is strictly positive
    if (maximumStepLength == null) {
        for (int i = 0; i < maximumStepLength.length; i++) {
            if (maximumStepLength[i] <= 0)
                throw new MathUnsupportedOperationException(createError("Maximum step length must be strictly positive"));
        }
    }
// Set a tolerance? If not then the routine will iterate until position convergence
//if (gradientTolerance == 0)
//	gradientTolerance = 1e-6;
}
Also used : PositionChecker(org.apache.commons.math3.optim.PositionChecker) MathUnsupportedOperationException(org.apache.commons.math3.exception.MathUnsupportedOperationException)

Aggregations

MathUnsupportedOperationException (org.apache.commons.math3.exception.MathUnsupportedOperationException)1 PositionChecker (org.apache.commons.math3.optim.PositionChecker)1