68 |
|
const int LS_ERROR = -1; |
69 |
|
|
70 |
|
/** @todo move to math module */ |
71 |
< |
double dotProduct(const std::vector<double>& v1, const std::vector<double>& v2); |
71 |
> |
RealType dotProduct(const std::vector<RealType>& v1, const std::vector<RealType>& v2); |
72 |
|
|
73 |
|
/** |
74 |
|
* @class Minimizer |
94 |
|
virtual void prepareStep() {}; |
95 |
|
|
96 |
|
//line search algorithm, for the time being, we use back track algorithm |
97 |
< |
virtual int doLineSearch(std::vector<double>& direction, double stepSize); |
97 |
> |
virtual int doLineSearch(std::vector<RealType>& direction, RealType stepSize); |
98 |
|
|
99 |
|
virtual int checkConvg() = 0; |
100 |
|
|
117 |
|
void setVerbose(bool verbose) { bVerbose = verbose;} |
118 |
|
|
119 |
|
//get and set the coordinate |
120 |
< |
std::vector<double> getX() { return curX; } |
121 |
< |
void setX(std::vector<double>& x); |
120 |
> |
std::vector<RealType> getX() { return curX; } |
121 |
> |
void setX(std::vector<RealType>& x); |
122 |
|
|
123 |
|
//get and set the value of object function |
124 |
< |
double getF() { return curF; } |
125 |
< |
void setF(double f) { curF = f; } |
124 |
> |
RealType getF() { return curF; } |
125 |
> |
void setF(RealType f) { curF = f; } |
126 |
|
|
127 |
< |
std::vector<double> getG() { return curG; } |
128 |
< |
void setG(std::vector<double>& g); |
127 |
> |
std::vector<RealType> getG() { return curG; } |
128 |
> |
void setG(std::vector<RealType>& g); |
129 |
|
|
130 |
|
//get and set the gradient |
131 |
< |
std::vector<double> getGrad() { return curG; } |
132 |
< |
void setGrad(std::vector<double>& g) { curG = g; } |
131 |
> |
std::vector<RealType> getGrad() { return curG; } |
132 |
> |
void setGrad(std::vector<RealType>& g) { curG = g; } |
133 |
|
|
134 |
|
//interal function to evaluate the energy and gradient in OOPSE |
135 |
< |
void calcEnergyGradient(std::vector<double>& x, std::vector<double>& grad, double& |
135 |
> |
void calcEnergyGradient(std::vector<RealType>& x, std::vector<RealType>& grad, RealType& |
136 |
|
energy, int& status); |
137 |
|
|
138 |
|
//calculate the value of object function |
139 |
|
virtual void calcF(); |
140 |
< |
virtual void calcF(std::vector<double>& x, double&f, int& status); |
140 |
> |
virtual void calcF(std::vector<RealType>& x, RealType&f, int& status); |
141 |
|
|
142 |
|
//calculate the gradient |
143 |
|
virtual void calcG(); |
144 |
< |
virtual void calcG(std::vector<double>& x, std::vector<double>& g, double& f, int& status); |
144 |
> |
virtual void calcG(std::vector<RealType>& x, std::vector<RealType>& g, RealType& f, int& status); |
145 |
|
|
146 |
|
//calculate the hessian |
147 |
|
//virtual void calcH(int& status); |
148 |
< |
//virtual void calcH(vector<double>& x, std::vector<dobule>& g, SymMatrix& h, int& status); |
148 |
> |
//virtual void calcH(vector<RealType>& x, std::vector<dobule>& g, SymMatrix& h, int& status); |
149 |
|
|
150 |
|
friend std::ostream& operator<<(std::ostream& os, const Minimizer& minimizer); |
151 |
|
|
152 |
|
protected: |
153 |
|
|
154 |
|
// transfrom cartesian and rotational coordinates into minimization coordinates |
155 |
< |
std::vector<double> getCoor(); |
155 |
> |
std::vector<RealType> getCoor(); |
156 |
|
|
157 |
|
// transfrom minimization coordinates into cartesian and rotational coordinates |
158 |
< |
void setCoor(std::vector<double>& x); |
158 |
> |
void setCoor(std::vector<RealType>& x); |
159 |
|
|
160 |
|
|
161 |
|
|
165 |
|
//remove the force component along the bond direction |
166 |
|
int shakeF() { return 0;} |
167 |
|
|
168 |
< |
double calcPotential(); |
168 |
> |
RealType calcPotential(); |
169 |
|
|
170 |
|
SimInfo* info; |
171 |
|
|
195 |
|
int egEvalStatus; |
196 |
|
|
197 |
|
//initial coordinates |
198 |
< |
//vector<double> initX; |
198 |
> |
//vector<RealType> initX; |
199 |
|
|
200 |
|
//current value of the function |
201 |
< |
double curF; |
201 |
> |
RealType curF; |
202 |
|
|
203 |
|
// current coordinates |
204 |
< |
std::vector<double> curX; |
204 |
> |
std::vector<RealType> curX; |
205 |
|
|
206 |
|
//gradient at curent coordinates |
207 |
< |
std::vector<double> curG; |
207 |
> |
std::vector<RealType> curG; |
208 |
|
|
209 |
|
//hessian at current coordinates |
210 |
|
//SymMatrix curH; |