00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _line_search_h_
00014 #define _line_search_h_
00015
00016 #include <iostream>
00017
00018 #include <optimizer.h>
00019
00023 template <class V>
00024 class LineSearch {
00025 public:
00026 typedef double value_type;
00027 protected:
00029 double too_small_, too_big_;
00031 int maxLoop_;
00033 V xtd_, gradient_;
00035 double qt_, qpt_;
00037 bool succeed_;
00038 public:
00040 LineSearch(double eps = 1e-8)
00041 : too_small_(eps), too_big_(1./eps),
00042 maxLoop_(100), qt_(0.), qpt_(0.),
00043 succeed_(true) {}
00045 virtual ~LineSearch() {}
00046
00048 double lastFunctionValue() { return qt_; }
00050 double lastGradientNorm2() { return qpt_; }
00051
00053 V& lastX() { return xtd_;}
00055 V& lastGradient() { return gradient_;}
00056
00058 void setMaxLoop(int maxLoop) { maxLoop_ = maxLoop;}
00059
00061 void setTooSmall(double too_small) { too_small_ = too_small;}
00063 void setTooBig(double too_big) { too_big_ = too_big;}
00064
00065 bool succeed() { return succeed_;}
00066
00068 virtual value_type operator() (OptimizationProblem<V>& P, value_type t_ini, value_type q0, value_type qp0) = 0;
00069 };
00070
00071 #endif