ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/minimizers/CGFamilyMinimizer.cpp
Revision: 1900
Committed: Tue Jan 4 22:18:06 2005 UTC (20 years, 4 months ago) by tim
File size: 1818 byte(s)
Log Message:
minimizers in progress

File Contents

# User Rev Content
1 tim 1884 #include <cmath>
2 gezelter 1490
3 tim 1900 #include "minimizers/CGFamilyMinimizer.hpp"
4     #include "primitives/Molecule.hpp"
5 tim 1492 #include "utils/Utility.hpp"
6 gezelter 1490
7 tim 1900 namespace oopse {
8 gezelter 1490
9 tim 1900 CGFamilyMinimizer::CGFamilyMinimizer(SimInfo *info) : OOPSEMinimizer(info){
10     prevG.resize(ndim);
11     prevX.resize(ndim);
12     direction.resize(ndim);
13 gezelter 1490
14 tim 1900 stepSize = paramSet->getStepSize();
15 gezelter 1490 }
16 tim 1900
17     int CGFamilyMinimizer::checkConvg(){
18 gezelter 1490 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 tim 1900 std::cout << "function value tolerance test passed" << std::endl;
35     std::cout << "ftol = " << fTol
36 tim 1830 << "\tdeltaf = " << deltaF<< std::endl;
37 gezelter 1490 }
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 tim 1900 std::cout << "gradient tolerance test" << std::endl;
58     std::cout << "gnorm = " << gnorm
59 tim 1830 << "\trelativeGTol = " << relativeGTol<< std::endl;
60 gezelter 1490 return CONVG_GTOL;
61     }
62    
63     //absolute gradient tolerance test
64    
65     if (gnorm <= gTol) {
66 tim 1900 std::cout << "absolute gradient tolerance test" << std::endl;
67     std::cout << "gnorm = " << gnorm
68 tim 1830 << "\tgTol = " << gTol<< std::endl;
69 gezelter 1490 return CONVG_ABSGTOL;
70     }
71    
72     // did not converge yet
73     return CONVG_UNCONVG;
74     }
75    
76 tim 1900 }

Properties

Name Value
svn:executable *