• 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

Revisiónaecfbc26e42b5f4783b6f08966acc433b95c14a1 (tree)
Tiempo2014-01-11 21:21:39
AutorKatsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Log Message

Factor Out OutputOptimizationStepMessage. #32881

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/branches/refactor_opt@1642 1136aad2-a195-0410-b898-f5ea1d11b9d8

Cambiar Resumen

Diferencia incremental

--- a/src/optimization/BFGS.cpp
+++ b/src/optimization/BFGS.cpp
@@ -150,7 +150,7 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct
150150 this->InitializeState(state, molecule);
151151
152152 for(int s=0; s<totalSteps; s++){
153- this->OutputLog(boost::format("%s%d\n\n") % this->messageStartBFGSStep % (s+1));
153+ this->OutputOptimizationStepMessage(s);
154154
155155 // Store old Force data
156156 MolDS_wrappers::Blas::GetInstance()->Dcopy(dimension,
--- a/src/optimization/BFGS.h
+++ b/src/optimization/BFGS.h
@@ -72,6 +72,9 @@ protected:
7272 std::string formatIncreaseScalingFactor;
7373
7474 private:
75+ const std::string& OptimizationStepMessage() const{
76+ return this->messageStartBFGSStep;
77+ }
7578 virtual void SearchMinimum(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure,
7679 MolDS_base::Molecule& molecule,
7780 double* lineSearchedEnergy,
--- a/src/optimization/ConjugateGradient.cpp
+++ b/src/optimization/ConjugateGradient.cpp
@@ -100,7 +100,7 @@ void ConjugateGradient::SearchMinimum(boost::shared_ptr<ElectronicStructure> ele
100100
101101 // conugate gradient loop
102102 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);
104104 state.SetInitialEnergy(state.GetCurrentEnergy());
105105
106106 // do line search
--- a/src/optimization/ConjugateGradient.h
+++ b/src/optimization/ConjugateGradient.h
@@ -41,6 +41,9 @@ protected:
4141 void SetMessages();
4242 private:
4343 std::string messageStartConjugateGradientStep;
44+ const std::string& OptimizationStepMessage() const{
45+ return this->messageStartConjugateGradientStep;
46+ }
4447 void SearchMinimum(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure,
4548 MolDS_base::Molecule& molecule,
4649 double* lineSearchedEnergy,
--- a/src/optimization/Optimizer.cpp
+++ b/src/optimization/Optimizer.cpp
@@ -195,6 +195,10 @@ void Optimizer::OutputMoleculeElectronicStructure(boost::shared_ptr<ElectronicSt
195195 }
196196 }
197197
198+void Optimizer::OutputOptimizationStepMessage(int nthStep) const{
199+ this->OutputLog(boost::format("%s%d\n\n") % this->OptimizationStepMessage() % (nthStep+1));
200+}
201+
198202 void Optimizer::LineSearch(boost::shared_ptr<ElectronicStructure> electronicStructure,
199203 MolDS_base::Molecule& molecule,
200204 double& lineSearchCurrentEnergy,
--- a/src/optimization/Optimizer.h
+++ b/src/optimization/Optimizer.h
@@ -76,6 +76,7 @@ protected:
7676 void OutputMoleculeElectronicStructure(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure,
7777 MolDS_base::Molecule& molecule,
7878 bool printsLogs) const;
79+ void OutputOptimizationStepMessage(int nthStep) const;
7980 void LineSearch(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure,
8081 MolDS_base::Molecule& molecule,
8182 double &lineSearchCurrentEnergy,
@@ -103,6 +104,7 @@ private:
103104 double* lineSearchedEnergy,
104105 bool* obainesOptimizedStructure) const = 0;
105106 virtual void InitializeState(OptimizerState &state, const MolDS_base::Molecule& molecule) const = 0;
107+ virtual const std::string& OptimizationStepMessage() const = 0;
106108 };
107109
108110 }
--- a/src/optimization/SteepestDescent.h
+++ b/src/optimization/SteepestDescent.h
@@ -29,6 +29,9 @@ protected:
2929 void SetMessages();
3030 private:
3131 std::string messageStartSteepestDescentStep;
32+ const std::string& OptimizationStepMessage() const{
33+ return this->messageStartSteepestDescentStep;
34+ }
3235 void SearchMinimum(boost::shared_ptr<MolDS_base::ElectronicStructure> electronicStructure,
3336 MolDS_base::Molecule& molecule,
3437 double* lineSearchedEnergy,