1 |
|
#ifndef _MINIMIZERBASE_H_ |
2 |
|
#define _MINIMIZERBASE_H_ |
3 |
|
|
4 |
< |
class MinimizerBase{ |
5 |
< |
public: |
4 |
> |
#include <string> |
5 |
> |
#include <vector> |
6 |
|
|
7 |
< |
virtual void Minimize() = 0; |
8 |
< |
virtual int step() = 0; |
9 |
< |
virtual bool testConvergence() = 0; |
7 |
> |
#include "MinimizerParameterSet.hpp" |
8 |
> |
#include "NLModel.hpp" |
9 |
|
|
10 |
< |
virtual bool isSolvable() = 0; |
10 |
> |
#define MINSTATUS_ERROR -1 |
11 |
> |
#define MINSTATUS_CONVERGE 0 |
12 |
> |
#define MINSTATUS_MAXITER 1 |
13 |
|
|
14 |
< |
void double setFTol(double tol); |
14 |
< |
void double setGradTol(double gradTol); |
14 |
> |
using namespace std; |
15 |
|
|
16 |
< |
void setStepSize(double step); |
17 |
< |
double getStepSize(); |
16 |
> |
class MinimizerBase{ |
17 |
> |
public: |
18 |
|
|
19 |
< |
void setMaxStep(); |
20 |
< |
double getMaxStep(); |
19 |
> |
//initialize the minimizer method |
20 |
> |
virtual void init() = 0; |
21 |
|
|
22 |
< |
const string& getMethodName(); |
23 |
< |
void setMethodName(const string& name); |
22 |
> |
//minimize the model |
23 |
> |
virtual void minimize() = 0; |
24 |
|
|
25 |
< |
void setObjFunctor(); |
26 |
< |
void getObjFunctor(); |
25 |
> |
// |
26 |
> |
virtual int checkConvergence() = 0; |
27 |
|
|
28 |
< |
/* |
29 |
< |
void setUpdateFunctor(); |
30 |
< |
void getUpdateFunctor(); |
28 |
> |
//check whether the model and the method are matched or not |
29 |
> |
virtual bool isSolvable() = 0; |
30 |
|
|
31 |
< |
void setSearchFunctor(); |
32 |
< |
void getSearchFunctor(); |
34 |
< |
*/ |
31 |
> |
// get the final status of minimization |
32 |
> |
int getMinimizationStatus() {return minStatus;} |
33 |
|
|
34 |
< |
protected: |
34 |
> |
// get the name of minimization method |
35 |
> |
const string getName() {return minimizerName;} |
36 |
|
|
37 |
< |
double stepSize; |
38 |
< |
double maxStep; |
40 |
< |
double fTol; |
41 |
< |
double gradTol; |
42 |
< |
string methodName; |
37 |
> |
//set the name of minimiation method |
38 |
> |
void setName(const string& name) { minimizerName = name;} |
39 |
|
|
40 |
< |
bool hasObjFunctor; |
40 |
> |
protected: |
41 |
> |
|
42 |
> |
int minStatus; |
43 |
> |
string minimizerName; |
44 |
|
|
46 |
– |
/* |
47 |
– |
bool hasUpdateFunctor; |
48 |
– |
|
49 |
– |
bool hasSearchFunctor; |
50 |
– |
*/ |
51 |
– |
|
45 |
|
}; |
46 |
+ |
|
47 |
|
#endif |