| 1 |
#ifndef _MINIMIZERBASE_H_
|
| 2 |
#define _MINIMIZERBASE_H_
|
| 3 |
|
| 4 |
#include <string>
|
| 5 |
#include <vector>
|
| 6 |
|
| 7 |
#include "MinimizerParameterSet.hpp"
|
| 8 |
|
| 9 |
#define MINSTATUS_ERROR -1
|
| 10 |
#define MINSTATUS_CONVERGE 0
|
| 11 |
#define MINSTATUS_MAXITER 1
|
| 12 |
|
| 13 |
using namespace std;
|
| 14 |
|
| 15 |
class MinimizerBase{
|
| 16 |
public:
|
| 17 |
|
| 18 |
//initialize the minimizer method
|
| 19 |
virtual void Init() = 0;
|
| 20 |
|
| 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 |
virtual bool isSolvable() = 0;
|
| 29 |
|
| 30 |
// 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 |
virtual void printMinizerInfo() = 0;
|
| 51 |
|
| 52 |
virtual MinimizerParameterSet* creatParameterSet() = 0;
|
| 53 |
void setMinX(vector<double>& x) { minX = x;}
|
| 54 |
vector<double> getMinX() { return minX;}
|
| 55 |
|
| 56 |
void setPrevMinX(vector<double>& x) { prevMinX = x;}
|
| 57 |
vector<double> getPrevMinX() {return prevMinX;}
|
| 58 |
|
| 59 |
int getCurrentIteration() {return currentIter;}
|
| 60 |
|
| 61 |
protected:
|
| 62 |
|
| 63 |
MinimizerParameterSet* paramSet;
|
| 64 |
int currentIter;
|
| 65 |
|
| 66 |
// Coordinates yielding the minimum value of the function.
|
| 67 |
vector<double> minX;
|
| 68 |
|
| 69 |
// Vector holding the previous point.
|
| 70 |
vector<double> prevMinX;
|
| 71 |
};
|
| 72 |
#endif
|