Revisión | aecfbc26e42b5f4783b6f08966acc433b95c14a1 (tree) |
---|---|
Tiempo | 2014-01-11 21:21:39 |
Autor | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
Factor Out OutputOptimizationStepMessage. #32881
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/branches/refactor_opt@1642 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -150,7 +150,7 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct | ||
150 | 150 | this->InitializeState(state, molecule); |
151 | 151 | |
152 | 152 | for(int s=0; s<totalSteps; s++){ |
153 | - this->OutputLog(boost::format("%s%d\n\n") % this->messageStartBFGSStep % (s+1)); | |
153 | + this->OutputOptimizationStepMessage(s); | |
154 | 154 | |
155 | 155 | // Store old Force data |
156 | 156 | MolDS_wrappers::Blas::GetInstance()->Dcopy(dimension, |
@@ -72,6 +72,9 @@ protected: | ||
72 | 72 | std::string formatIncreaseScalingFactor; |
73 | 73 | |
74 | 74 | private: |
75 | + const std::string& OptimizationStepMessage() const{ | |
76 | + return this->messageStartBFGSStep; | |
77 | + } | |
75 | 78 | virtual void SearchMinimum(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure, |
76 | 79 | MolDS_base::Molecule& molecule, |
77 | 80 | double* lineSearchedEnergy, |
@@ -100,7 +100,7 @@ void ConjugateGradient::SearchMinimum(boost::shared_ptr<ElectronicStructure> ele | ||
100 | 100 | |
101 | 101 | // conugate gradient loop |
102 | 102 | for(int s=0; s<totalSteps; s++){ |
103 | - this->OutputLog(boost::format("%s%d\n\n") % this->messageStartConjugateGradientStep.c_str() % (s+1)); | |
103 | + this->OutputOptimizationStepMessage(s); | |
104 | 104 | state.SetInitialEnergy(state.GetCurrentEnergy()); |
105 | 105 | |
106 | 106 | // do line search |
@@ -41,6 +41,9 @@ protected: | ||
41 | 41 | void SetMessages(); |
42 | 42 | private: |
43 | 43 | std::string messageStartConjugateGradientStep; |
44 | + const std::string& OptimizationStepMessage() const{ | |
45 | + return this->messageStartConjugateGradientStep; | |
46 | + } | |
44 | 47 | void SearchMinimum(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure, |
45 | 48 | MolDS_base::Molecule& molecule, |
46 | 49 | double* lineSearchedEnergy, |
@@ -195,6 +195,10 @@ void Optimizer::OutputMoleculeElectronicStructure(boost::shared_ptr<ElectronicSt | ||
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | +void Optimizer::OutputOptimizationStepMessage(int nthStep) const{ | |
199 | + this->OutputLog(boost::format("%s%d\n\n") % this->OptimizationStepMessage() % (nthStep+1)); | |
200 | +} | |
201 | + | |
198 | 202 | void Optimizer::LineSearch(boost::shared_ptr<ElectronicStructure> electronicStructure, |
199 | 203 | MolDS_base::Molecule& molecule, |
200 | 204 | double& lineSearchCurrentEnergy, |
@@ -76,6 +76,7 @@ protected: | ||
76 | 76 | void OutputMoleculeElectronicStructure(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure, |
77 | 77 | MolDS_base::Molecule& molecule, |
78 | 78 | bool printsLogs) const; |
79 | + void OutputOptimizationStepMessage(int nthStep) const; | |
79 | 80 | void LineSearch(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure, |
80 | 81 | MolDS_base::Molecule& molecule, |
81 | 82 | double &lineSearchCurrentEnergy, |
@@ -103,6 +104,7 @@ private: | ||
103 | 104 | double* lineSearchedEnergy, |
104 | 105 | bool* obainesOptimizedStructure) const = 0; |
105 | 106 | virtual void InitializeState(OptimizerState &state, const MolDS_base::Molecule& molecule) const = 0; |
107 | + virtual const std::string& OptimizationStepMessage() const = 0; | |
106 | 108 | }; |
107 | 109 | |
108 | 110 | } |
@@ -29,6 +29,9 @@ protected: | ||
29 | 29 | void SetMessages(); |
30 | 30 | private: |
31 | 31 | std::string messageStartSteepestDescentStep; |
32 | + const std::string& OptimizationStepMessage() const{ | |
33 | + return this->messageStartSteepestDescentStep; | |
34 | + } | |
32 | 35 | void SearchMinimum(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure, |
33 | 36 | MolDS_base::Molecule& molecule, |
34 | 37 | double* lineSearchedEnergy, |