FunctionBase.h

00001 #ifndef _FunctionBase_h
00002 #define _FunctionBase_h
00003 
00004 
00005 // SYSTEM INCLUDES
00006 //
00007 
00008 // PROJECT INCLUDES
00009 //
00010 
00011 // LOCAL INCLUDES
00012 //
00013 #include "EvaluationError.h"
00014 #include "VariableNames.h"
00015 
00016 // FORWARD REFERENCES
00017 //
00018 class ProblemBase;
00019 
00024 class FunctionBase
00025 {
00026 public:
00027 // LIFECYCLE
00028 
00033     FunctionBase(bool isDifferentiable);
00034 
00035 
00038     virtual ~FunctionBase(void);
00039 
00040 
00041 // OPERATORS
00042 
00043 // OPERATIONS
00044 
00045     virtual std::auto_ptr<FunctionBase>     Clone() const = 0;
00046 
00052     double          Evaluate(const ColumnVector& point) const
00053         throw(EvaluationError);
00054 
00060     double          EvaluateNoThrow(const ColumnVector& point) const throw();
00061 
00070     virtual void    BeginFixed() const;
00071 
00074     virtual void    EndFixed() const;
00075 
00082     double          PartialDerivative(const ColumnVector& point,
00083                                       int                 variableIndex) const
00084                                             throw(EvaluationError);
00085 
00094     double          SecondPartialDerivative(const ColumnVector& point,
00095                                             int   firstVariableIndex,
00096                                             int   secondVariableIndex) const
00097                                                 throw(EvaluationError);
00098 
00103     ColumnVector    Gradient(const ColumnVector& point) const
00104                                                 throw(EvaluationError);
00105 
00110     SymmetricMatrix Hessian(const ColumnVector& point) const
00111                                                 throw(EvaluationError);
00112 
00118     void                        IncreaseCounter() const;
00119 
00122     void                        ResetCounter() const;
00123 
00124 
00125 // ACCESS
00126 
00131     virtual wxString            ToString(bool full = true) const = 0;
00132 
00135     virtual unsigned            EvaluationCount() const;
00136 
00137     //TODO: Zdecydować się czy zrobić tę funkcję wirtualną i dodawać problem do
00138     //"kaskadowo" (będzie wymagało modyfikacji FunctionDecorator).
00144     virtual void        SetProblem(const ProblemBase* pProblem) const;
00145 
00148     virtual VariableNames       PresentVariables() const = 0;
00149 
00150 // INQUIRY
00151 
00154     virtual bool                IsDifferentiable() const;
00155 
00158     virtual bool                ContainsUnknown(const VariableNames& variables)
00159                                     const = 0;
00160 
00161 protected:
00162     FunctionBase(const FunctionBase& from);
00163 
00166     virtual double          DoEvaluateNoThrow(const ColumnVector& point) const
00167         throw() = 0;
00168 
00169     virtual double          DoEvaluate(const ColumnVector& point) const
00170         throw(EvaluationError);
00171 
00172     bool                mDifferentiable;   
00173     // Dodane mutable. Brzydki hak, ale SetProblem trzeba wywolac przy
00174     // kopiowaniu problemu, a funkcja w problemie jest const.
00175     mutable const ProblemBase*  mpProblem; 
00176 
00177 private:
00187     void                        CheckValidity(double              value,
00188                                               const ColumnVector& point) const;
00189 
00190     mutable unsigned mCounter;  
00191 };
00192 
00193 // INLINE METHODS
00194 //
00195 
00196 // EXTERNAL REFERENCES
00197 //
00198 
00199 #endif  // _FunctionBase_h_

Wygenerowano Fri Sep 29 21:04:47 2006 dla EduOptim2 programem  doxygen 1.4.6