00001 #ifndef PLAYA_LINE_SEARCH_BASED_OPT_BASE_H 00002 #define PLAYA_LINE_SEARCH_BASED_OPT_BASE_H 00003 00004 #include "PlayaUnconstrainedOptimizerBase.hpp" 00005 #include "PlayaLineSearchBase.hpp" 00006 #include "PlayaOptConvergenceTestBase.hpp" 00007 #include "PlayaObjectiveBase.hpp" 00008 00009 namespace Playa 00010 { 00011 00012 /** 00013 * 00014 */ 00015 class DirectionGeneratorBase : public ObjectWithVerbosity 00016 { 00017 public: 00018 /** */ 00019 DirectionGeneratorBase() {} 00020 00021 /** */ 00022 ~DirectionGeneratorBase() {} 00023 00024 /** */ 00025 virtual bool generateDirection(const RCP<ObjectiveBase>& obj, 00026 const Vector<double>& xCur, 00027 const Vector<double>& gradCur, 00028 const double& fCur, 00029 Vector<double>& p) = 0 ; 00030 }; 00031 00032 00033 /** 00034 * Base class for optimizers based on line search methods. 00035 * 00036 * @author Kevin Long 00037 */ 00038 class LineSearchBasedOptBase : public UnconstrainedOptimizerBase 00039 { 00040 public: 00041 /** */ 00042 LineSearchBasedOptBase(const ParameterList& params); 00043 /** */ 00044 virtual ~LineSearchBasedOptBase(){} 00045 00046 /** Main method to apply the algorithm starting with x and 00047 returning the result in x */ 00048 OptState run(const RCP<ObjectiveBase>& obj, 00049 const Vector<double>& xInit, 00050 const RCP<ConvergenceMonitor>& convMonitor = null) const ; 00051 00052 /** */ 00053 virtual RCP<DirectionGeneratorBase> makeDirectionGenerator() const = 0 ; 00054 00055 /** */ 00056 virtual void print(std::ostream& os) const ; 00057 00058 protected: 00059 /** */ 00060 const RCP<LineSearchBase>& lineSearch() const {return lineSearch_;} 00061 00062 /** */ 00063 const RCP<OptConvergenceTestBase>& convTest() const {return convTest_;} 00064 00065 private: 00066 RCP<LineSearchBase> lineSearch_; 00067 RCP<OptConvergenceTestBase> convTest_; 00068 00069 }; 00070 00071 00072 } 00073 00074 #endif