added a no-args constructor for GaussNewtonEstimator
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@745188 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4cc86649f4
commit
da9117b726
|
@ -34,10 +34,16 @@ import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
|
|||
*/
|
||||
public abstract class AbstractEstimator implements Estimator {
|
||||
|
||||
/** Default maximal number of cost evaluations allowed. */
|
||||
public static final int DEFAULT_MAX_COST_EVALUATIONS = 100;
|
||||
|
||||
/**
|
||||
* Build an abstract estimator for least squares problems.
|
||||
* <p>The maximal number of cost evaluations allowed is set
|
||||
* to its default value {@link #DEFAULT_MAX_COST_EVALUATIONS}.</p>
|
||||
*/
|
||||
protected AbstractEstimator() {
|
||||
setMaxCostEval(DEFAULT_MAX_COST_EVALUATIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,6 +40,34 @@ import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
|
|||
|
||||
public class GaussNewtonEstimator extends AbstractEstimator implements Serializable {
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = 5485001826076289109L;
|
||||
|
||||
/** Default threshold for cost steady state detection. */
|
||||
private static final double DEFAULT_STEADY_STATE_THRESHOLD = 1.0e-6;
|
||||
|
||||
/** Default threshold for cost convergence. */
|
||||
private static final double DEFAULT_CONVERGENCE = 1.0e-6;
|
||||
|
||||
/** Threshold for cost steady state detection. */
|
||||
private double steadyStateThreshold;
|
||||
|
||||
/** Threshold for cost convergence. */
|
||||
private double convergence;
|
||||
|
||||
/** Simple constructor with default settings.
|
||||
* <p>
|
||||
* The estimator is built with default values for all settings.
|
||||
* </p>
|
||||
* @see #DEFAULT_STEADY_STATE_THRESHOLD
|
||||
* @see #DEFAULT_CONVERGENCE
|
||||
* @see AbstractEstimator#DEFAULT_MAX_COST_EVALUATIONS
|
||||
*/
|
||||
public GaussNewtonEstimator() {
|
||||
this.steadyStateThreshold = DEFAULT_STEADY_STATE_THRESHOLD;
|
||||
this.convergence = DEFAULT_CONVERGENCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple constructor.
|
||||
*
|
||||
|
@ -66,19 +94,42 @@ public class GaussNewtonEstimator extends AbstractEstimator implements Serializa
|
|||
* to improve the criterion anymore
|
||||
* @param steadyStateThreshold steady state detection threshold, the
|
||||
* problem has converged has reached a steady state if
|
||||
* <code>Math.abs (Jn - Jn-1) < Jn * convergence</code>, where
|
||||
* <code>Jn</code> and <code>Jn-1</code> are the current and
|
||||
* preceding criterion value (square sum of the weighted residuals
|
||||
* of considered measurements).
|
||||
* <code>Math.abs(J<sub>n</sub> - J<sub>n-1</sub>) <
|
||||
* J<sub>n</sub> × convergence</code>, where <code>J<sub>n</sub></code>
|
||||
* and <code>J<sub>n-1</sub></code> are the current and preceding criterion
|
||||
* values (square sum of the weighted residuals of considered measurements).
|
||||
*/
|
||||
public GaussNewtonEstimator(int maxCostEval,
|
||||
double convergence,
|
||||
double steadyStateThreshold) {
|
||||
public GaussNewtonEstimator(final int maxCostEval, final double convergence,
|
||||
final double steadyStateThreshold) {
|
||||
setMaxCostEval(maxCostEval);
|
||||
this.steadyStateThreshold = steadyStateThreshold;
|
||||
this.convergence = convergence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the convergence criterion threshold.
|
||||
* @param convergence criterion threshold below which we do not need
|
||||
* to improve the criterion anymore
|
||||
*/
|
||||
public void setConvergence(final double convergence) {
|
||||
this.convergence = convergence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the steady state detection threshold.
|
||||
* <p>
|
||||
* The problem has converged has reached a steady state if
|
||||
* <code>Math.abs(J<sub>n</sub> - J<sub>n-1</sub>) <
|
||||
* J<sub>n</sub> × convergence</code>, where <code>J<sub>n</sub></code>
|
||||
* and <code>J<sub>n-1</sub></code> are the current and preceding criterion
|
||||
* values (square sum of the weighted residuals of considered measurements).
|
||||
* </p>
|
||||
* @param steadyStateThreshold steady state detection threshold
|
||||
*/
|
||||
public void setSteadyStateThreshold(final double steadyStateThreshold) {
|
||||
this.steadyStateThreshold = steadyStateThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Solve an estimation problem using a least squares criterion.
|
||||
*
|
||||
|
@ -92,7 +143,7 @@ public class GaussNewtonEstimator extends AbstractEstimator implements Serializa
|
|||
* below a physical threshold under which improvement are considered
|
||||
* useless or when the algorithm is unable to improve it (even if it
|
||||
* is still high). The first condition that is met stops the
|
||||
* iterations. If the convergence it nos reached before the maximum
|
||||
* iterations. If the convergence it not reached before the maximum
|
||||
* number of iterations, an {@link EstimationException} is
|
||||
* thrown.</p>
|
||||
*
|
||||
|
@ -172,13 +223,4 @@ public class GaussNewtonEstimator extends AbstractEstimator implements Serializa
|
|||
|
||||
}
|
||||
|
||||
/** Threshold for cost steady state detection. */
|
||||
private double steadyStateThreshold;
|
||||
|
||||
/** Threshold for cost convergence. */
|
||||
private double convergence;
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = 5485001826076289109L;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue