Revision | bedf6dbad2227b67f28075d37e03ca263c83eab6 (tree) |
---|---|
Time | 2012-11-27 17:17:32 |
Author | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
Merge trunk into branch gdiis. #28915
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/branches/gdiis@1141 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -66,7 +66,36 @@ void BFGS::SetMessages(){ | ||
66 | 66 | = "Error in optimization::BFGS::Optimize: Optimization did not met convergence criterion.\n"; |
67 | 67 | this->errorMessageNaNInRFOStep |
68 | 68 | = "Error in optimization::BFGS::Optimize: RFO step has gone NaN. (lambda * s[%d] = %e, lambda = %e, alpha = %e)\n"; |
69 | - this->messageStartBFGSStep = "\n========== START: BFGS step "; | |
69 | + | |
70 | + this->messageStartBFGSStep | |
71 | + = "\n========== START: BFGS step "; | |
72 | + this->messageHillClimbing = | |
73 | + "Detected hill climbing.\n" | |
74 | + "Rolling back molecular geometry.\n"; | |
75 | + this->messageRecalculateRFOStep | |
76 | + = "Recalculating RFO step...\n"; | |
77 | + this->messageRawHessianEigenvalues | |
78 | + = "Eigenvalues of the raw Hessian:"; | |
79 | + this->messageShiftedHessianEigenvalues | |
80 | + = "Eigenvalues of the level shifted hessian:"; | |
81 | + | |
82 | + this->formatEnergyChangeComparison = | |
83 | + "\n" | |
84 | + "actual energy change = %e\n" | |
85 | + "expected energy change = %e\n" | |
86 | + "actual/expected energy change = %f\n"; | |
87 | + this->formatLowestHessianEigenvalue | |
88 | + = "Lowest eigenvalue of the augmented Hessian = %f\n"; | |
89 | + this->format2ndLowestHessianEigenvalue | |
90 | + = "2nd lowest eigenvalue of the augmented Hessian = %f\n"; | |
91 | + this->format3rdLowestHessianEigenvalue | |
92 | + = "3rd lowest eigenvalue of the augmented Hessian = %f\n"; | |
93 | + this->formatRFOStepSize | |
94 | + = "Calculated RFO step size = %f\n"; | |
95 | + this->formatTrustRadiusIs | |
96 | + = "Trust radius is %f\n"; | |
97 | + this->formatIncreaseScalingFactor | |
98 | + = "Scaling factor is increased to %e.\n"; | |
70 | 99 | } |
71 | 100 | |
72 | 101 | void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStructure, |
@@ -190,12 +219,8 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct | ||
190 | 219 | bool aproxcheckCanOutputLogs = true; |
191 | 220 | tempCanOutputLogs = molecule.CanOutputLogs(); |
192 | 221 | molecule.SetCanOutputLogs(aproxcheckCanOutputLogs); |
193 | - this->OutputLog((boost::format("\n" | |
194 | - "actual energy change = %e\n" | |
195 | - "expected energy change = %e\n" | |
196 | - "actual/expected energy change = %f\n") | |
197 | - % (lineSearchCurrentEnergy-referenceEnergy) | |
198 | - % approximateChange % r)); | |
222 | + this->OutputLog(boost::format(this->formatEnergyChangeComparison) | |
223 | + % (lineSearchCurrentEnergy-lineSearchInitialEnergy) % approximateChange % r); | |
199 | 224 | molecule.SetCanOutputLogs(tempCanOutputLogs); |
200 | 225 | |
201 | 226 | // check convergence |
@@ -216,8 +241,7 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct | ||
216 | 241 | bool tempCanOutputLogs = molecule.CanOutputLogs(); |
217 | 242 | bool rollbackCanOutputLogs = true; |
218 | 243 | molecule.SetCanOutputLogs(rollbackCanOutputLogs); |
219 | - this->OutputLog("Detected hill climbing.\n" | |
220 | - "Rolling back molecular geometry.\n"); | |
244 | + this->OutputLog(this->messageHillClimbing); | |
221 | 245 | for(int i=0;i<molecule.GetNumberAtoms();i++){ |
222 | 246 | const Atom* atom = molecule.GetAtom(i); |
223 | 247 | double* xyz = atom->GetXyz(); |
@@ -335,17 +359,17 @@ void BFGS::CalcRFOStep(double* vectorStep, | ||
335 | 359 | } |
336 | 360 | normStep = sqrt(normStep); |
337 | 361 | |
338 | - this->OutputLog(boost::format("Lowest eigenvalue of the augmented Hessian = %f\n") % vectorEigenValues[0]); | |
339 | - this->OutputLog(boost::format("2nd lowest eigenvalue of the augmented Hessian = %f\n") % vectorEigenValues[1]); | |
340 | - this->OutputLog(boost::format("3rd lowest eigenvalue of the augmented Hessian = %f\n") % vectorEigenValues[2]); | |
341 | - this->OutputLog(boost::format("Calculated RFO step size = %f\n") % normStep); | |
362 | + this->OutputLog(boost::format(this->formatLowestHessianEigenvalue) % vectorEigenValues[0]); | |
363 | + this->OutputLog(boost::format(this->format2ndLowestHessianEigenvalue) % vectorEigenValues[1]); | |
364 | + this->OutputLog(boost::format(this->format3rdLowestHessianEigenvalue) % vectorEigenValues[2]); | |
365 | + this->OutputLog(boost::format(this->formatRFOStepSize) % normStep); | |
366 | + this->OutputLog(boost::format(this->formatTrustRadiusIs) % trustRadius); | |
342 | 367 | |
343 | - this->OutputLog(boost::format("Trust radius is %f\n") % trustRadius); | |
344 | 368 | // Limit the step size to trustRadius |
345 | 369 | if(normStep > trustRadius){ |
346 | 370 | alpha *= normStep / trustRadius * 1.1; // 1.1 is speed up factor |
347 | - this->OutputLog(boost::format("Scaling factor is increased to %e.\n") % alpha); | |
348 | - this->OutputLog("Recalculating RFO step...\n"); | |
371 | + this->OutputLog(boost::format(this->formatTrustRadiusIs) % alpha); | |
372 | + this->OutputLog(this->messageRecalculateRFOStep); | |
349 | 373 | } |
350 | 374 | }while(normStep > trustRadius); |
351 | 375 | } |
@@ -506,7 +530,7 @@ void BFGS::ShiftHessianRedundantMode(double** matrixHessian, | ||
506 | 530 | calcEigenVectors); |
507 | 531 | |
508 | 532 | // Output eigenvalues of the raw Hessianto the log |
509 | - this->OutputLog("Eigenvalues of the raw Hessian:"); | |
533 | + this->OutputLog(this->messageRawHessianEigenvalues); | |
510 | 534 | for(int i=0;i<dimension;i++){ |
511 | 535 | if((i%6) == 0){ |
512 | 536 | this->OutputLog(boost::format("\n%e")%vectorHessianEigenValues[i]); |
@@ -557,7 +581,7 @@ void BFGS::ShiftHessianRedundantMode(double** matrixHessian, | ||
557 | 581 | } |
558 | 582 | |
559 | 583 | // Output eigenvalues of the raw Hessianto the log |
560 | - this->OutputLog("Eigenvalues of the level shifted hessian:"); | |
584 | + this->OutputLog(this->messageShiftedHessianEigenvalues); | |
561 | 585 | for(int i=0;i<dimension;i++){ |
562 | 586 | if((i%6) == 0){ |
563 | 587 | this->OutputLog(boost::format("\n%e")%vectorHessianEigenValues[i]); |
@@ -29,7 +29,21 @@ protected: | ||
29 | 29 | void SetMessages(); |
30 | 30 | private: |
31 | 31 | std::string errorMessageNaNInRFOStep; |
32 | + | |
32 | 33 | std::string messageStartBFGSStep; |
34 | + std::string messageHillClimbing; | |
35 | + std::string messageRecalculateRFOStep; | |
36 | + std::string messageRawHessianEigenvalues; | |
37 | + std::string messageShiftedHessianEigenvalues; | |
38 | + | |
39 | + std::string formatEnergyChangeComparison; | |
40 | + std::string formatLowestHessianEigenvalue; | |
41 | + std::string format2ndLowestHessianEigenvalue; | |
42 | + std::string format3rdLowestHessianEigenvalue; | |
43 | + std::string formatRFOStepSize; | |
44 | + std::string formatTrustRadiusIs; | |
45 | + std::string formatIncreaseScalingFactor; | |
46 | + | |
33 | 47 | virtual void SearchMinimum(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure, |
34 | 48 | MolDS_base::Molecule& molecule, |
35 | 49 | double* lineSearchedEnergy, |