QVFunctionMinimizer Class Reference
[Function optimization]

Wrapper class for GSL function minimization. More...

#include <qvmath/qvfunctionminimizer.h>

List of all members.

Public Member Functions

 QVFunctionMinimizer (const bool useGoldenSection=true)
 Constructor for the class.
virtual double function (const double value)=0
 Function to be optimized.
void setStartingValue (const double value)
 Specifies the search starting value.
void setSearchRange (const double min, const double max)
 Specifies the search range.
const double & getMinimum () const
 Returns the minimum obtained in the last search.
const int & getIterations () const
 Number of iterations elapsed in the last search.
bool iterate (const int maxIterations=100, const double maxError=0.00001)
 Launchs a minimization search.


Detailed Description

Wrapper class for GSL function minimization.

This is a baseclass to create function minimizator objects. It is based on the GSL functionality for that matter.

Todo:
detail the minimization method used by the GSL.
This class is used creating a subclass containing the function to be optimized. Method function should be redefined in the subclasses contain the code for that function.

An example subclass for QVFunctionMinimization follows:

class FMinimizer: public QVFunctionMinimizer
        {
        public:
                fMinimizer(): QVFunctionMinimizer()     {}
                double function(double value)
                        { return f(value); }    // Or whatever the function is.
        }

The following code ilustrates the usage of this class to perform optimization for function f

[...]
// We create the minimization object
FMinimizer fMinimizer;

// and start a minimization search of 100 iterations 
if (fMinimizer.iterate(100))
        std::cout       << "The search found a minimum at value "
                        << fMinimizer.getMinimum() << std::endl;
else
        std::cout       << "No minimum could be found." << std::endl;
[...]

Definition at line 75 of file qvfunctionminimizer.h.


Constructor & Destructor Documentation

QVFunctionMinimizer::QVFunctionMinimizer ( const bool  useGoldenSection = true  )  [inline]

Constructor for the class.

Todo:
explain parameter useGolenSection below
Parameters:
useGolenSection explain ???

Definition at line 89 of file qvfunctionminimizer.h.


Member Function Documentation

virtual double QVFunctionMinimizer::function ( const double  value  )  [pure virtual]

Function to be optimized.

This method should be implemented by the subclass containing the function to be minimized.

Parameters:
value value to evaluate the function.

void QVFunctionMinimizer::setStartingValue ( const double  value  )  [inline]

Specifies the search starting value.

The search will start looking for the minimum around it. By default this value is set to 0 when the minimizer object is constructed.

Parameters:
value the starting search value.

Definition at line 107 of file qvfunctionminimizer.h.

void QVFunctionMinimizer::setSearchRange ( const double  min,
const double  max 
) [inline]

Specifies the search range.

The search will constrain to the given range. By default this range is [-1,1].

Parameters:
value the starting search value.

Definition at line 115 of file qvfunctionminimizer.h.

const double& QVFunctionMinimizer::getMinimum (  )  const [inline]

Returns the minimum obtained in the last search.

After a successful search started with function iterate, this method return the minimum value obtained in it, if the search was successful.

Returns:
minimum value obtained in the last search.

Definition at line 124 of file qvfunctionminimizer.h.

const int& QVFunctionMinimizer::getIterations (  )  const [inline]

Number of iterations elapsed in the last search.

This will return the number of iterations which took to the last search (started with function iterate) to find a minimum, or stopping, if none was found.

Returns:
number of iterations elapse in the last search.

Definition at line 133 of file qvfunctionminimizer.h.

bool QVFunctionMinimizer::iterate ( const int  maxIterations = 100,
const double  maxError = 0.00001 
)

Launchs a minimization search.

This method will start a new search.

Todo:
specify for param maxError below
Parameters:
maxIteration maximum number of steps to perform in the search
maxError maximum ?????
Returns:
true if a minimum was found, else false.

Definition at line 34 of file qvfunctionminimizer.cpp.


The documentation for this class was generated from the following files: