| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

# FuncMinimum Class Reference

The simplest concrete implementation of IFuncMinimum interface. More...

`#include <FuncMinimum.h>`

Inheritance diagram for FuncMinimum:
[legend]
Collaboration diagram for FuncMinimum:
[legend]

List of all members.

## Classes
class | FuncMinimumMisc
## Public Types
typedef std::vector< const GenFunc * > | Gradient
## Public Member Functions
virtual StatusCode | minimum (const GenFunc &func, Arg &arg) const
| Find minimum of the function "GenFunc".
virtual StatusCode | minimum (const GenFunc &func, Arg &arg, Covariance &covar) const
| Find minimum of the function "GenFunc".
virtual StatusCode | initialize ()
| Overriding initialize.
virtual StatusCode | finalize ()
| standard finalization method
virtual | ~FuncMinimum ()
| Destructor.
| FuncMinimum (const std::string &type, const std::string &name, const IInterface *parent)
| Standard constructor.
## Private Member Functions
| FuncMinimum ()
| default constructor is private
| FuncMinimum (const FuncMinimum &)
| copy constructor is private
FuncMinimum & | operator= (const FuncMinimum &)
| assignment operator is
## Private Attributes
std::string | m_algType
double | m_max_iter
double | m_norm_gradient
double | m_step_size
double | m_tol
const gsl_multimin_fdfminimizer_type * | m_type
| AlgTool type (concrete class name)
## Friends
class | ToolFactory< FuncMinimum >

## Detailed Description

The simplest concrete implementation of IFuncMinimum interface.

See also:
  GaudiGSL/IFuncMinimum.h

Author:
  Kirill Miklyaev kirillm@iris1.itep.ru

Date:
  2002-09-14

Definition at line 29 of file FuncMinimum.h.

## Member Typedef Documentation

typedef std::vector<const GenFunc*> FuncMinimum::Gradient

Definition at line 33 of file FuncMinimum.h.

## Constructor & Destructor Documentation

FuncMinimum::~FuncMinimum | ( | ) | `[virtual]`

Destructor.

Definition at line 356 of file FuncMinimum.cpp.

    {}

FuncMinimum::FuncMinimum | ( | const std::string & | type,
|  | const std::string & | name,
|  | const IInterface * | parent
| ) |  |

Standard constructor.

See also:
  GaudiTool

Parameters:

  type | tool type
  name | tool name
  parent | parent of the tool

declare type of the algorithm for multidimensional minimization

declare maximum of iteration

declare the absolute tolerance for the Euclidean norm of the gradient

declare the size of the first trial step

declare the accuracy of the line minimization

Definition at line 64 of file FuncMinimum.cpp.

      : base_class      ( type, name , parent )
      , m_algType       ( "conjugate_fr"      )
      , m_max_iter      ( 200                 )
      , m_norm_gradient ( 1.0e-10             )
      , m_step_size     ( 0.01                )
      , m_tol           ( 1e-10               )
      , m_type          ( 0                   )
    {
      declareProperty ( "Algorithm", m_algType       );
      declareProperty ( "Iteration", m_max_iter      );
      declareProperty ( "Gradient" , m_norm_gradient );
      declareProperty ( "Step_size", m_step_size     );
      declareProperty ( "Tol"      , m_tol           );
    }

FuncMinimum::FuncMinimum | ( | ) | `[private]`

default constructor is private

FuncMinimum::FuncMinimum | ( | const FuncMinimum & | ) | `[private]`

copy constructor is private

## Member Function Documentation

StatusCode FuncMinimum::finalize | ( | void | ) | `[virtual]`

standard finalization method

See also:
  AlgTool
  IAlgTool

Returns:
  status code

Reimplemented from GaudiTool.

Definition at line 343 of file FuncMinimum.cpp.

    {
      StatusCode sc = GaudiTool::finalize() ;

      MsgStream log( msgSvc() , name() ) ;

      if ( sc.isFailure() )
        {
          return Error("Could not finalize base class GaudiTool", sc);
        }
      return StatusCode::SUCCESS;
    }

StatusCode FuncMinimum::initialize | ( | ) | `[virtual]`

Overriding initialize.

The algorithm for multidimensional minimization

Reimplemented from GaudiTool.

Definition at line 290 of file FuncMinimum.cpp.

    {
      StatusCode sc = GaudiTool::initialize() ;

      MsgStream log( msgSvc() , name() ) ;

      if ( sc.isFailure() )
        {
          return Error ("Could not initialize base class GaudiTool", sc);
        }

      if(       "conjugate_fr" == m_algType )
        {
          m_type = gsl_multimin_fdfminimizer_conjugate_fr     ;
          log << MSG::DEBUG
              << "Minimization algorithm to be used: "
              << "'gsl_multimin_fdfminimizer_conjugate_fr'"
              << endmsg;
        }
      else if ( "conjugate_pr" == m_algType )
        {
          m_type = gsl_multimin_fdfminimizer_conjugate_pr     ;
          log << MSG::DEBUG
              << "Minimization algorithm to be used: "
              << "'gsl_multimin_fdfminimizer_conjugate_pr'"
              << endmsg;
        }
      else if ( "vector_bfgs" == m_algType )
        {
          m_type = gsl_multimin_fdfminimizer_vector_bfgs      ;
          log << MSG::DEBUG
              << "Minimization algorithm to be used: " <<
              "'gsl_multimin_fdfminimizer_vector_bfgs'" << endmsg;
        }
      else if ( "steepest_descent" == m_algType )
        {
          m_type = gsl_multimin_fdfminimizer_steepest_descent ;
          log << MSG::DEBUG
              << "Minimization algorithm to be used: "
              << "'gsl_multimin_fdfminimizer_steepest_descent'"
              << endmsg;
        }
      else
        {
          return Error(" Unknown algorithm type '"
                       + std::string(m_algType) + "'");
        }

      return StatusCode::SUCCESS;
    }

