pele
Python energy landscape explorer
/home/js850/projects/pele/source/pele/lbfgs.h
00001 #ifndef _PELE_LBFGS_H__
00002 #define _PELE_LBFGS_H__
00003 
00004 #include <vector>
00005 #include <memory>
00006 #include "base_potential.h"
00007 #include "array.h"
00008 #include "optimizer.h"
00009 
00010 namespace pele{
00011 
00016 class LBFGS : public GradientOptimizer{
00017 private:
00018 
00019     int M_; 
00020     double max_f_rise_; 
00024     bool use_relative_f_; 
00030     // places to store the lbfgs memory
00032     std::vector<Array<double> > s_;
00034     std::vector<Array<double> > y_;
00036     Array<double> rho_;
00042     double H0_;
00043     int k_; 
00045 public:
00049     LBFGS( std::shared_ptr<pele::BasePotential> potential, const pele::Array<double> x0,
00050             double tol = 1e-4, int M = 4);
00051 
00055     virtual ~LBFGS() {}
00056 
00060     void one_iteration();
00061 
00062     // functions for setting the parameters
00063     inline void set_H0(double H0)
00064     {
00065         if (iter_number_ > 0){
00066             std::cout << "warning: setting H0 after the first iteration.\n";
00067         }
00068         H0_ = H0;
00069     }
00070     inline void set_max_f_rise(double max_f_rise) { max_f_rise_ = max_f_rise; }
00071 
00072     inline void set_use_relative_f(int use_relative_f)
00073     { 
00074         use_relative_f_ = (bool) use_relative_f;
00075     }
00076 
00077     // functions for accessing the results
00078     inline double get_H0() const { return H0_; }
00079 
00086     virtual void reset(pele::Array<double> &x0);
00087 
00088 private:
00089 
00094     void update_memory( Array<double> xold, Array<double> gold, 
00095             Array<double> xnew, Array<double> gnew);
00096 
00100     void compute_lbfgs_step(Array<double> step);
00101 
00107     double backtracking_linesearch(Array<double> step);
00108 
00109 };
00110 }
00111 
00112 #endif
 All Classes Namespaces Functions Variables Typedefs