Example usage for org.apache.commons.math3.optimization PointValuePair getPointRef

List of usage examples for org.apache.commons.math3.optimization PointValuePair getPointRef

Introduction

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

Prototype

public double[] getPointRef() 

Source Link

Document

Gets a reference to the point.

Usage

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

/** {@inheritDoc} */
@Override/*from www  .j  a  va  2  s.  co m*/
public PointValuePair optimize(int maxEval, DifferentiableMultivariateFunction f, GoalType goalType,
        double[] initial) {
    Preconditions.checkArgument(maxEval > 0);
    Preconditions.checkNotNull(f);
    Preconditions.checkNotNull(goalType);
    Preconditions.checkNotNull(initial);

    // FIXME : goalType is being ignored!

    Updater updater = Updater.newUpdater(f);

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

    evaluations = 1;
    do {
        prev = next;
        double[] x = prev.getPointRef();
        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;
}