Example usage for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_OF_INTERPOLATION_POINTS

List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_OF_INTERPOLATION_POINTS

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_OF_INTERPOLATION_POINTS.

Prototype

LocalizedFormats NUMBER_OF_INTERPOLATION_POINTS

To view the source code for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_OF_INTERPOLATION_POINTS.

Click Source Link

Usage

From source file:com.itemanalysis.psychometrics.optimization.BOBYQAOptimizer.java

/**
 * Performs validity checks.//from   ww w.j a  v  a2 s .  co  m
 *
 * @param lowerBound Lower bounds (constraints) of the objective variables.
 * @param upperBound Upperer bounds (constraints) of the objective variables.
 */
private void setup(double[] lowerBound, double[] upperBound) {
    printMethod(); // XXX

    double[] init = getStartPoint();
    final int dimension = init.length;

    // Check problem dimension.
    if (dimension < MINIMUM_PROBLEM_DIMENSION) {
        throw new NumberIsTooSmallException(dimension, MINIMUM_PROBLEM_DIMENSION, true);
    }
    // Check number of interpolation points.
    final int[] nPointsInterval = { dimension + 2, (dimension + 2) * (dimension + 1) / 2 };
    if (numberOfInterpolationPoints < nPointsInterval[0] || numberOfInterpolationPoints > nPointsInterval[1]) {
        throw new OutOfRangeException(LocalizedFormats.NUMBER_OF_INTERPOLATION_POINTS,
                numberOfInterpolationPoints, nPointsInterval[0], nPointsInterval[1]);
    }

    // Initialize bound differences.
    boundDifference = new double[dimension];

    double requiredMinDiff = 2 * initialTrustRegionRadius;
    double minDiff = Double.POSITIVE_INFINITY;
    for (int i = 0; i < dimension; i++) {
        boundDifference[i] = upperBound[i] - lowerBound[i];
        minDiff = Math.min(minDiff, boundDifference[i]);
    }
    if (minDiff < requiredMinDiff) {
        initialTrustRegionRadius = minDiff / 3.0;
    }

    // Initialize the data structures used by the "bobyqa" method.
    bMatrix = new Array2DRowRealMatrix(dimension + numberOfInterpolationPoints, dimension);
    zMatrix = new Array2DRowRealMatrix(numberOfInterpolationPoints,
            numberOfInterpolationPoints - dimension - 1);
    interpolationPoints = new Array2DRowRealMatrix(numberOfInterpolationPoints, dimension);
    originShift = new ArrayRealVector(dimension);
    fAtInterpolationPoints = new ArrayRealVector(numberOfInterpolationPoints);
    trustRegionCenterOffset = new ArrayRealVector(dimension);
    gradientAtTrustRegionCenter = new ArrayRealVector(dimension);
    lowerDifference = new ArrayRealVector(dimension);
    upperDifference = new ArrayRealVector(dimension);
    modelSecondDerivativesParameters = new ArrayRealVector(numberOfInterpolationPoints);
    newPoint = new ArrayRealVector(dimension);
    alternativeNewPoint = new ArrayRealVector(dimension);
    trialStepPoint = new ArrayRealVector(dimension);
    lagrangeValuesAtNewPoint = new ArrayRealVector(dimension + numberOfInterpolationPoints);
    modelSecondDerivativesValues = new ArrayRealVector(dimension * (dimension + 1) / 2);
}