Example usage for org.apache.commons.math3.optimization.univariate UnivariatePointValuePair getValue

List of usage examples for org.apache.commons.math3.optimization.univariate UnivariatePointValuePair getValue

Introduction

In this page you can find the example usage for org.apache.commons.math3.optimization.univariate UnivariatePointValuePair getValue.

Prototype

public double getValue() 

Source Link

Document

Get the value of the objective function.

Usage

From source file:edu.byu.nlp.math.optimize.UnivariateNewtonRaphson.java

/** {@inheritDoc} */
@Override/*from ww  w  . java  2  s  .c o m*/
public UnivariatePointValuePair optimize(int maxEval, DifferentiableUnivariateFunction f, GoalType goalType,
        double initial, double arg4) {
    Preconditions.checkArgument(maxEval > 0);
    Preconditions.checkNotNull(f);
    Preconditions.checkNotNull(goalType);
    Preconditions.checkNotNull(initial);

    // FIXME : goalType is being ignored!

    Updater updater = Updater.newUpdater(f);

    UnivariatePointValuePair prev = null;
    UnivariatePointValuePair next = updater.update(initial);
    logger.info(String.format("Iteration 0, value = %f", next.getValue()));

    evaluations = 1;
    do {
        prev = next;
        double x = prev.getPoint();
        next = updater.update(x);
        ++evaluations;
        logger.info(String.format("Iteration %d, value = %f", evaluations, next.getValue()));
    } while (!convergenceChecker.converged(evaluations, prev, next) && evaluations < maxEval
            && evaluations < maxEvaluations);

    return next;
}