public interface UnconstrainedLeastSquares<S extends DMatrix> extends IterativeOptimization
Non-linear least squares problems have a special structure which can be taken advantage of for optimization.
The least squares problem is defined below:
F(x) = 0.5*sum( i=1:M ; fi(x)2 )
where fi(x) is a function from ℜN to ℜ. M is number of functions, and N is number of fit parameters. M ≥ N
fi(x) = observed - predicted, which is known as the residual error.
F-Test: ftol ≤ 1 - f(x+p)/f(x)
G-Test: gtol ≤ ||g(x)||inf
An absolute f-test can be done by checking the value of
getFunctionValue() in each iteration.
NOTE: The function computes the M outputs of the fi(x), residual error functions, NOT [fi(x)]2
Input functions are specified using
FunctionNtoM for the set of M
FunctionNtoMxN for the Jacobian. The function's output is a vector of length M,
where element i correspond to function i's output. The Jacobian is an array containing the partial
derivatives of each function. Element J(i,j) corresponds to the partial of function i and parameter j.
The array is stored in a row major format. The partial for F(i,j) would be stored at index = i*N+j in the data array.
NOTE: If you need to modify the optimization parameters this can be done inside the 'function'.
|Modifier and Type||Method and Description|
Returns the value of the objective function being evaluated at the current parameters value.
After each iteration this function can be called to get the current best set of parameters.
Specify the initial set of parameters from which to start from.
Specifies a set of functions and their Jacobian.
void setFunction(FunctionNtoM function, FunctionNtoMxN<S> jacobian)
function- Computes the output of M functions fi(x) which take in N fit parameters as input.
jacobian- Computes the Jacobian of the M functions. If null a numerical Jacobian will be used.
void initialize(double initial, double ftol, double gtol)
setFunction(org.ddogleg.optimization.functions.FunctionNtoM, org.ddogleg.optimization.functions.FunctionNtoMxN<S>)has been called.
initial- Initial parameters or guess with N elements..
ftol- Relative threshold for change in function value between iterations. 0 ≤ ftol ≤ 1. Try 1e-12
gtol- Absolute threshold for convergence based on the gradient's norm. 0 disables test. 0 ≤ gtol. Try 1e-12