ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/minimizers/CGFamilyMinimizer.cpp
Revision: 1902
Committed: Wed Jan 5 17:35:19 2005 UTC (19 years, 6 months ago) by tim
File size: 1813 byte(s)
Log Message:
minimizer in progress

File Contents

# Content
1 #include <cmath>
2
3 #include "minimizers/CGFamilyMinimizer.hpp"
4 #include "primitives/Molecule.hpp"
5 #include "utils/Utility.hpp"
6
7 namespace oopse {
8
9 CGFamilyMinimizer::CGFamilyMinimizer(SimInfo *info) : Minimizer(info){
10 prevG.resize(ndim);
11 prevX.resize(ndim);
12 direction.resize(ndim);
13
14 stepSize = paramSet->getStepSize();
15 }
16
17 int CGFamilyMinimizer::checkConvg(){
18 double fTol;
19 double relativeFTol; // relative tolerance
20 double deltaF;
21 double gTol;
22 double relativeGTol;
23 double gnorm;
24
25
26 // test function tolerance test
27 fTol =paramSet->getFTol();
28 relativeFTol = fTol * std::max(1.0,fabs(curF)); // relative tolerance
29 deltaF = prevF - curF;
30
31 if (fabs(deltaF) <= relativeFTol) {
32
33 if (bVerbose){
34 std::cout << "function value tolerance test passed" << std::endl;
35 std::cout << "ftol = " << fTol
36 << "\tdeltaf = " << deltaF<< std::endl;
37 }
38 return CONVG_FTOL;
39 }
40
41 //gradient tolerance test
42 gTol = paramSet->getGTol();
43 relativeGTol = gTol * std::max(1.0,fabs(curF));
44
45 #ifndef IS_MPI
46 gnorm = sqrt(dotProduct(curG, curG));
47 #else
48 double localDP;
49 double globalDP;
50
51 localDP = dotProduct(curG, curG);
52 MPI_Allreduce(&localDP, &globalDP, 1, MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
53 gnorm = sqrt(globalDP);
54 #endif
55
56 if (gnorm <= relativeGTol) {
57 std::cout << "gradient tolerance test" << std::endl;
58 std::cout << "gnorm = " << gnorm
59 << "\trelativeGTol = " << relativeGTol<< std::endl;
60 return CONVG_GTOL;
61 }
62
63 //absolute gradient tolerance test
64
65 if (gnorm <= gTol) {
66 std::cout << "absolute gradient tolerance test" << std::endl;
67 std::cout << "gnorm = " << gnorm
68 << "\tgTol = " << gTol<< std::endl;
69 return CONVG_ABSGTOL;
70 }
71
72 // did not converge yet
73 return CONVG_UNCONVG;
74 }
75
76 }

Properties

Name Value
svn:executable *