You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2014/02/18 15:33:14 UTC
svn commit: r1569357 - in
/commons/proper/math/trunk/src/main/java/org/apache/commons/math3:
fitting/leastsquares/ optim/
Author: luc
Date: Tue Feb 18 14:33:14 2014
New Revision: 1569357
URL: http://svn.apache.org/r1569357
Log:
Fix Javadoc and checkstyle errors.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimizationProblem.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/AbstractOptimizationProblem.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java?rev=1569357&r1=1569356&r2=1569357&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java Tue Feb 18 14:33:14 2014
@@ -119,6 +119,7 @@ public class GaussNewtonOptimizer implem
return new GaussNewtonOptimizer(decomposition);
}
+ /** {@inheritDoc} */
public Optimum optimize(final LeastSquaresProblem lsp) {
//create local evaluation and iteration counts
final Incrementor evaluationCounter = lsp.getEvaluationCounter();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java?rev=1569357&r1=1569356&r2=1569357&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java Tue Feb 18 14:33:14 2014
@@ -41,6 +41,16 @@ class LeastSquaresProblemImpl
/** Initial guess. */
private RealVector start;
+ /**
+ * Create a {@link LeastSquaresProblem} from the given data.
+ *
+ * @param model the model function
+ * @param target the observed data
+ * @param start the initial guess
+ * @param checker the convergence checker
+ * @param maxEvaluations the allowed evaluations
+ * @param maxIterations the allowed iterations
+ */
LeastSquaresProblemImpl(final MultivariateJacobianFunction model,
final RealVector target,
final RealVector start,
@@ -53,18 +63,22 @@ class LeastSquaresProblemImpl
this.start = start;
}
+ /** {@inheritDoc} */
public int getObservationSize() {
return target.getDimension();
}
+ /** {@inheritDoc} */
public int getParameterSize() {
return start.getDimension();
}
+ /** {@inheritDoc} */
public RealVector getStart() {
return start == null ? null : start.copy();
}
+ /** {@inheritDoc} */
public Evaluation evaluate(final RealVector point) {
//evaluate value and jacobian in one function call
final Pair<RealVector, RealMatrix> value = this.model.value(point);
@@ -91,6 +105,14 @@ class LeastSquaresProblemImpl
/** reference to the observed values */
private final RealVector target;
+ /**
+ * Create an {@link Evaluation} with no weights.
+ *
+ * @param values the computed function values
+ * @param jacobian the computed function Jacobian
+ * @param target the observed values
+ * @param point the abscissa
+ */
private UnweightedEvaluation(final RealVector values,
final RealMatrix jacobian,
final RealVector target,
@@ -102,19 +124,22 @@ class LeastSquaresProblemImpl
this.point = point;
}
-
+ /** {@inheritDoc} */
public RealVector computeValue() {
return this.values;
}
+ /** {@inheritDoc} */
public RealMatrix computeJacobian() {
return this.jacobian;
}
+ /** {@inheritDoc} */
public RealVector getPoint() {
return this.point;
}
+ /** {@inheritDoc} */
public RealVector computeResiduals() {
return target.subtract(this.computeValue());
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimizationProblem.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimizationProblem.java?rev=1569357&r1=1569356&r2=1569357&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimizationProblem.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimizationProblem.java Tue Feb 18 14:33:14 2014
@@ -3,19 +3,27 @@ package org.apache.commons.math3.fitting
import org.apache.commons.math3.optim.ConvergenceChecker;
import org.apache.commons.math3.util.Incrementor;
-/** @author Evan Ward */
+/**
+ * Common settings for all optimization problems. Includes divergence and convergence
+ * criteria.
+ *
+ * @param <PAIR> The type of value the {@link #getConvergenceChecker() convergence
+ * checker} will operate on. It should include the value of the model
+ * function and point where it was evaluated.
+ * @version $Id$
+ */
public interface OptimizationProblem<PAIR> {
/**
- * Get a independent Incrementor that counts up to {@link #getMaxEvaluations()} and
- * then throws an exception.
+ * Get a independent Incrementor that counts up to the maximum number of evaluations
+ * and then throws an exception.
*
* @return a counter for the evaluations.
*/
Incrementor getEvaluationCounter();
/**
- * Get a independent Incrementor that counts up to {@link #getMaxIterations()} and
- * then throws an exception.
+ * Get a independent Incrementor that counts up to the maximum number of iterations
+ * and then throws an exception.
*
* @return a counter for the evaluations.
*/
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/AbstractOptimizationProblem.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/AbstractOptimizationProblem.java?rev=1569357&r1=1569356&r2=1569357&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/AbstractOptimizationProblem.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/AbstractOptimizationProblem.java Tue Feb 18 14:33:14 2014
@@ -22,44 +22,55 @@ import org.apache.commons.math3.fitting.
import org.apache.commons.math3.util.Incrementor;
/**
- * Base class for implementing optimizers. It contains the boiler-plate code for counting
- * the number of evaluations of the objective function and the number of iterations of the
- * algorithm, and storing the convergence checker.
+ * Base class for implementing optimization problems. It contains the boiler-plate code
+ * for counting the number of evaluations of the objective function and the number of
+ * iterations of the algorithm, and storing the convergence checker.
*
- * @param <PAIR> Type of the point/value pair returned by the optimization algorithm.
- * @param <OPTIM> Type of a subclass of this class. This parameter allows to implement
- * fluent API methods at upper levels of the class hierarchy (since the
- * fluent API requires that the actual type of the subclass is returned).
+ * @param <PAIR> Type of the point/value pair returned by the optimization algorithm.
* @version $Id$
* @since 3.3
*/
public abstract class AbstractOptimizationProblem<PAIR>
implements OptimizationProblem<PAIR> {
+ /** Callback to use for the evaluation counter. */
+ private static final MaxEvalCallback MAX_EVAL_CALLBACK = new MaxEvalCallback();
+ /** Callback to use for the iteration counter. */
+ private static final MaxIterCallback MAX_ITER_CALLBACK = new MaxIterCallback();
+
/** max evaluations */
private final int maxEvaluations;
/** max iterations */
private final int maxIterations;
/** Convergence checker. */
- private ConvergenceChecker<PAIR> checker = null;
+ private final ConvergenceChecker<PAIR> checker;
+ /**
+ * Create an {@link AbstractOptimizationProblem} from the given data.
+ *
+ * @param maxEvaluations the number of allowed model function evaluations.
+ * @param maxIterations the number of allowed iterations.
+ * @param checker the convergence checker.
+ */
+ protected AbstractOptimizationProblem(final int maxEvaluations,
+ final int maxIterations,
+ final ConvergenceChecker<PAIR> checker) {
+ this.maxEvaluations = maxEvaluations;
+ this.maxIterations = maxIterations;
+ this.checker = checker;
+ }
+ /** {@inheritDoc} */
public Incrementor getEvaluationCounter() {
return new Incrementor(this.maxEvaluations, MAX_EVAL_CALLBACK);
}
+ /** {@inheritDoc} */
public Incrementor getIterationCounter() {
return new Incrementor(this.maxIterations, MAX_ITER_CALLBACK);
}
- protected AbstractOptimizationProblem(final int maxEvaluations,
- final int maxIterations,
- final ConvergenceChecker<PAIR> checker) {
- this.maxEvaluations = maxEvaluations;
- this.maxIterations = maxIterations;
- this.checker = checker;
- }
-
+ /** {@inheritDoc} */
public ConvergenceChecker<PAIR> getConvergenceChecker() {
return checker;
}
@@ -77,8 +88,6 @@ public abstract class AbstractOptimizati
}
}
- private static final MaxEvalCallback MAX_EVAL_CALLBACK = new MaxEvalCallback();
-
/** Defines the action to perform when reaching the maximum number of evaluations. */
private static class MaxIterCallback
implements Incrementor.MaxCountExceededCallback {
@@ -92,5 +101,4 @@ public abstract class AbstractOptimizati
}
}
- private static final MaxIterCallback MAX_ITER_CALLBACK = new MaxIterCallback();
}