ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Minimizer.hpp
Revision: 1023
Committed: Wed Feb 4 22:26:00 2004 UTC (20 years, 5 months ago) by tim
File size: 1709 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 _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;}
10
11 virtual void printMinizerInfo() = 0;
12 void init() {}
13 void setMinX(vector<double>& x) { minX = x;}
14 vector<double> getMinX() { return minX;}
15
16 void setPrevMinX(vector<double>& x) { prevMinX = x;}
17 vector<double> getPrevMinX() {return prevMinX;}
18
19 int getCurrentIteration() {return currentIter;}
20
21 protected:
22
23 MinimizerParameterSet* paramSet;
24 int currentIter;
25
26 // Coordinates yielding the minimum value of the function.
27 vector<double> minX;
28
29 // Vector holding the previous point.
30 vector<double> prevMinX;
31 };
32
33 class MinimizerUsingLineSearch : public Minimizer{
34 public:
35 MinimizerUsingLineSearch(MinimizerParameterSet* param) : Minimizer(param), lineSearchInit(false){}
36 void setLineSearchStrategy(NLModel* nlp, LineSearchStrategy stategy){
37
38 if(stategy == GoldenSection)
39 lsMinimizer = new GoldenSectionMinimizer(nlp);
40
41 else if(stategy == Brent)
42 lsMinimizer = new BrentMinimizer(nlp);
43
44 else{
45 cerr << "MinimizerUsingLineSearch Error : Unknown Line Search Strategy" << endl;
46 exit(-1);
47 }
48
49 lsMinimizer->setMaxIteration(paramSet->getLineSearchMaxIteration());
50 lsMinimizer->setStepTol(paramSet->getLineSearchTol());
51
52 lineSearchInit = true;
53 }
54
55 protected:
56
57 Minimizer1D* lsMinimizer;
58 bool lineSearchInit;
59 };
60
61 #endif

Properties

Name Value
svn:executable *