ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Minimizer.hpp
Revision: 1031
Committed: Fri Feb 6 18:58:06 2004 UTC (20 years, 5 months ago) by tim
File size: 1968 byte(s)
Log Message:
Add some lines into global.cpp to make it work with energy minimization

File Contents

# Content
1 #ifndef _MINIMIZER_H_
2 #define _MINIMIZER_H_
3 #include "MinimizerBase.hpp"
4 #include "Minimizer1D.hpp"
5 typedef enum {GoldenSection, Brent} LineSearchStrategy;
6 class Minimizer : public MinimizerBase{
7
8 public:
9 Minimizer(MinimizerParameterSet* param) : paramSet(param), outputFunc(NULL) {}
10
11 virtual void printMinizerInfo() = 0;
12 void init() {}
13
14
15 void setOutputFunctor(OutputFunctor* functor) {outputFunc = functor;}
16 virtual void writeOut(vector<double>& x, int iter){
17 if (outputFunc !=NULL)
18 (*outputFunc)(x, iter);
19 }
20
21 void setMinX(vector<double>& x) { minX = x;}
22 vector<double> getMinX() { return minX;}
23
24 void setPrevMinX(vector<double>& x) { prevMinX = x;}
25 vector<double> getPrevMinX() {return prevMinX;}
26
27 int getCurrentIteration() {return currentIter;}
28
29 protected:
30
31 MinimizerParameterSet* paramSet;
32 OutputFunctor* outputFunc;
33 int currentIter;
34
35 // Coordinates yielding the minimum value of the function.
36 vector<double> minX;
37
38 // Vector holding the previous point.
39 vector<double> prevMinX;
40 };
41
42 class MinimizerUsingLineSearch : public Minimizer{
43 public:
44 MinimizerUsingLineSearch(MinimizerParameterSet* param) : Minimizer(param), lineSearchInit(false){}
45 void setLineSearchStrategy(NLModel* nlp, LineSearchStrategy stategy){
46
47 if(stategy == GoldenSection)
48 lsMinimizer = new GoldenSectionMinimizer(nlp);
49
50 else if(stategy == Brent)
51 lsMinimizer = new BrentMinimizer(nlp);
52
53 else{
54 cerr << "MinimizerUsingLineSearch Error : Unknown Line Search Strategy" << endl;
55 exit(-1);
56 }
57
58 lsMinimizer->setMaxIteration(paramSet->getLineSearchMaxIteration());
59 lsMinimizer->setStepTol(paramSet->getLineSearchTol());
60
61 lineSearchInit = true;
62 }
63
64 protected:
65
66 Minimizer1D* lsMinimizer;
67 bool lineSearchInit;
68 };
69
70 #endif

Properties

Name Value
svn:executable *