• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision793c1ae342c7c14319749309cb0660aa1bb9fc41 (tree)
Time2012-11-27 16:55:06
AuthorKatsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Log Message

Set message strings in SetMessages. #28764

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1139 1136aad2-a195-0410-b898-f5ea1d11b9d8

Change Summary

Incremental Difference

--- a/src/optimization/BFGS.cpp
+++ b/src/optimization/BFGS.cpp
@@ -64,7 +64,36 @@ void BFGS::SetMessages(){
6464 = "Error in optimization::BFGS::Optimize: Optimization did not met convergence criterion.\n";
6565 this->errorMessageNaNInRFOStep
6666 = "Error in optimization::BFGS::Optimize: RFO step has gone NaN. (lambda * s[%d] = %e, lambda = %e, alpha = %e)\n";
67- this->messageStartBFGSStep = "\n========== START: BFGS step ";
67+
68+ this->messageStartBFGSStep
69+ = "\n========== START: BFGS step ";
70+ this->messageHillClimbing =
71+ "Detected hill climbing.\n"
72+ "Rolling back molecular geometry.\n";
73+ this->messageRecalculateRFOStep
74+ = "Recalculating RFO step...\n";
75+ this->messageRawHessianEigenvalues
76+ = "Eigenvalues of the raw Hessian:";
77+ this->messageShiftedHessianEigenvalues
78+ = "Eigenvalues of the level shifted hessian:";
79+
80+ this->formatEnergyChangeComparison =
81+ "\n"
82+ "actual energy change = %e\n"
83+ "expected energy change = %e\n"
84+ "actual/expected energy change = %f\n";
85+ this->formatLowestHessianEigenvalue
86+ = "Lowest eigenvalue of the augmented Hessian = %f\n";
87+ this->format2ndLowestHessianEigenvalue
88+ = "2nd lowest eigenvalue of the augmented Hessian = %f\n";
89+ this->format3rdLowestHessianEigenvalue
90+ = "3rd lowest eigenvalue of the augmented Hessian = %f\n";
91+ this->formatRFOStepSize
92+ = "Calculated RFO step size = %f\n";
93+ this->formatTrustRadiusIs
94+ = "Trust radius is %f\n";
95+ this->formatIncreaseScalingFactor
96+ = "Scaling factor is increased to %e.\n";
6897 }
6998
7099 void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStructure,
@@ -168,16 +197,12 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct
168197
169198 // Calculate the correctness of the approximation
170199 double r = (lineSearchCurrentEnergy - lineSearchInitialEnergy)
171- / approximateChange; // correctness of the step
200+ / approximateChange; // correctness of the step
172201 bool aproxcheckCanOutputLogs = true;
173202 tempCanOutputLogs = molecule.CanOutputLogs();
174203 molecule.SetCanOutputLogs(aproxcheckCanOutputLogs);
175- this->OutputLog(boost::format("\n"
176- "actual energy change = %e\n"
177- "expected energy change = %e\n"
178- "actual/expected energy change = %f\n")
179- % (lineSearchCurrentEnergy-lineSearchInitialEnergy)
180- % approximateChange % r);
204+ this->OutputLog(boost::format(this->formatEnergyChangeComparison)
205+ % (lineSearchCurrentEnergy-lineSearchInitialEnergy) % approximateChange % r);
181206 molecule.SetCanOutputLogs(tempCanOutputLogs);
182207
183208 // check convergence
@@ -198,8 +223,7 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct
198223 bool tempCanOutputLogs = molecule.CanOutputLogs();
199224 bool rollbackCanOutputLogs = true;
200225 molecule.SetCanOutputLogs(rollbackCanOutputLogs);
201- this->OutputLog("Detected hill climbing.\n"
202- "Rolling back molecular geometry.\n");
226+ this->OutputLog(this->messageHillClimbing);
203227 for(int i=0;i<molecule.GetNumberAtoms();i++){
204228 const Atom* atom = molecule.GetAtom(i);
205229 double* xyz = atom->GetXyz();
@@ -317,17 +341,17 @@ void BFGS::CalcRFOStep(double* vectorStep,
317341 }
318342 normStep = sqrt(normStep);
319343
320- this->OutputLog(boost::format("Lowest eigenvalue of the augmented Hessian = %f\n") % vectorEigenValues[0]);
321- this->OutputLog(boost::format("2nd lowest eigenvalue of the augmented Hessian = %f\n") % vectorEigenValues[1]);
322- this->OutputLog(boost::format("3rd lowest eigenvalue of the augmented Hessian = %f\n") % vectorEigenValues[2]);
323- this->OutputLog(boost::format("Calculated RFO step size = %f\n") % normStep);
344+ this->OutputLog(boost::format(this->formatLowestHessianEigenvalue) % vectorEigenValues[0]);
345+ this->OutputLog(boost::format(this->format2ndLowestHessianEigenvalue) % vectorEigenValues[1]);
346+ this->OutputLog(boost::format(this->format3rdLowestHessianEigenvalue) % vectorEigenValues[2]);
347+ this->OutputLog(boost::format(this->formatRFOStepSize) % normStep);
348+ this->OutputLog(boost::format(this->formatTrustRadiusIs) % trustRadius);
324349
325- this->OutputLog(boost::format("Trust radius is %f\n") % trustRadius);
326350 // Limit the step size to trustRadius
327351 if(normStep > trustRadius){
328352 alpha *= normStep / trustRadius * 1.1; // 1.1 is speed up factor
329- this->OutputLog(boost::format("Scaling factor is increased to %e.\n") % alpha);
330- this->OutputLog("Recalculating RFO step...\n");
353+ this->OutputLog(boost::format(this->formatTrustRadiusIs) % alpha);
354+ this->OutputLog(this->messageRecalculateRFOStep);
331355 }
332356 }while(normStep > trustRadius);
333357 }
@@ -488,7 +512,7 @@ void BFGS::ShiftHessianRedundantMode(double** matrixHessian,
488512 calcEigenVectors);
489513
490514 // Output eigenvalues of the raw Hessianto the log
491- this->OutputLog("Eigenvalues of the raw Hessian:");
515+ this->OutputLog(this->messageRawHessianEigenvalues);
492516 for(int i=0;i<dimension;i++){
493517 if((i%6) == 0){
494518 this->OutputLog(boost::format("\n%e")%vectorHessianEigenValues[i]);
@@ -539,7 +563,7 @@ void BFGS::ShiftHessianRedundantMode(double** matrixHessian,
539563 }
540564
541565 // Output eigenvalues of the raw Hessianto the log
542- this->OutputLog("Eigenvalues of the level shifted hessian:");
566+ this->OutputLog(this->messageShiftedHessianEigenvalues);
543567 for(int i=0;i<dimension;i++){
544568 if((i%6) == 0){
545569 this->OutputLog(boost::format("\n%e")%vectorHessianEigenValues[i]);
--- a/src/optimization/BFGS.h
+++ b/src/optimization/BFGS.h
@@ -29,7 +29,21 @@ protected:
2929 void SetMessages();
3030 private:
3131 std::string errorMessageNaNInRFOStep;
32+
3233 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+
3347 virtual void SearchMinimum(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure,
3448 MolDS_base::Molecule& molecule,
3549 double* lineSearchedEnergy,