Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#NUMBER_OF_INTERPOLATION_POINTS

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#NUMBER_OF_INTERPOLATION_POINTS . 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: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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 = FastMath.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);
}
 
Example 2
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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 = FastMath.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);
}
 
Example 3
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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);
}
 
Example 4
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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);
}
 
Example 5
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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);
}
 
Example 6
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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);
}
 
Example 7
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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);
}
 
Example 8
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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);
}
 
Example 9
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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);
}
 
Example 10
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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);
}
 
Example 11
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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);
}
 
Example 12
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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 = FastMath.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);
}
 
Example 13
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs validity checks.
 *
 * @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 = FastMath.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);
}