Example usage for org.apache.commons.math3.optim PointValuePair PointValuePair

List of usage examples for org.apache.commons.math3.optim PointValuePair PointValuePair

Introduction

In this page you can find the example usage for org.apache.commons.math3.optim PointValuePair PointValuePair.

Prototype

public PointValuePair(final double[] point, final double value, final boolean copyArray) 

Source Link

Document

Builds a point/objective function value pair.

Usage

From source file:com.wwidesigner.math.DIRECTOptimizer.java

/** {@inheritDoc} */
@Override/* w w  w.  ja v a  2  s  . c om*/
protected PointValuePair doOptimize() {
    currentBest = new PointValuePair(getStartPoint(), Double.MAX_VALUE, true);
    iterationOfLastImprovement = 0;
    int nrPromising;

    // Validity checks.
    setup();

    double convergenceDiameter = thresholdDiameter(convergenceXThreshold, boundDifference.length);

    do {
        incrementIterationCount();
        nrPromising = dividePotentiallyOptimal(convergenceDiameter);
    } while (!hasConverged(nrPromising));

    if (getGoalType() == GoalType.MAXIMIZE) {
        return new PointValuePair(currentBest.getPoint(), -currentBest.getValue());
    }

    return currentBest;
}

From source file:com.wwidesigner.math.DIRECTOptimizer.java

/** {@inheritDoc} */
@Override//from  w  w  w .j  a  v a  2s.  c o  m
public double computeObjectiveValue(double[] params) {
    double fval;
    try {
        fval = super.computeObjectiveValue(params);
        if (getGoalType() == GoalType.MAXIMIZE) {
            fval = -fval;
        }
        if (fval < currentBest.getValue()) {
            currentBest = new PointValuePair(params, fval, true);
            iterationOfLastImprovement = getIterations();
        }
        if (fval > fMax) {
            fMax = fval;
        }
    } catch (NoSuchElementException e) {
        fval = fMax;
    }
    return fval;
}