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: 1830
Committed: Thu Dec 2 05:17:10 2004 UTC (19 years, 8 months ago) by tim
File size: 2261 byte(s)
Log Message:
change endl to std::endl

File Contents

# User Rev Content
1 gezelter 1490 #include <math.h>
2    
3 tim 1492 #include "minimizers/OOPSEMinimizer.hpp"
4     #include "utils/Utility.hpp"
5 gezelter 1490
6     CGFamilyMinmizer::CGFamilyMinmizer(SimInfo *theInfo, ForceFields* the_ff ,
7     MinimizerParameterSet * param)
8     :OOPSEMinimizer(theInfo, the_ff, param){
9     prevG.resize(ndim);
10     prevX.resize(ndim);
11     direction.resize(ndim);
12    
13     stepSize = paramSet->getStepSize();
14    
15     }
16     int CGFamilyMinmizer::checkConvg(){
17     double fTol;
18     double relativeFTol; // relative tolerance
19     double deltaF;
20     double gTol;
21     double relativeGTol;
22     double gnorm;
23    
24    
25     // test function tolerance test
26     fTol =paramSet->getFTol();
27     relativeFTol = fTol * std::max(1.0,fabs(curF)); // relative tolerance
28     deltaF = prevF - curF;
29    
30     if (fabs(deltaF) <= relativeFTol) {
31    
32     if (bVerbose){
33 tim 1830 cout << "function value tolerance test passed" << std::endl;
34 gezelter 1490 cout << "ftol = " << fTol
35 tim 1830 << "\tdeltaf = " << deltaF<< std::endl;
36 gezelter 1490 }
37     return CONVG_FTOL;
38     }
39    
40     //gradient tolerance test
41     gTol = paramSet->getGTol();
42     relativeGTol = gTol * std::max(1.0,fabs(curF));
43    
44     #ifndef IS_MPI
45     gnorm = sqrt(dotProduct(curG, curG));
46     #else
47     double localDP;
48     double globalDP;
49    
50     localDP = dotProduct(curG, curG);
51     MPI_Allreduce(&localDP, &globalDP, 1, MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
52     gnorm = sqrt(globalDP);
53     #endif
54    
55     if (gnorm <= relativeGTol) {
56 tim 1830 cout << "gradient tolerance test" << std::endl;
57 gezelter 1490 cout << "gnorm = " << gnorm
58 tim 1830 << "\trelativeGTol = " << relativeGTol<< std::endl;
59 gezelter 1490 return CONVG_GTOL;
60     }
61    
62     //absolute gradient tolerance test
63    
64     if (gnorm <= gTol) {
65 tim 1830 cout << "absolute gradient tolerance test" << std::endl;
66 gezelter 1490 cout << "gnorm = " << gnorm
67 tim 1830 << "\tgTol = " << gTol<< std::endl;
68 gezelter 1490 return CONVG_ABSGTOL;
69     }
70    
71     /*
72     //test step tolerance test
73    
74     double stepTol = paramSet->getStepTol();
75     double snorm = stepTolNorm();
76     double xnorm = Norm2(curX);
77     double sTol = stepTol*max(1.0, xnorm);
78     if (snorm <= sTol) {
79 tim 1830 cout << "step tolerance test passed" << std::endl;
80 gezelter 1490 cout << "stol = " << sTol
81 tim 1830 << "\tsnorm = " << snorm<< std::endl;
82 gezelter 1490 return CONVG_STEPTOL;
83     }
84     */
85     // did not converge yet
86     return CONVG_UNCONVG;
87     }
88    

Properties

Name Value
svn:executable *