00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: conjugateGradient.h,v 1.29.20.6 2007/08/07 09:12:33 aleru Exp $ 00005 // 00006 00007 #ifndef BALL_MOLMEC_MINIMIZATION_CONJUGATEGRADIENT_H 00008 #define BALL_MOLMEC_MINIMIZATION_CONJUGATEGRADIENT_H 00009 00010 #ifndef BALL_MOLMEC_MINIMIZATION_ENERGYMINIMIZER_H 00011 # include <BALL/MOLMEC/MINIMIZATION/energyMinimizer.h> 00012 #endif 00013 00014 #ifndef BALL_MOLMEC_MINIMIZATION_LINESEARCH_H 00015 # include <BALL/MOLMEC/MINIMIZATION/lineSearch.h> 00016 #endif 00017 00018 namespace BALL 00019 { 00040 class BALL_EXPORT ConjugateGradientMinimizer 00041 : public EnergyMinimizer 00042 { 00043 public: 00044 00048 00052 enum UpdateMethod 00053 { 00056 POLAK_RIBIERE = 1, 00057 00060 FLETCHER_REEVES = 2, 00061 00064 SHANNO = 3 00065 }; 00066 00068 00071 00074 struct Option 00075 { 00078 static const char* UPDATE_METHOD; 00079 }; 00080 00083 struct BALL_EXPORT Default 00084 { 00087 static const Size UPDATE_METHOD; 00088 }; 00089 00091 00094 00095 BALL_CREATE(ConjugateGradientMinimizer) 00096 00097 00099 ConjugateGradientMinimizer(); 00100 00103 ConjugateGradientMinimizer(ForceField& force_field); 00104 00107 ConjugateGradientMinimizer(ForceField& force_field,SnapShotManager *ssm); 00108 00111 ConjugateGradientMinimizer(ForceField& force_field, 00112 SnapShotManager* ssm, const Options& options); 00113 00116 ConjugateGradientMinimizer(ForceField& force_field, const Options& options); 00117 00120 ConjugateGradientMinimizer(const ConjugateGradientMinimizer& rhs); 00121 00124 virtual ~ConjugateGradientMinimizer(); 00125 00127 00130 00133 const ConjugateGradientMinimizer& operator = (const ConjugateGradientMinimizer& rhs); 00134 00136 00139 00142 virtual bool specificSetup(); 00143 00145 00148 00152 void setUpdateMethod(UpdateMethod method); 00153 00156 UpdateMethod getUpdateMethod() const; 00157 00164 virtual double findStep(); 00165 00171 virtual void updateDirection(); 00172 00181 virtual bool minimize(Size iterations = 0, bool resume = false); 00182 00183 protected: 00184 00186 00189 00192 LineSearch line_search_; 00193 00196 Gradient unscaled_direction_; 00197 00200 Size number_of_atoms_; 00201 00204 Size updt_method_; 00205 00208 bool first_iter_; 00209 00212 double old_gtg_; 00213 00216 vector<Vector3> a_i_; 00217 00220 vector<Vector3> b_i_; 00221 00224 vector<Vector3> p_t_; 00225 00228 vector<Vector3> y_t_; 00229 00232 vector<Vector3> p_i_; 00233 00236 vector<Vector3> y_i_; 00237 00240 double D_1_; 00241 00244 double D_4_; 00245 00248 Size restart_frequency_; 00249 00255 Size last_restart_iter_; 00256 00258 00259 }; 00260 } // end of namespace BALL 00261 00262 #endif // BALL_MOLMEC_MINIMIZATION_CONJUGATEGRADIENT_H