src/qvmath/qvfunctionminimizer.h

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00024 
00025 #ifndef QVFUNCTIONMINIMIZER_H
00026 #define QVFUNCTIONMINIMIZER_H
00027 
00028 #include <qvmath/qvvector.h>
00029 #include <qvmath/qvmath.h>
00030 #include <gsl/gsl_errno.h>
00031 #include <gsl/gsl_math.h>
00032 #include <gsl/gsl_min.h>
00033 
00074 class QVFunctionMinimizer
00075         {
00076         private:
00077                 int iterations;
00078                 bool useGoldenSection;
00079                 double actual, minimum, maximum;
00080 
00081                 static double static_function (const double v, void *functionMinimizerPtr);
00082 
00083         public: 
00088                 QVFunctionMinimizer(const bool useGoldenSection = true):
00089                         useGoldenSection(useGoldenSection), actual(0), minimum(-1), maximum(1)  { }
00090 
00097                 virtual double function(const double value) = 0;
00098 
00106                 void setStartingValue(const double value)                       { actual = value; }
00107 
00114                 void setSearchRange(const double min, const double max )        { minimum = min; maximum = max; }
00115 
00123                 const double & getMinimum()     const   { return actual; }
00124 
00132                 const int & getIterations()     const   { return iterations; }
00133 
00143                 bool iterate(const int maxIterations = 100, const double maxError = 0.00001);
00144         };
00145 
00146 #endif
00147 

Generated on Thu Jul 17 17:23:28 2008 for QVision by  doxygen 1.5.3