Package org.ddogleg.optimization
Class GaussNewtonBase_F64<C extends ConfigGaussNewton,HM extends HessianMath>
java.lang.Object
org.ddogleg.optimization.GaussNewtonBase_F64<C,HM>
- Direct Known Subclasses:
LevenbergMarquardt_F64
,TrustRegionBase_F64
public abstract class GaussNewtonBase_F64<C extends ConfigGaussNewton,HM extends HessianMath>
extends Object
Base class for Gauss-Newton based approaches for unconstrained optimization.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptiondouble
double
Storage for the gradientdouble
protected DMatrixRMaj
protected GaussNewtonBase_F64.Mode
protected boolean
protected int
protected int
protected @Nullable PrintStream
protected int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Apply scaling to gradient and Hessianprotected boolean
Checks for convergence using f-test:protected void
Sets scaling to the sqrt() of the diagonal elements in the Hessian matrixvoid
computeHessianScaling
(DMatrixRMaj scaling) Applies the standard formula for computing scaling.double
Computes predicted reduction for step 'p'protected abstract boolean
Selects the next stepprotected abstract void
functionGradientHessian
(DMatrixRMaj x, boolean sameStateAsCost, DMatrixRMaj gradient, HM hessian) Computes the gradient and Hessian at 'x'.void
initialize
(double[] initial, int numberOfParameters) boolean
iterate()
Performs one iterationmode()
void
setVerbose
(@Nullable PrintStream out, int level) If set to a non-null output then extra information will be printed to the specified stream.protected void
Undo scaling on estimated parametersprotected abstract boolean
Computes all the derived data structures and attempts to update the parameters
-
Field Details
-
hessian
-
x
-
x_next
-
p
-
fx
public double fx -
gradient
Storage for the gradient -
sameStateAsCost
protected boolean sameStateAsCost -
hessianScaling
-
mode
-
totalFullSteps
protected int totalFullSteps -
totalSelectSteps
protected int totalSelectSteps -
verbose
-
verboseLevel
protected int verboseLevel -
config
-
ftest_val
public double ftest_val -
gtest_val
public double gtest_val
-
-
Constructor Details
-
GaussNewtonBase_F64
-
-
Method Details
-
initialize
public void initialize(double[] initial, int numberOfParameters) -
iterate
public boolean iterate()Performs one iteration- Returns:
- true if it has converged or false if not
-
updateDerivates
protected abstract boolean updateDerivates()Computes all the derived data structures and attempts to update the parameters- Returns:
- true if it has converged.
-
computeStep
protected abstract boolean computeStep()Selects the next step- Returns:
- true if it has converged.
-
computeHessianScaling
protected void computeHessianScaling()Sets scaling to the sqrt() of the diagonal elements in the Hessian matrix -
computeHessianScaling
Applies the standard formula for computing scaling. This is broken off into its own function so that it easily invoked if the function above is overridden- Parameters:
scaling
- Vector containing scaling information
-
applyHessianScaling
protected void applyHessianScaling()Apply scaling to gradient and Hessian -
undoHessianScalingOnParameters
Undo scaling on estimated parameters -
checkConvergenceGTest
Checks for convergence using f-test:
g-test : gtol ≤ ||g(x)||_inf- Returns:
- true if converged or false if it hasn't converged
-
functionGradientHessian
protected abstract void functionGradientHessian(DMatrixRMaj x, boolean sameStateAsCost, DMatrixRMaj gradient, HM hessian) Computes the gradient and Hessian at 'x'. If sameStateAsCost is true then it can be assumed that 'x' has not changed since the cost was last computed.- Parameters:
gradient
- (Input) xsameStateAsCost
- (Input) If true then when the cost (or residuals) was last called it had the same value of xgradient
- (Output) gradienthessian
- (Output) hessian
-
computePredictedReduction
Computes predicted reduction for step 'p'- Parameters:
p
- Change in state or the step- Returns:
- predicted reduction in quadratic model
-
mode
-
setVerbose
If set to a non-null output then extra information will be printed to the specified stream.- Parameters:
out
- Stream that is printed to. Set to null to disablelevel
- (Future use) Parameter which can be used to specify level of verbose output. Set to zero for now.
-