ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/minimizers/OOPSEMinimizer.hpp
Revision: 1492
Committed: Fri Sep 24 16:27:58 2004 UTC (19 years, 9 months ago) by tim
File size: 5396 byte(s)
Log Message:
change the #include in source files

File Contents

# Content
1 #ifndef _OOPSEMINIMIZER_H_
2 #define _OOPSEMINIMIZER_H_
3
4 #include <iostream>
5
6 #include "integrators/Integrator.hpp"
7 #include "minimizers/MinimizerParameterSet.hpp"
8
9
10 using namespace std;
11
12 const int MIN_LSERROR = -1;
13 const int MIN_MAXITER = 0;
14 const int MIN_CONVERGE = 1;
15
16 const int CONVG_UNCONVG = 0;
17 const int CONVG_FTOL = 1;
18 const int CONVG_GTOL = 2;
19 const int CONVG_ABSGTOL = 3;
20 const int CONVG_STEPTOL = 4;
21
22 const int LS_SUCCEED =1;
23 const int LS_ERROR = -1;
24
25 // base class of minimizer
26
27 class OOPSEMinimizer : public RealIntegrator{
28 public:
29
30 OOPSEMinimizer(SimInfo *theInfo, ForceFields* the_ff,
31 MinimizerParameterSet* param);
32
33 virtual ~OOPSEMinimizer();
34
35 //
36 virtual void init() {}
37
38 //driver function of minimization method
39 virtual void minimize();
40
41 //
42 virtual int step() = 0;
43
44 //
45 virtual void prepareStep() {};
46
47 //line search algorithm, for the time being, we use back track algorithm
48 virtual int doLineSearch(vector<double>& direction, double stepSize);
49
50 virtual int checkConvg() = 0;
51
52 //print detail information of the minimization method
53 virtual void printMinimizerInfo();
54
55 //save the result when minimization method is done
56 virtual void saveResult(){}
57
58 //write out the trajectory
59 virtual void writeOut(vector<double>&x, double curIter);
60
61
62 //get the status of minimization
63 int getMinStatus() {return minStatus;}
64
65 // get the dimension of the model
66 int getDim() { return ndim; }
67
68 //get the name of minimizer method
69 string getMinimizerName() { return minimizerName; }
70
71 //return number of current Iteration
72 int getCurIter() { return curIter; }
73
74 // set the verbose mode of minimizer
75 void setVerbose(bool verbose) { bVerbose = verbose;}
76
77 //get and set the coordinate
78 vector<double> getX() { return curX; }
79 void setX(vector<double>& x);
80
81 //get and set the value of object function
82 double getF() { return curF; }
83 void setF(double f) { curF = f; }
84
85 vector<double> getG() { return curG; }
86 void setG(vector<double>& g);
87
88 //get and set the gradient
89 vector<double> getGrad() { return curG; }
90 void setGrad(vector<double>& g) { curG = g; }
91
92 //interal function to evaluate the energy and gradient in OOPSE
93 void calcEnergyGradient(vector<double>& x, vector<double>& grad, double&
94 energy, int& status);
95
96 //calculate the value of object function
97 virtual void calcF();
98 virtual void calcF(vector<double>& x, double&f, int& status);
99
100 //calculate the gradient
101 virtual void calcG();
102 virtual void calcG(vector<double>& x, vector<double>& g, double& f, int& status);
103
104 //calculate the hessian
105 //virtual void calcH(int& status);
106 //virtual void calcH(vector<double>& x, vector<dobule>& g, SymMatrix& h, int& status);
107
108
109 protected:
110
111 // transfrom cartesian and rotational coordinates into minimization coordinates
112 vector<double> getCoor();
113
114 // transfrom minimization coordinates into cartesian and rotational coordinates
115 void setCoor(vector<double>& x);
116
117 //flag of turning on shake algorithm
118 bool bShake;
119
120 //constraint the bonds;
121 int shakeR();
122
123 //remove the force component along the bond direction
124 int shakeF();
125
126 // dimension of the model
127 int ndim;
128
129 //name of the minimizer
130 string minimizerName;
131
132 // current iteration number
133 int curIter;
134 //status of minimization
135 int minStatus;
136
137 //flag of verbose mode
138 bool bVerbose;
139
140
141 //parameter set of minimization method
142 MinimizerParameterSet* paramSet;
143
144 //status of energy and gradient evaluation
145 int egEvalStatus;
146
147 //initial coordinates
148 //vector<double> initX;
149
150 //current value of the function
151 double curF;
152 // current coordinates
153 vector<double> curX;
154 //gradient at curent coordinates
155 vector<double> curG;
156
157 //hessian at current coordinates
158 //SymMatrix curH;
159
160 private:
161
162 //calculate the dimension od the model for minimization
163 void calcDim();
164
165 };
166
167 // steepest descent minimizer
168 class SDMinimizer : public OOPSEMinimizer{
169 public:
170 SDMinimizer(SimInfo *theInfo, ForceFields* the_ff,
171 MinimizerParameterSet* param);
172
173 virtual void init();
174 virtual int step();
175 virtual void prepareStep();
176 virtual int checkConvg();
177 protected:
178
179 vector<double> direction;
180 double prevF;
181 double stepSize;
182
183 };
184
185 // conjugate gradient famlily minimzier
186 class CGFamilyMinmizer : public OOPSEMinimizer{
187 public:
188 CGFamilyMinmizer(SimInfo *theInfo, ForceFields* the_ff,
189 MinimizerParameterSet* param);
190
191 //check the convergence
192 virtual int checkConvg();
193
194
195 protected:
196
197 vector<double> direction;
198 vector<double> prevX;
199 vector<double> prevG;
200 double prevF;
201 double stepSize;
202 };
203
204 //Polak-Ribiere Conjugate Gradient Method
205 class PRCGMinimizer : public CGFamilyMinmizer{
206 public:
207 PRCGMinimizer(SimInfo *theInfo, ForceFields* the_ff,
208 MinimizerParameterSet* param)
209 :CGFamilyMinmizer(theInfo, the_ff, param) {}
210 virtual int step();
211 virtual void init();
212 virtual void prepareStep();
213 };
214
215 #endif

Properties

Name Value
svn:executable *