• 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ón58acae003a8d93744ca20ebc970a7c63396810b0 (tree)
Tiempo2013-08-08 19:43:39
AutorKatsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Log Message

Factor out BFGS::UpdateTrustRadius. #31856

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

Cambiar Resumen

Diferencia incremental

--- a/src/optimization/BFGS.cpp
+++ b/src/optimization/BFGS.cpp
@@ -186,15 +186,7 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct
186186 }
187187 this->OutputMoleculeElectronicStructure(electronicStructure, molecule, this->CanOutputLogs());
188188
189- // Calculate the correctness of the approximation
190- double r = (lineSearchCurrentEnergy - lineSearchInitialEnergy)
191- / approximateChange; // correctness of the step
192- bool aproxcheckCanOutputLogs = true;
193- tempCanOutputLogs = molecule.CanOutputLogs();
194- molecule.SetCanOutputLogs(aproxcheckCanOutputLogs);
195- this->OutputLog(boost::format(this->formatEnergyChangeComparison)
196- % (lineSearchCurrentEnergy-lineSearchInitialEnergy) % approximateChange % r);
197- molecule.SetCanOutputLogs(tempCanOutputLogs);
189+ this->UpdateTrustRadius(trustRadius, approximateChange, lineSearchInitialEnergy, lineSearchCurrentEnergy);
198190
199191 // check convergence
200192 if(this->SatisfiesConvergenceCriterion(matrixForce,
@@ -207,9 +199,7 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct
207199 break;
208200 }
209201
210- // Update the trust radius
211- if(r < 0)
212- {
202+ if(lineSearchCurrentEnergy > lineSearchInitialEnergy){
213203 // Rollback molecular geometry
214204 bool tempCanOutputLogs = molecule.CanOutputLogs();
215205 bool rollbackCanOutputLogs = true;
@@ -224,23 +214,8 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct
224214 }
225215 lineSearchCurrentEnergy = lineSearchInitialEnergy;
226216 molecule.SetCanOutputLogs(tempCanOutputLogs);
227- // and rerun with smaller trust radius
228- // without updating Hessian
229- trustRadius /= 4;
230- continue;
231- }
232- else if(r<0.25){
233- trustRadius /= 4;
234- }
235- else if(r<0.75){
236- // keep trust radius
237- }
238- else if(r<2){
239- trustRadius *= 2;
240- }
241- else{
242- trustRadius /= 2;
243217 }
218+
244219 //Calculate displacement (K_k at Eq. (15) in [SJTO_1983])
245220 MallocerFreer::GetInstance()->Malloc(&matrixDisplacement, molecule.GetNumberAtoms(), CartesianType_end);
246221 for(int i=0;i<molecule.GetNumberAtoms();i++){
@@ -555,8 +530,37 @@ double BFGS::ApproximateEnergyChange(int dimension,
555530 approximateChangeDenominator += vectorStep[i] * vectorStep[i];
556531 for(int j=0;j<dimension;j++){
557532 approximateChangeNumerator += vectorStep[i] * matrixHessian[i][j] * vectorStep[j] / 2;
558- }
559533 }
560- return approximateChangeNumerator / approximateChangeDenominator;
561534 }
535+ return approximateChangeNumerator / approximateChangeDenominator;
536+}
537+
538+void BFGS::UpdateTrustRadius(double &trustRadius,
539+ double approximateEnergyChange,
540+ double initialEnergy,
541+ double currentEnergy)const{
542+ // Calculate the correctness of the approximation
543+ double r = (currentEnergy - initialEnergy)
544+ / approximateEnergyChange;
545+
546+ this->OutputLog(boost::format(this->formatEnergyChangeComparison)
547+ % (currentEnergy-initialEnergy) % approximateEnergyChange % r);
548+
549+ if(r < 0)
550+ {
551+ trustRadius /= 4;
552+ }
553+ else if(r<0.25){
554+ trustRadius /= 4;
555+ }
556+ else if(r<0.75){
557+ // keep trust radius
558+ }
559+ else if(r<2){
560+ trustRadius *= 2;
561+ }
562+ else{
563+ trustRadius /= 2;
564+ }
565+}
562566 }
--- a/src/optimization/BFGS.h
+++ b/src/optimization/BFGS.h
@@ -67,6 +67,10 @@ protected:
6767 double const* const* matrixHessian,
6868 double const* vectorForce,
6969 double const* vectorStep) const;
70+ void UpdateTrustRadius(double &trustRadius,
71+ double approximateEnergyChange,
72+ double currentEnergy,
73+ double initialEnergy)const;
7074 };
7175
7276 }