Skip to content

Commit c7c7cd9

Browse files
committed
Fix Javadoc and checkstyle errors.
1 parent 02c3002 commit c7c7cd9

4 files changed

Lines changed: 67 additions & 25 deletions

File tree

src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public GaussNewtonOptimizer withDecomposition(final Decomposition decomposition)
119119
return new GaussNewtonOptimizer(decomposition);
120120
}
121121

122+
/** {@inheritDoc} */
122123
public Optimum optimize(final LeastSquaresProblem lsp) {
123124
//create local evaluation and iteration counts
124125
final Incrementor evaluationCounter = lsp.getEvaluationCounter();

src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ class LeastSquaresProblemImpl
4141
/** Initial guess. */
4242
private RealVector start;
4343

44+
/**
45+
* Create a {@link LeastSquaresProblem} from the given data.
46+
*
47+
* @param model the model function
48+
* @param target the observed data
49+
* @param start the initial guess
50+
* @param checker the convergence checker
51+
* @param maxEvaluations the allowed evaluations
52+
* @param maxIterations the allowed iterations
53+
*/
4454
LeastSquaresProblemImpl(final MultivariateJacobianFunction model,
4555
final RealVector target,
4656
final RealVector start,
@@ -53,18 +63,22 @@ class LeastSquaresProblemImpl
5363
this.start = start;
5464
}
5565

66+
/** {@inheritDoc} */
5667
public int getObservationSize() {
5768
return target.getDimension();
5869
}
5970

71+
/** {@inheritDoc} */
6072
public int getParameterSize() {
6173
return start.getDimension();
6274
}
6375

76+
/** {@inheritDoc} */
6477
public RealVector getStart() {
6578
return start == null ? null : start.copy();
6679
}
6780

81+
/** {@inheritDoc} */
6882
public Evaluation evaluate(final RealVector point) {
6983
//evaluate value and jacobian in one function call
7084
final Pair<RealVector, RealMatrix> value = this.model.value(point);
@@ -91,6 +105,14 @@ private static class UnweightedEvaluation extends AbstractEvaluation {
91105
/** reference to the observed values */
92106
private final RealVector target;
93107

108+
/**
109+
* Create an {@link Evaluation} with no weights.
110+
*
111+
* @param values the computed function values
112+
* @param jacobian the computed function Jacobian
113+
* @param target the observed values
114+
* @param point the abscissa
115+
*/
94116
private UnweightedEvaluation(final RealVector values,
95117
final RealMatrix jacobian,
96118
final RealVector target,
@@ -102,19 +124,22 @@ private UnweightedEvaluation(final RealVector values,
102124
this.point = point;
103125
}
104126

105-
127+
/** {@inheritDoc} */
106128
public RealVector computeValue() {
107129
return this.values;
108130
}
109131

132+
/** {@inheritDoc} */
110133
public RealMatrix computeJacobian() {
111134
return this.jacobian;
112135
}
113136

137+
/** {@inheritDoc} */
114138
public RealVector getPoint() {
115139
return this.point;
116140
}
117141

142+
/** {@inheritDoc} */
118143
public RealVector computeResiduals() {
119144
return target.subtract(this.computeValue());
120145
}

src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimizationProblem.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,27 @@
33
import org.apache.commons.math3.optim.ConvergenceChecker;
44
import org.apache.commons.math3.util.Incrementor;
55

6-
/** @author Evan Ward */
6+
/**
7+
* Common settings for all optimization problems. Includes divergence and convergence
8+
* criteria.
9+
*
10+
* @param <PAIR> The type of value the {@link #getConvergenceChecker() convergence
11+
* checker} will operate on. It should include the value of the model
12+
* function and point where it was evaluated.
13+
* @version $Id$
14+
*/
715
public interface OptimizationProblem<PAIR> {
816
/**
9-
* Get a independent Incrementor that counts up to {@link #getMaxEvaluations()} and
10-
* then throws an exception.
17+
* Get a independent Incrementor that counts up to the maximum number of evaluations
18+
* and then throws an exception.
1119
*
1220
* @return a counter for the evaluations.
1321
*/
1422
Incrementor getEvaluationCounter();
1523

1624
/**
17-
* Get a independent Incrementor that counts up to {@link #getMaxIterations()} and
18-
* then throws an exception.
25+
* Get a independent Incrementor that counts up to the maximum number of iterations
26+
* and then throws an exception.
1927
*
2028
* @return a counter for the evaluations.
2129
*/

src/main/java/org/apache/commons/math3/optim/AbstractOptimizationProblem.java

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,55 @@
2222
import org.apache.commons.math3.util.Incrementor;
2323

2424
/**
25-
* Base class for implementing optimizers. It contains the boiler-plate code for counting
26-
* the number of evaluations of the objective function and the number of iterations of the
27-
* algorithm, and storing the convergence checker.
25+
* Base class for implementing optimization problems. It contains the boiler-plate code
26+
* for counting the number of evaluations of the objective function and the number of
27+
* iterations of the algorithm, and storing the convergence checker.
2828
*
29-
* @param <PAIR> Type of the point/value pair returned by the optimization algorithm.
30-
* @param <OPTIM> Type of a subclass of this class. This parameter allows to implement
31-
* fluent API methods at upper levels of the class hierarchy (since the
32-
* fluent API requires that the actual type of the subclass is returned).
29+
* @param <PAIR> Type of the point/value pair returned by the optimization algorithm.
3330
* @version $Id$
3431
* @since 3.3
3532
*/
3633
public abstract class AbstractOptimizationProblem<PAIR>
3734
implements OptimizationProblem<PAIR> {
3835

36+
/** Callback to use for the evaluation counter. */
37+
private static final MaxEvalCallback MAX_EVAL_CALLBACK = new MaxEvalCallback();
38+
/** Callback to use for the iteration counter. */
39+
private static final MaxIterCallback MAX_ITER_CALLBACK = new MaxIterCallback();
40+
3941
/** max evaluations */
4042
private final int maxEvaluations;
4143
/** max iterations */
4244
private final int maxIterations;
4345
/** Convergence checker. */
44-
private ConvergenceChecker<PAIR> checker = null;
46+
private final ConvergenceChecker<PAIR> checker;
4547

48+
/**
49+
* Create an {@link AbstractOptimizationProblem} from the given data.
50+
*
51+
* @param maxEvaluations the number of allowed model function evaluations.
52+
* @param maxIterations the number of allowed iterations.
53+
* @param checker the convergence checker.
54+
*/
55+
protected AbstractOptimizationProblem(final int maxEvaluations,
56+
final int maxIterations,
57+
final ConvergenceChecker<PAIR> checker) {
58+
this.maxEvaluations = maxEvaluations;
59+
this.maxIterations = maxIterations;
60+
this.checker = checker;
61+
}
4662

63+
/** {@inheritDoc} */
4764
public Incrementor getEvaluationCounter() {
4865
return new Incrementor(this.maxEvaluations, MAX_EVAL_CALLBACK);
4966
}
5067

68+
/** {@inheritDoc} */
5169
public Incrementor getIterationCounter() {
5270
return new Incrementor(this.maxIterations, MAX_ITER_CALLBACK);
5371
}
5472

55-
protected AbstractOptimizationProblem(final int maxEvaluations,
56-
final int maxIterations,
57-
final ConvergenceChecker<PAIR> checker) {
58-
this.maxEvaluations = maxEvaluations;
59-
this.maxIterations = maxIterations;
60-
this.checker = checker;
61-
}
62-
73+
/** {@inheritDoc} */
6374
public ConvergenceChecker<PAIR> getConvergenceChecker() {
6475
return checker;
6576
}
@@ -77,8 +88,6 @@ public void trigger(int max) {
7788
}
7889
}
7990

80-
private static final MaxEvalCallback MAX_EVAL_CALLBACK = new MaxEvalCallback();
81-
8291
/** Defines the action to perform when reaching the maximum number of evaluations. */
8392
private static class MaxIterCallback
8493
implements Incrementor.MaxCountExceededCallback {
@@ -92,5 +101,4 @@ public void trigger(int max) {
92101
}
93102
}
94103

95-
private static final MaxIterCallback MAX_ITER_CALLBACK = new MaxIterCallback();
96104
}

0 commit comments

Comments
 (0)