#ifndef ROOT_Math_Minimizer
#define ROOT_Math_Minimizer
#ifndef ROOT_Math_IFunctionfwd
#include "Math/IFunctionfwd.h"
#endif
#include <vector> 
#include <limits> 
#ifdef DEBUG
#include <iostream> 
#endif
namespace ROOT { 
   
   namespace Math { 
 
class Minimizer {
public: 
   typedef ROOT::Math::IMultiGenFunction IObjFunction; 
   typedef ROOT::Math::IMultiGradFunction IGradObjFunction; 
    
   Minimizer () : 
#ifndef DEBUG
      fDebug(0), 
#else
      fDebug(3),
#endif 
      fStrategy(1),
      fMaxCalls(0), 
      fMaxIter(0),
      fTol(1.E-6), 
      fUp(1.)
   {} 
    
   virtual ~Minimizer ()  {}  
private:
   
    
   Minimizer(const Minimizer &) {} 
    
   Minimizer & operator = (const Minimizer & rhs)  {
      if (this == &rhs) return *this;  
      return *this;
   }
public: 
   
   
   virtual void Clear() {}
   
   virtual void SetFunction(const IObjFunction & func) = 0; 
   
   virtual void SetFunction(const IGradObjFunction & func) = 0;
   
   
   template<class VariableIterator> 
   int SetVariables(const VariableIterator & begin, const VariableIterator & end) { 
      unsigned int ivar = 0; 
      for ( VariableIterator vitr = begin; vitr != end; ++vitr) { 
#ifdef DEBUG
         std::cout << "adding variable " << ivar << "  " << vitr->Name(); 
         if (vitr->IsDoubleBound() ) std::cout << " bounded to [ " <<  vitr->LowerLimit() << " , " <<  vitr->UpperLimit() << " ] ";
         std::cout << std::endl; 
#endif
         bool iret = false; 
         if (vitr->IsFixed() )
            iret = SetFixedVariable(ivar,  vitr->Name(), vitr->Value() ); 
         else if (vitr->IsDoubleBound() )
            iret = SetLimitedVariable(ivar,  vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->LowerLimit(), vitr->UpperLimit() );
         else if (vitr->HasLowerLimit() )
            iret = SetLowerLimitedVariable(ivar,  vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->LowerLimit() );
         else if (vitr->HasUpperLimit() )
            iret = SetUpperLimitedVariable(ivar,  vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->UpperLimit() );
         else 
            iret = SetVariable( ivar, vitr->Name(), vitr->Value(), vitr->StepSize() ); 
         if (iret) ivar++; 
#ifdef DEBUG
         if (iret) 
            std::cout << "Added variable " << vitr->Name() << " val = " << vitr->Value() << " step " << vitr->StepSize() 
                      << std::endl; 
         else 
            std::cout << "Failed to Add variable " << vitr->Name() << std::endl; 
#endif
      }
      return ivar; 
   }
   
   virtual bool SetVariable(unsigned int ivar, const std::string & name, double val, double step) = 0; 
   
   virtual bool SetLowerLimitedVariable(unsigned int  ivar , const std::string & name , double val , double step , double lower ) { 
      return SetLimitedVariable(ivar, name, val, step, lower, std::numeric_limits<double>::infinity() );  
   } 
   
   virtual bool SetUpperLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double upper ) { 
      return SetLimitedVariable(ivar, name, val, step, - std::numeric_limits<double>::infinity(), upper );  
   } 
   
   virtual bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double , double ) { 
      return SetVariable(ivar, name, val, step );  
   }
   
   virtual bool SetFixedVariable(unsigned int ivar , const std::string & name , double val ) { 
      return SetLimitedVariable(ivar, name, val, 0., val, val); 
   }
   
   virtual  bool Minimize() = 0; 
   
   virtual double MinValue() const = 0; 
   
   virtual double Edm() const = 0; 
   
   virtual const double *  X() const = 0; 
   
   virtual const double *  MinGradient() const = 0;  
   
   virtual unsigned int NCalls() const = 0;    
   
   
   virtual unsigned int NDim() const = 0;  
   
   
   virtual unsigned int NFree() const = 0;  
   
   virtual bool ProvidesError() const = 0; 
   
   virtual const double * Errors() const = 0;
    
   virtual double CovMatrix(unsigned int i, unsigned int j) const = 0;  
   
   virtual bool GetMinosError(unsigned int , double & errLow, double & errUp) { 
      errLow = 0; errUp = 0; 
      return false; 
   }  
   
   
   
   
   int PrintLevel() const { return fDebug; }
   
   unsigned int MaxFunctionCalls() { return fMaxCalls; } 
   
   unsigned int MaxIterations() { return fMaxIter; } 
   
   double Tolerance() const { return  fTol; }
   
   int Strategy() const { return fStrategy; }
   
   
   double ErrorUp() const { return fUp; } 
   
   void SetPrintLevel(int level) { fDebug = level; }
   
   void SetMaxFunctionCalls(unsigned int maxfcn) { if (maxfcn > 0) fMaxCalls = maxfcn; }
   
   void SetMaxIterations(unsigned int maxiter) { if (maxiter > 0) fMaxIter = maxiter; } 
   
   void SetTolerance(double tol) { fTol = tol; }
   
   void SetStrategy(int strategyLevel) { fStrategy = strategyLevel; }  
   
   void SetErrorUp(double up) { fUp = up; }
protected: 
   
 
   int fDebug;                  
   int fStrategy;               
   unsigned int fMaxCalls;      
   unsigned int fMaxIter;       
   double fTol;                 
   double fUp;                  
}; 
   } 
} 
#endif /* ROOT_Math_Minimizer */
Last update: Thu Jan 17 08:41:55 2008
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.