Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/eigen3/unsupported/Eigen/NonLinearOptimization is written in an unsupported language. File is not indexed.

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2009 Thomas Capricelli <orzel@freehackers.org>
0005 //
0006 // This Source Code Form is subject to the terms of the Mozilla
0007 // Public License v. 2.0. If a copy of the MPL was not distributed
0008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0009 
0010 #ifndef EIGEN_NONLINEAROPTIMIZATION_MODULE
0011 #define EIGEN_NONLINEAROPTIMIZATION_MODULE
0012 
0013 #include <vector>
0014 
0015 #include "../../Eigen/Core"
0016 #include "../../Eigen/Jacobi"
0017 #include "../../Eigen/QR"
0018 #include "NumericalDiff"
0019 
0020 /**
0021   * \defgroup NonLinearOptimization_Module Non linear optimization module
0022   *
0023   * \code
0024   * #include <unsupported/Eigen/NonLinearOptimization>
0025   * \endcode
0026   *
0027   * This module provides implementation of two important algorithms in non linear
0028   * optimization. In both cases, we consider a system of non linear functions. Of
0029   * course, this should work, and even work very well if those functions are
0030   * actually linear. But if this is so, you should probably better use other
0031   * methods more fitted to this special case.
0032   *
0033   * One algorithm allows to find a least-squares solution of such a system
0034   * (Levenberg-Marquardt algorithm) and the second one is used to find 
0035   * a zero for the system (Powell hybrid "dogleg" method).
0036   *
0037   * This code is a port of minpack (http://en.wikipedia.org/wiki/MINPACK).
0038   * Minpack is a very famous, old, robust and well renowned package, written in
0039   * fortran. Those implementations have been carefully tuned, tested, and used
0040   * for several decades.
0041   *
0042   * The original fortran code was automatically translated using f2c (http://en.wikipedia.org/wiki/F2c) in C,
0043   * then c++, and then cleaned by several different authors.
0044   * The last one of those cleanings being our starting point : 
0045   * http://devernay.free.fr/hacks/cminpack.html
0046   * 
0047   * Finally, we ported this code to Eigen, creating classes and API
0048   * coherent with Eigen. When possible, we switched to Eigen
0049   * implementation, such as most linear algebra (vectors, matrices, stable norms).
0050   *
0051   * Doing so, we were very careful to check the tests we setup at the very
0052   * beginning, which ensure that the same results are found.
0053   *
0054   * \section Tests Tests
0055   * 
0056   * The tests are placed in the file unsupported/test/NonLinear.cpp.
0057   * 
0058   * There are two kinds of tests : those that come from examples bundled with cminpack.
0059   * They guaranty we get the same results as the original algorithms (value for 'x',
0060   * for the number of evaluations of the function, and for the number of evaluations
0061   * of the Jacobian if ever).
0062   * 
0063   * Other tests were added by myself at the very beginning of the 
0064   * process and check the results for Levenberg-Marquardt using the reference data 
0065   * on http://www.itl.nist.gov/div898/strd/nls/nls_main.shtml. Since then i've 
0066   * carefully checked that the same results were obtained when modifying the
0067   * code. Please note that we do not always get the exact same decimals as they do,
0068   * but this is ok : they use 128bits float, and we do the tests using the C type 'double',
0069   * which is 64 bits on most platforms (x86 and amd64, at least).
0070   * I've performed those tests on several other implementations of Levenberg-Marquardt, and
0071   * (c)minpack performs VERY well compared to those, both in accuracy and speed.
0072   * 
0073   * The documentation for running the tests is on the wiki
0074   * http://eigen.tuxfamily.org/index.php?title=Tests
0075   * 
0076   * \section API API: overview of methods
0077   * 
0078   * Both algorithms needs a functor computing the Jacobian. It can be computed by
0079   * hand, using auto-differentiation (see \ref AutoDiff_Module), or using numerical
0080   * differences (see \ref NumericalDiff_Module). For instance:
0081   *\code
0082   * MyFunc func;
0083   * NumericalDiff<MyFunc> func_with_num_diff(func);
0084   * LevenbergMarquardt<NumericalDiff<MyFunc> > lm(func_with_num_diff);
0085   * \endcode
0086   * For HybridNonLinearSolver, the method solveNumericalDiff() does the above wrapping for
0087   * you.
0088   * 
0089   * The methods LevenbergMarquardt.lmder1()/lmdif1()/lmstr1() and 
0090   * HybridNonLinearSolver.hybrj1()/hybrd1() are specific methods from the original 
0091   * minpack package that you probably should NOT use until you are porting a code that
0092   * was previously using minpack. They just define a 'simple' API with default values 
0093   * for some parameters.
0094   * 
0095   * All algorithms are provided using two APIs :
0096   *     - one where the user inits the algorithm, and uses '*OneStep()' as much as he wants : 
0097   * this way the caller have control over the steps
0098   *     - one where the user just calls a method (optimize() or solve()) which will 
0099   * handle the loop: init + loop until a stop condition is met. Those are provided for
0100   *  convenience.
0101   * 
0102   * As an example, the method LevenbergMarquardt::minimize() is 
0103   * implemented as follow: 
0104   * \code
0105   * Status LevenbergMarquardt<FunctorType,Scalar>::minimize(FVectorType  &x, const int mode)
0106   * {
0107   *     Status status = minimizeInit(x, mode);
0108   *     do {
0109   *         status = minimizeOneStep(x, mode);
0110   *     } while (status==Running);
0111   *     return status;
0112   * }
0113   * \endcode
0114   * 
0115   * \section examples Examples
0116   * 
0117   * The easiest way to understand how to use this module is by looking at the many examples in the file
0118   * unsupported/test/NonLinearOptimization.cpp.
0119   */
0120 
0121 #ifndef EIGEN_PARSED_BY_DOXYGEN
0122 
0123 #include "src/NonLinearOptimization/qrsolv.h"
0124 #include "src/NonLinearOptimization/r1updt.h"
0125 #include "src/NonLinearOptimization/r1mpyq.h"
0126 #include "src/NonLinearOptimization/rwupdt.h"
0127 #include "src/NonLinearOptimization/fdjac1.h"
0128 #include "src/NonLinearOptimization/lmpar.h"
0129 #include "src/NonLinearOptimization/dogleg.h"
0130 #include "src/NonLinearOptimization/covar.h"
0131 
0132 #include "src/NonLinearOptimization/chkder.h"
0133 
0134 #endif
0135 
0136 #include "src/NonLinearOptimization/HybridNonLinearSolver.h"
0137 #include "src/NonLinearOptimization/LevenbergMarquardt.h"
0138 
0139 
0140 #endif // EIGEN_NONLINEAROPTIMIZATION_MODULE