1 |
tim |
970 |
#ifndef _MINIMIZERBASE_H_
|
2 |
|
|
#define _MINIMIZERBASE_H_
|
3 |
|
|
|
4 |
tim |
1000 |
#include <string>
|
5 |
tim |
1002 |
#include <vector>
|
6 |
tim |
1000 |
|
7 |
|
|
#include "MinimizerParameterSet.hpp"
|
8 |
|
|
|
9 |
tim |
1002 |
#define MINSTATUS_ERROR -1
|
10 |
|
|
#define MINSTATUS_CONVERGE 0
|
11 |
|
|
#define MINSTATUS_MAXITER 1
|
12 |
|
|
|
13 |
tim |
1000 |
using namespace std;
|
14 |
|
|
|
15 |
tim |
970 |
class MinimizerBase{
|
16 |
|
|
public:
|
17 |
|
|
|
18 |
tim |
1002 |
//initialize the minimizer method
|
19 |
tim |
987 |
virtual void Init() = 0;
|
20 |
tim |
1002 |
|
21 |
|
|
//minimize the model
|
22 |
|
|
virtual void minimize() = 0;
|
23 |
|
|
|
24 |
|
|
//
|
25 |
|
|
virtual int checkConvergence() = 0;
|
26 |
|
|
|
27 |
|
|
//check whether the model and the method are matched or not
|
28 |
tim |
970 |
virtual bool isSolvable() = 0;
|
29 |
|
|
|
30 |
tim |
1002 |
// get the final status of minimization
|
31 |
|
|
int getMinimizationStatus() {return minimizationStatus;}
|
32 |
|
|
|
33 |
|
|
// get the name of minimization method
|
34 |
|
|
const string getName() {return minimizerName;}
|
35 |
|
|
|
36 |
|
|
//set the name of minimiation method
|
37 |
|
|
void setName(const string& name) { minimizerName = name;}
|
38 |
|
|
|
39 |
|
|
protected:
|
40 |
|
|
|
41 |
|
|
int minStatus;
|
42 |
|
|
string minimizerName;
|
43 |
|
|
|
44 |
|
|
};
|
45 |
|
|
|
46 |
|
|
class Minimizer : public MinimizerBase{
|
47 |
|
|
|
48 |
|
|
public:
|
49 |
|
|
|
50 |
tim |
1000 |
virtual void printMinizerInfo() = 0;
|
51 |
tim |
970 |
|
52 |
tim |
1000 |
virtual MinimizerParameterSet* creatParameterSet() = 0;
|
53 |
|
|
void setMinX(vector<double>& x) { minX = x;}
|
54 |
|
|
vector<double> getMinX() { return minX;}
|
55 |
tim |
970 |
|
56 |
tim |
1002 |
void setPrevMinX(vector<double>& x) { prevMinX = x;}
|
57 |
tim |
1000 |
vector<double> getPrevMinX() {return prevMinX;}
|
58 |
tim |
970 |
|
59 |
tim |
1002 |
int getCurrentIteration() {return currentIter;}
|
60 |
tim |
1000 |
|
61 |
tim |
970 |
protected:
|
62 |
tim |
1000 |
|
63 |
tim |
1002 |
MinimizerParameterSet* paramSet;
|
64 |
|
|
int currentIter;
|
65 |
tim |
970 |
|
66 |
tim |
1000 |
// Coordinates yielding the minimum value of the function.
|
67 |
|
|
vector<double> minX;
|
68 |
|
|
|
69 |
|
|
// Vector holding the previous point.
|
70 |
|
|
vector<double> prevMinX;
|
71 |
tim |
970 |
};
|
72 |
|
|
#endif
|