List of usage examples for org.apache.commons.math3.optim PointValuePair PointValuePair
public PointValuePair(final double[] point, final double value, final boolean copyArray)
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; }