Révision | 704481b6b72da1f7244469e4b191fb509359ea54 (tree) |
---|---|
l'heure | 2012-07-02 15:47:44 |
Auteur | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
Implemented input parsing routine for BFGS method. #28764
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@854 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -53,6 +53,7 @@ RENUMSTR_END() | ||
53 | 53 | RENUMSTR_BEGIN( OptimizationMethodType, OptimizationMethodTypeStr ) |
54 | 54 | RENUMSTR( ConjugateGradientMethod, "Conjugate gradient" ) |
55 | 55 | RENUMSTR( SteepestDescentMethod, "Steepest descent" ) |
56 | + RENUMSTR( BFGSMethod, "BFGS" ) | |
56 | 57 | RENUMSTR( OptimizationMethodType_end, "OptimizationMethodType_end" ) |
57 | 58 | RENUMSTR_END() |
58 | 59 |
@@ -312,6 +312,7 @@ void InputParser::SetMessages(){ | ||
312 | 312 | this->stringOptimization = "optimization"; |
313 | 313 | this->stringOptimizationEnd = "optimization_end"; |
314 | 314 | this->stringOptimizationMethod = "method"; |
315 | + this->stringOptimizationBFGS = "bfgs"; | |
315 | 316 | this->stringOptimizationConjugateGradient = "conjugate_gradient"; |
316 | 317 | this->stringOptimizationSteepestDescent = "steepest_descent"; |
317 | 318 | this->stringOptimizationTotalSteps = "total_steps"; |
@@ -865,6 +866,9 @@ int InputParser::ParseConditionsOptimization(vector<string>* inputTerms, int par | ||
865 | 866 | else if((*inputTerms)[parseIndex+1].compare(this->stringOptimizationSteepestDescent) == 0){ |
866 | 867 | Parameters::GetInstance()->SetMethodOptimization(SteepestDescentMethod); |
867 | 868 | } |
869 | + else if((*inputTerms)[parseIndex+1].compare(this->stringOptimizationBFGS) == 0){ | |
870 | + Parameters::GetInstance()->SetMethodOptimization(BFGSMethod); | |
871 | + } | |
868 | 872 | else{ |
869 | 873 | } |
870 | 874 | parseIndex++; |
@@ -1430,9 +1434,17 @@ void InputParser::OutputOptimizationConditions() const{ | ||
1430 | 1434 | % Parameters::GetInstance()->GetMaxGradientOptimization()).str()); |
1431 | 1435 | this->OutputLog((boost::format("%s%lf\n") % this->messageOptimizationRmsGradient.c_str() |
1432 | 1436 | % Parameters::GetInstance()->GetRmsGradientOptimization()).str()); |
1433 | - this->OutputLog((boost::format("%s%lf%s\n") % this->messageOptimizationTimeWidth.c_str() | |
1434 | - % (Parameters::GetInstance()->GetTimeWidthOptimization()/Parameters::GetInstance()->GetFs2AU()) | |
1435 | - % this->messageFs.c_str()).str()); | |
1437 | + | |
1438 | + switch(Parameters::GetInstance()->GetMethodOptimization()){ | |
1439 | + case ConjugateGradientMethod: | |
1440 | + case SteepestDescentMethod: | |
1441 | + this->OutputLog((boost::format("%s%lf%s\n") % this->messageOptimizationTimeWidth.c_str() | |
1442 | + % (Parameters::GetInstance()->GetTimeWidthOptimization()/Parameters::GetInstance()->GetFs2AU()) | |
1443 | + % this->messageFs.c_str()).str()); | |
1444 | + break; | |
1445 | + default: | |
1446 | + break; | |
1447 | + } | |
1436 | 1448 | |
1437 | 1449 | this->OutputLog("\n"); |
1438 | 1450 | } |
@@ -241,6 +241,7 @@ private: | ||
241 | 241 | std::string stringOptimization; |
242 | 242 | std::string stringOptimizationEnd; |
243 | 243 | std::string stringOptimizationMethod; |
244 | + std::string stringOptimizationBFGS; | |
244 | 245 | std::string stringOptimizationConjugateGradient; |
245 | 246 | std::string stringOptimizationSteepestDescent; |
246 | 247 | std::string stringOptimizationTotalSteps; |
@@ -35,6 +35,7 @@ | ||
35 | 35 | #include"../ElectronicStructure.h" |
36 | 36 | #include"../../optimization/Optimizer.h" |
37 | 37 | #include"../../optimization/ConjugateGradient.h" |
38 | +#include"../../optimization/BFGS.h" | |
38 | 39 | #include"../../optimization/SteepestDescent.h" |
39 | 40 | #include"OptimizerFactory.h" |
40 | 41 | using namespace std; |
@@ -49,6 +50,9 @@ MolDS_optimization::Optimizer* OptimizerFactory::Create(OptimizationMethodType m | ||
49 | 50 | if(methodType == ConjugateGradientMethod ){ |
50 | 51 | optimizer = new MolDS_optimization::ConjugateGradient(); |
51 | 52 | } |
53 | + else if(methodType == BFGSMethod ){ | |
54 | + optimizer = new MolDS_optimization::BFGS(); | |
55 | + } | |
52 | 56 | else if(methodType == SteepestDescentMethod ){ |
53 | 57 | optimizer = new MolDS_optimization::SteepestDescent(); |
54 | 58 | } |