From d461b86d60edd1f3847fb2a18ab14db5d122e4b1 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Tue, 22 Jan 2019 17:13:13 +0100 Subject: [PATCH] abs->fabs fixes and other improvements --- examples/ex3/main.cpp | 2 +- src/ConjugateGradientTargetFunction.hpp | 2 +- src/NoisyStochasticReconfigurationOptimization.hpp | 2 +- src/StochasticReconfigurationOptimization.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/ex3/main.cpp b/examples/ex3/main.cpp index b97bcda..4d45afe 100644 --- a/examples/ex3/main.cpp +++ b/examples/ex3/main.cpp @@ -102,7 +102,7 @@ int main(){ cout << endl << " - - - WAVE FUNCTION OPTIMIZATION - - - " << endl << endl; - const long NMC = 2000l; // MC samplings to use for computing the energy + const long NMC = 20000l; // MC samplings to use for computing the energy double * energy = new double[4]; // energy double * d_energy = new double[4]; // energy error bar double * vp = new double[psi->getNVP()]; diff --git a/src/ConjugateGradientTargetFunction.hpp b/src/ConjugateGradientTargetFunction.hpp index f620e8c..0974967 100644 --- a/src/ConjugateGradientTargetFunction.hpp +++ b/src/ConjugateGradientTargetFunction.hpp @@ -86,7 +86,7 @@ class ConjugateGradientTargetFunction: public NoisyFunctionWithGradient // compute direction (or gradient) to follow for (int i=0; i<_wf->getNVP(); ++i){ grad_E[i] = 2.*( HOi[i] - H[0]*Oi[i] ); - dgrad_E[i] = 2.*( dHOi[i] + abs(H[0]*Oi[i])*(dH[0]/H[0]+dOi[i]/Oi[i]) ); + dgrad_E[i] = 2.*( dHOi[i] + fabs(H[0]*Oi[i])*(dH[0]/H[0]+dOi[i]/Oi[i]) ); } if (_lambda_reg > 0.) { // compute the regularization derivative diff --git a/src/NoisyStochasticReconfigurationOptimization.hpp b/src/NoisyStochasticReconfigurationOptimization.hpp index 416e37a..972bcea 100644 --- a/src/NoisyStochasticReconfigurationOptimization.hpp +++ b/src/NoisyStochasticReconfigurationOptimization.hpp @@ -23,7 +23,7 @@ class NoisyStochasticReconfigurationOptimization: public WFOptimization{ // optimization void optimizeWF(){ // create targetfunction - NoisyStochasticReconfigurationTargetFunction * targetf = new NoisyStochasticReconfigurationTargetFunction(_wf, _H, getMCI(), _Nmc); + NoisyStochasticReconfigurationTargetFunction * targetf = new NoisyStochasticReconfigurationTargetFunction(_wf, _H, getMCI(), _Nmc, 0., true); // declare the Dynamic Descent object DynamicDescent * ddesc = new DynamicDescent(targetf); // allocate an array that will contain the wave function variational parameters diff --git a/src/StochasticReconfigurationOptimization.cpp b/src/StochasticReconfigurationOptimization.cpp index 283bb4f..9325557 100644 --- a/src/StochasticReconfigurationOptimization.cpp +++ b/src/StochasticReconfigurationOptimization.cpp @@ -40,7 +40,7 @@ namespace sropt_details { } // perform the integral and store the values - MPIVMC::Integrate(w.mci, w.Nmc, obs, dobs, true, true); + MPIVMC::Integrate(w.mci, w.Nmc, obs, dobs, true, false); // clear w.mci->clearObservables(); @@ -81,7 +81,7 @@ namespace sropt_details { for (int j=0; j