StatusCode FuncMinimum::minimum | ( | const GenFunc & | func,
|  | IFuncMinimum::Arg & | arg,
|  | IFuncMinimum::Covariance & | covar
| ) |  | const`[virtual]`

Find minimum of the function "GenFunc".

See also:
  IFuncMinimum.h

Returns:
  StatusCode

Find minimum of our function

Implements IFuncMinimum.

Definition at line 247 of file FuncMinimum.cpp.

    {
      MsgStream log( msgSvc(), name() );

      StatusCode sc = minimum (func, arg) ;

      if (sc.isFailure())
        {
          std::ostringstream buffer;
          buffer << "MINIMUM IS NOT FOUND. StatusCode =  '" << sc.getCode() << '\'';
          return Error (buffer.str(), sc);
        }
      else
        {
          HepSymMatrix cov(arg.dimension(), 0);
          for (unsigned int i = 0; i < arg.dimension(); ++i)
            {
              Genfun::GENFUNCTION f = func.partial(i);
              for (unsigned int j = i; j < arg.dimension(); ++j)
                {
                  Genfun::GENFUNCTION fij = f.partial(j);
                  cov(i+1, j+1) = 0.5 * fij(arg);
                }
            }

          int inv;
          covar = cov.inverse(inv);
          if ( inv != 0)
            {
              return Error
                ("Matrix of Error is not complete successful");
            }

          return StatusCode::SUCCESS;
        }

    }

StatusCode FuncMinimum::minimum | ( | const GenFunc & | func,
|  | IFuncMinimum::Arg & | arg
| ) |  | const`[virtual]`

Find minimum of the function "GenFunc".

See also:
  IFuncMinimum.h

Returns:
  StatusCode

Implements IFuncMinimum.

Definition at line 151 of file FuncMinimum.cpp.

    {
      using namespace Genfun;

      gsl_vector_view vect = gsl_vector_view_array ( &arg[0] ,
                                                     arg.dimension() );
      MsgStream log( msgSvc(), name() );

      FuncMinimumMisc local (func, arg);

      gsl_multimin_function_fdf function;

      function.f = &fun_gsl;
      function.df = &dfun_gsl;
      function.fdf = &fdfun_gsl;
      function.n = vect.vector.size;
      function.params = (void*) &local;

      size_t iter   = 0 ;
      int    status = 0 ;
      const gsl_multimin_fdfminimizer_type *T = m_type ;

      gsl_multimin_fdfminimizer *s;

      s = gsl_multimin_fdfminimizer_alloc ( T, vect.vector.size);

      gsl_multimin_fdfminimizer_set ( s, &function,
                                      &vect.vector, m_step_size, m_tol);

      for( iter = 0 ; iter < m_max_iter ; ++iter )
        {
          status = gsl_multimin_fdfminimizer_iterate (s);

          if ( status )
            {
              return Error
                ("Error from gsl_multimin_fdfminimizer_iterate '"
                 + std::string(gsl_strerror(status)) + "'") ;
            }

          status = gsl_multimin_test_gradient (s->gradient,
                                               m_norm_gradient);

          if ( status != GSL_CONTINUE ) { break; }
        }

      for (unsigned int i = 0; i < vect.vector.size; ++i)
        {
          gsl_vector_set (&vect.vector, i, gsl_vector_get (s->x, i));
        }

      if (status == GSL_SUCCESS)
        {
          log << MSG::DEBUG
              << "We stopped in the method on the " << iter
              << " iteration (we have maximum "     << m_max_iter
              << " iterations)"                     << endmsg;

          log << "The Euclidean norm of gradient = "
              << gsl_blas_dnrm2 (s->gradient)
              << " by the absolute tolerance = "
              << m_norm_gradient << endmsg;
        }
      else if (status == GSL_CONTINUE && iter <= m_max_iter )
        {
          return Error ( "Method finished with '"
                         + std::string(gsl_strerror(status))
                         +  "' error" );
        }
      else
        {
          return Error ( "Method finished with '" +
                         std::string(gsl_strerror(status))
                         +  "' error" );
        }

      gsl_multimin_fdfminimizer_free (s);

      if (status)
        {
          return Error ( "Method finished with '"
                         + std::string(gsl_strerror(status))
                         +  "' error" );
        }

      return StatusCode::SUCCESS;
    }

FuncMinimum& FuncMinimum::operator= | ( | const FuncMinimum & | ) | `[private]`

assignment operator is

## Friends And Related Function Documentation

friend class ToolFactory< FuncMinimum >`[friend]`

Definition at line 31 of file FuncMinimum.h.

## Member Data Documentation

std::string FuncMinimum::m_algType`[private]`

Definition at line 108 of file FuncMinimum.h.

double FuncMinimum::m_max_iter`[private]`

Definition at line 109 of file FuncMinimum.h.

double FuncMinimum::m_norm_gradient`[private]`

Definition at line 110 of file FuncMinimum.h.

double FuncMinimum::m_step_size`[private]`

Definition at line 111 of file FuncMinimum.h.

double FuncMinimum::m_tol`[private]`

Definition at line 112 of file FuncMinimum.h.

const gsl_multimin_fdfminimizer_type* FuncMinimum::m_type`[private]`

AlgTool type (concrete class name)

Reimplemented from AlgTool.

Definition at line 113 of file FuncMinimum.h.

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

- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiGSL/src/Components/FuncMinimum.h
- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiGSL/src/Components/FuncMinimum.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines