• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Révision58525f1df6f49bf6e6f24a5d0c277365730007f3 (tree)
l'heure2014-01-09 14:47:43
AuteurKatsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Message de Log

Fix BFGS rollback code. #32879

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

Change Summary

Modification

--- a/src/optimization/BFGS.cpp
+++ b/src/optimization/BFGS.cpp
@@ -145,7 +145,9 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct
145145
146146 // Store old Force data
147147 MallocerFreer::GetInstance()->Malloc(&vectorOldForce, dimension);
148- MolDS_wrappers::Blas::GetInstance()->Dcopy(dimension, vectorForce, vectorOldForce);
148+ MolDS_wrappers::Blas::GetInstance()->Dcopy(dimension,
149+ static_cast<double const*>(vectorForce),
150+ vectorOldForce);
149151
150152 this->StoreMolecularGeometry(matrixOldCoordinates, molecule);
151153
@@ -194,21 +196,27 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct
194196 break;
195197 }
196198
197- if(lineSearchCurrentEnergy > lineSearchInitialEnergy){
199+ //Calculate displacement (K_k at Eq. (15) in [SJTO_1983])
200+ this->CalcDisplacement(matrixDisplacement, matrixOldCoordinates, molecule);
201+
202+ //Rollback geometry and energy if energy increases
203+ bool isHillClimbing = lineSearchCurrentEnergy > lineSearchInitialEnergy;
204+ if(isHillClimbing){
198205 this->OutputLog(this->messageHillClimbing);
199206 this->RollbackMolecularGeometry(molecule, matrixOldCoordinates);
200207 lineSearchCurrentEnergy = lineSearchInitialEnergy;
201208 }
202209
203- //Calculate displacement (K_k at Eq. (15) in [SJTO_1983])
204- this->CalcDisplacement(matrixDisplacement, matrixOldCoordinates, molecule);
205-
206210 matrixForce = electronicStructure->GetForce(elecState);
207211 vectorForce = &matrixForce[0][0];
208212
209213 // Update Hessian
210214 this->UpdateHessian(matrixHessian, dimension, vectorForce, vectorOldForce, &matrixDisplacement[0][0]);
211215
216+ //Rollback gradient if energy increases
217+ if(isHillClimbing){
218+ vectorForce = vectorOldForce;
219+ }
212220 }
213221 *lineSearchedEnergy = lineSearchCurrentEnergy;
214222 }