00001 // This file is part of Eugenio, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2009 Thomas Capricelli <orzel@freehackers.org> 00005 // 00006 // Eigen is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 3 of the License, or (at your option) any later version. 00010 // 00011 // Alternatively, you can redistribute it and/or 00012 // modify it under the terms of the GNU General Public License as 00013 // published by the Free Software Foundation; either version 2 of 00014 // the License, or (at your option) any later version. 00015 // 00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Lesser General Public 00022 // License and a copy of the GNU General Public License along with 00023 // Eigen. If not, see <http://www.gnu.org/licenses/>. 00024 00025 #ifndef EIGEN_NONLINEAROPTIMIZATION_MODULE 00026 #define EIGEN_NONLINEAROPTIMIZATION_MODULE 00027 00028 #include <vector> 00029 00030 #include <Eigen/Core> 00031 #include <Eigen/Jacobi> 00032 #include <Eigen/QR> 00033 #include <unsupported/Eigen/NumericalDiff> 00034 00035 namespace Eigen { 00036 00037 /** \ingroup Unsupported_modules 00038 * \defgroup NonLinearOptimization_Module Non linear optimization module 00039 * \ingroup eigen_grp 00040 * \ingroup eigen_grp 00041 * 00042 * \code 00043 * #include <unsupported/Eigen/NonLinearOptimization> 00044 * \endcode 00045 * 00046 * This module provides implementation of two important algorithms in non linear 00047 * optimization. In both cases, we consider a system of non linear functions. Of 00048 * course, this should work, and even work very well if those functions are 00049 * actually linear. But if this is so, you should probably better use other 00050 * methods more fitted to this special case. 00051 * 00052 * One algorithm allows to find an extremum of such a system (Levenberg 00053 * Marquardt algorithm) and the second one is used to find 00054 * a zero for the system (Powell hybrid "dogleg" method). 00055 * 00056 * This code is a port of minpack (http://en.wikipedia.org/wiki/MINPACK). 00057 * Minpack is a very famous, old, robust and well-reknown package, written in 00058 * fortran. Those implementations have been carefully tuned, tested, and used 00059 * for several decades. 00060 * 00061 * The original fortran code was automatically translated using f2c (http://en.wikipedia.org/wiki/F2c) in C, 00062 * then c++, and then cleaned by several different authors. 00063 * The last one of those cleanings being our starting point : 00064 * http://devernay.free.fr/hacks/cminpack.html 00065 * 00066 * Finally, we ported this code to Eigen, creating classes and API 00067 * coherent with Eigen. When possible, we switched to Eigen 00068 * implementation, such as most linear algebra (vectors, matrices, stable norms). 00069 * 00070 * Doing so, we were very careful to check the tests we setup at the very 00071 * beginning, which ensure that the same results are found. 00072 * 00073 * \section Tests Tests 00074 * 00075 * The tests are placed in the file unsupported/test/NonLinear.cpp. 00076 * 00077 * There are two kinds of tests : those that come from examples bundled with cminpack. 00078 * They guaranty we get the same results as the original algorithms (value for 'x', 00079 * for the number of evaluations of the function, and for the number of evaluations 00080 * of the jacobian if ever). 00081 * 00082 * Other tests were added by myself at the very beginning of the 00083 * process and check the results for levenberg-marquardt using the reference data 00084 * on http://www.itl.nist.gov/div898/strd/nls/nls_main.shtml. Since then i've 00085 * carefully checked that the same results were obtained when modifiying the 00086 * code. Please note that we do not always get the exact same decimals as they do, 00087 * but this is ok : they use 128bits float, and we do the tests using the C type 'double', 00088 * which is 64 bits on most platforms (x86 and amd64, at least). 00089 * I've performed those tests on several other implementations of levenberg-marquardt, and 00090 * (c)minpack performs VERY well compared to those, both in accuracy and speed. 00091 * 00092 * The documentation for running the tests is on the wiki 00093 * http://eigen.tuxfamily.org/index.php?title=Tests 00094 * 00095 * \section API API : overview of methods 00096 * 00097 * Both algorithms can use either the jacobian (provided by the user) or compute 00098 * an approximation by themselves (actually using Eigen \ref NumericalDiff_Module). 00099 * The part of API referring to the latter use 'NumericalDiff' in the method names 00100 * (exemple: LevenbergMarquardt.minimizeNumericalDiff() ) 00101 * 00102 * The methods LevenbergMarquardt.lmder1()/lmdif1()/lmstr1() and 00103 * HybridNonLinearSolver.hybrj1()/hybrd1() are specific methods from the original 00104 * minpack package that you probably should NOT use until you are porting a code that 00105 * was previously using minpack. They just define a 'simple' API with default values 00106 * for some parameters. 00107 * 00108 * All algorithms are provided using Two APIs : 00109 * - one where the user inits the algorithm, and uses '*OneStep()' as much as he wants : 00110 * this way the caller have control over the steps 00111 * - one where the user just calls a method (optimize() or solve()) which will 00112 * handle the loop: init + loop until a stop condition is met. Those are provided for 00113 * convenience. 00114 * 00115 * As an example, the method LevenbergMarquardt::minimize() is 00116 * implemented as follow : 00117 * \code 00118 * Status LevenbergMarquardt<FunctorType,Scalar>::minimize(FVectorType &x, const int mode) 00119 * { 00120 * Status status = minimizeInit(x, mode); 00121 * do { 00122 * status = minimizeOneStep(x, mode); 00123 * } while (status==Running); 00124 * return status; 00125 * } 00126 * \endcode 00127 * 00128 * \section examples Examples 00129 * 00130 * The easiest way to understand how to use this module is by looking at the many examples in the file 00131 * unsupported/test/NonLinearOptimization.cpp. 00132 */ 00133 00134 #ifndef EIGEN_PARSED_BY_DOXYGEN 00135 00136 #include "src/NonLinearOptimization/qrsolv.h" 00137 #include "src/NonLinearOptimization/r1updt.h" 00138 #include "src/NonLinearOptimization/r1mpyq.h" 00139 #include "src/NonLinearOptimization/rwupdt.h" 00140 #include "src/NonLinearOptimization/fdjac1.h" 00141 #include "src/NonLinearOptimization/lmpar.h" 00142 #include "src/NonLinearOptimization/dogleg.h" 00143 #include "src/NonLinearOptimization/covar.h" 00144 00145 #include "src/NonLinearOptimization/chkder.h" 00146 00147 #endif 00148 00149 #include "src/NonLinearOptimization/HybridNonLinearSolver.h" 00150 #include "src/NonLinearOptimization/LevenbergMarquardt.h" 00151 00152 } 00153 00154 00155 00156 #endif // EIGEN_NONLINEAROPTIMIZATION_MODULE
| Page generated by Doxygen 1.7.4 for MRPT 0.9.5 SVN:2717 at Sun Oct 16 16:08:03 PDT 2011 | Hosted on: |