ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Minimizer1D.hpp
Revision: 1023
Committed: Wed Feb 4 22:26:00 2004 UTC (21 years, 3 months ago) by tim
File size: 2322 byte(s)
Log Message:
Fix a bunch of bugs   :-)
Single version of conjugate gradient with golden search linesearch pass a couple of
functions test. Brent's  algorithm is still broken

File Contents

# Content
1 #ifndef _MINIMIZER1D_H_
2 #define _MINIMIZER1D_H_
3
4 #include "MinimizerBase.hpp"
5
6 //abstract class of one dimension minimizer for line searching
7 // optimize f(x+val*direction)
8 //some potential problem, such as which class is responsible for deleting NLModel,
9 //can be resolved by using smart pointer
10 class Minimizer1D : public MinimizerBase{
11
12 public:
13 Minimizer1D(NLModel* nlp) {model = nlp;}
14 virtual ~Minimizer1D() {}
15
16 virtual void init() {}
17 virtual bool isSolvable() {return true;}
18
19 virtual void minimize() = 0;
20 virtual void minimize(vector<double>& direction, double left, double right) = 0;
21
22 void setRange(double left, double right) {leftVar = left, rightVar= right;}
23 void setDirection(vector<double>& direction) {this->direction = direction;}
24 double getMinVar() {return minVar;}
25 double getPrevMinVar() {return prevMinVar;}
26
27 void setMaxIteration(int iter) {maxIteration = iter;}
28
29 int getMaxIteration() {return maxIteration;}
30 int getCurrentIteration() {return currentIter;}
31
32 void setStepTol(double tol) {stepTol =tol;}
33 double getStepTol() {return stepTol;}
34 protected:
35
36 NLModel* model;
37 double leftVar;
38 double rightVar;
39 double minVar;
40 double prevMinVar;
41
42 vector<double> direction;
43
44 int maxIteration;
45 int currentIter;
46 double stepTol;
47 };
48
49 class GoldenSectionMinimizer : public Minimizer1D{
50
51 public:
52
53 GoldenSectionMinimizer(NLModel* nlp);
54 void minimize();
55 virtual void minimize(vector<double>& direction, double left, double right){
56 setRange(left, right);
57 setDirection(direction);
58 minimize();
59 }
60 virtual int checkConvergence();
61
62 protected:
63
64 double fMinVar;
65 double fPrevMinVar;
66
67 double fAlpha;
68 double fBeta;
69 double alpha;
70 double beta;
71
72 };
73
74 class BrentMinimizer : public Minimizer1D{
75 public:
76
77 BrentMinimizer(NLModel* nlp);
78
79 void minimize();
80 virtual void minimize(vector<double>& direction, double left, double right){
81 setRange(left, right);
82 setDirection(direction);
83 minimize();
84 }
85 virtual int checkConvergence();
86 protected:
87
88 double fMinVar;
89 double fPrevMinVar;
90 double midVar;
91
92 };
93 #endif

Properties

Name Value
svn:executable *