00001 #ifndef PLAYA_OBJECTIVE_BASE_H 00002 #define PLAYA_OBJECTIVE_BASE_H 00003 00004 #include "PlayaDefs.hpp" 00005 #include "PlayaVectorDecl.hpp" 00006 #include "PlayaObjectWithVerbosity.hpp" 00007 00008 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION 00009 #include "PlayaVectorImpl.hpp" 00010 #endif 00011 00012 00013 00014 00015 namespace Playa 00016 { 00022 class ObjectiveBase : public ObjectWithVerbosity, 00023 public Describable 00024 { 00025 public: 00027 ObjectiveBase(int verb=0) : ObjectWithVerbosity(verb), contextString_() {;} 00028 00030 virtual ~ObjectiveBase(){;} 00031 00033 virtual void evalGrad(const Vector<double>& x, double& f, 00034 Vector<double>& grad) const = 0; 00035 00037 virtual void eval(const Vector<double>& x, double& f) const = 0 ; 00038 00040 virtual Vector<double> getInit() const = 0; 00041 00044 virtual double getInvHScale() const {return 1.0;} 00045 00048 virtual void iterationCallback(const Vector<double>& x, int iter) const {;} 00049 00052 virtual void finalCallback(const Vector<double>& x) const {;} 00053 00058 void setContextString(const string& str) const {contextString_ = str;} 00059 00064 const string& contextString() const {return contextString_;} 00065 00069 virtual int numFuncEvals() const {return -1;} 00070 00074 virtual string description() const {return "ObjectiveBase";} 00075 00079 bool fdCheck(const Vector<double>& x, double tol, int verbosity=0) const ; 00080 00081 protected: 00083 virtual double fdStep() const {return 1.0e-4;} 00084 00085 00086 private: 00087 mutable string contextString_; 00088 }; 00089 00090 } 00091 00092 #endif