2 |
|
#define _MINIMIZERBASE_H_ |
3 |
|
|
4 |
|
#include <string> |
5 |
+ |
#include <vector> |
6 |
|
|
7 |
|
#include "MinimizerParameterSet.hpp" |
8 |
+ |
#include "NLModel.hpp" |
9 |
|
|
10 |
+ |
#define MINSTATUS_ERROR -1 |
11 |
+ |
#define MINSTATUS_CONVERGE 0 |
12 |
+ |
#define MINSTATUS_MAXITER 1 |
13 |
+ |
|
14 |
|
using namespace std; |
15 |
|
|
16 |
|
class MinimizerBase{ |
17 |
|
public: |
18 |
|
|
19 |
< |
virtual void Init() = 0; |
20 |
< |
virtual void Minimize() = 0; |
15 |
< |
virtual int isConvergenceAchieved() = 0; |
16 |
< |
|
17 |
< |
virtual bool isSolvable() = 0; |
19 |
> |
//initialize the minimizer method |
20 |
> |
virtual void init() = 0; |
21 |
|
|
22 |
< |
virtual void printMinizerInfo() = 0; |
22 |
> |
//minimize the model |
23 |
> |
virtual void minimize() = 0; |
24 |
|
|
25 |
< |
virtual MinimizerParameterSet* creatParameterSet() = 0; |
26 |
< |
|
23 |
< |
void setInitX(vector<double>& x) { initX = x;} |
25 |
> |
// |
26 |
> |
virtual int checkConvergence() = 0; |
27 |
|
|
28 |
< |
void setMinX(vector<double>& x) { minX = x;} |
29 |
< |
vector<double> getMinX() { return minX;} |
28 |
> |
//check whether the model and the method are matched or not |
29 |
> |
virtual bool isSolvable() = 0; |
30 |
|
|
31 |
< |
void setPrecMinX(vector<double>& x) { prevMinX = x;} |
32 |
< |
vector<double> getPrevMinX() {return prevMinX;} |
31 |
> |
// get the final status of minimization |
32 |
> |
int getMinimizationStatus() {return minStatus;} |
33 |
|
|
34 |
< |
int getMinimizationStatus() {return minimizationStatus;} |
32 |
< |
|
34 |
> |
// get the name of minimization method |
35 |
|
const string getName() {return minimizerName;} |
36 |
+ |
|
37 |
+ |
//set the name of minimiation method |
38 |
|
void setName(const string& name) { minimizerName = name;} |
39 |
|
|
36 |
– |
|
40 |
|
protected: |
41 |
|
|
42 |
< |
MinimizerParameterSet* paramSet; |
40 |
< |
|
41 |
< |
int minimizationStatus; |
42 |
< |
|
42 |
> |
int minStatus; |
43 |
|
string minimizerName; |
44 |
– |
|
45 |
– |
// Coordinates yielding the minimum value of the function. |
46 |
– |
vector<double> minX; |
44 |
|
|
48 |
– |
// Vector holding the previous point. |
49 |
– |
vector<double> prevMinX; |
45 |
|
}; |
46 |
+ |
|
47 |
|
#endif |