levmar library

An implementation of the Levenberg-Marquardt method for solving non-linear least-squares minimisation problems

Author:

Usage notes

The library can be used either with or without an analytical Jacobian.

Unconstrained minimisation with analytic Jacobian
extern int dlevmar_der(
      void (*f)(double *p, double *hx, int m, int n, void *adata),
      void (*jacf)(double *p, double *j, int m, int n, void *adata),
      double *p, double *x, int m, int n, int itmax, double *opts,
      double *info, double *work, double *covar, void *adata);

ret = dlevmar_der(f, jacf, p, x, m, n, itmax,
                  opts, info, work, covar, adata);

where

void f(double *p, double *x, int m, int n, void *data)
/**
 * p is the parameter vector of length m
 * x is the measurement vector of length n
 *   (f evaluated at p is x)
 * data is unused (NULL)
 */
void (*jacf)(double *p, double *j, int m, int n, void *adata)
/**
 * p is the parameter vector of length m
 * j is the Jacobian vector (df/dp) of length n
 * adata is unused (NULL)
 */
/*
 * minim. options [\mu, \epsilon1, \epsilon2, \epsilon3].
 *
 * Respectively the scale factor for initial \mu,
 * stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2.
 *
 * Set to NULL for defaults to be used.
 *
 * Note that ||J^T e||_inf is computed on free (not equal
 * to lb[i] or ub[i]) variables only.
 */
/*
 * info[0]= ||e||_2 at initial p.
 *
 * info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2,
 *             mu/max[J^T J]_ii ], all computed at estimated p.
 *
 * info[5]= number of iterations,
 *
 * info[6]= reason for terminating:
 *          1 - stopped by small gradient J^T e
 *          2 - stopped by small Dp
 *          3 - stopped by itmax
 *          4 - singular matrix. Restart from current p with
 *              increased mu
 *          5 - no further error reduction is possible. Restart
 *              with increased mu
 *          6 - stopped by small ||e||_2
 *
 * info[7]= number of function evaluations
 *
 * info[8]= number of jacobian evaluations
 */
Unconstrained minimisation without analytic Jacobian
extern int dlevmar_dif(
      void (*func)(double *p, double *hx, int m, int n, void *adata),
      double *p, double *x, int m, int n, int itmax, double *opts,
      double *info, double *work, double *covar, void *adata);

ret = dlevmar_dif(f, p, x, m, n, 1000, opts, info,
                  NULL, NULL, NULL);

References

[KMHN04] K. Madsen, H.B. Nielsen and O. Tinglef. Methods for non-linear least squares problems. Technical report, Informatics and Mathematical Modelling, Technical University of Denmark, 4/2004.


sub-sahara africa
subrahaman
sahara trip IanKnot rainbow