ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Minimizer.hpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/Minimizer.hpp (file contents):
Revision 1011 by tim, Tue Feb 3 20:47:10 2004 UTC vs.
Revision 1031 by tim, Fri Feb 6 18:58:06 2004 UTC

# Line 2 | Line 2
2   #define _MINIMIZER_H_
3   #include "MinimizerBase.hpp"
4   #include "Minimizer1D.hpp"
5 <
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 <    virtual MinimizerParameterSet* creatParameterSet() = 0;
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  
# Line 21 | Line 29 | class Minimizer : public MinimizerBase{
29    protected:
30      
31      MinimizerParameterSet* paramSet;    
32 +    OutputFunctor* outputFunc;
33      int currentIter;
34  
35      // Coordinates yielding the minimum value of the function.
# Line 32 | Line 41 | class MinimizerUsingLineSearch : public Minimizer{
41  
42   class MinimizerUsingLineSearch : public Minimizer{
43    public:
44 <    void setLineSearchStrategy();
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines