1 |
#ifndef _CONSTRAINT_H_
|
2 |
#define _CONSTRAINT_H_
|
3 |
|
4 |
#include <iostream>
|
5 |
#include <vector>
|
6 |
|
7 |
#include "SymMatrix.hpp"
|
8 |
|
9 |
#define ERROR_CONSTRAINT 10
|
10 |
|
11 |
using namespace std;
|
12 |
|
13 |
typedef enum {simpleBound = 1, linearEqu = 2, linearInequ = 4,
|
14 |
nonlinearEqu = 8, nonlinearInequ =16} ConsType;
|
15 |
|
16 |
typedef enum {btUpper, btLower, btEqu} BoundType;
|
17 |
|
18 |
/**
|
19 |
* Abstract class of constraint for nonlinear optimization problem
|
20 |
*/
|
21 |
class ConstraintBase{
|
22 |
public:
|
23 |
ConstraintBase();
|
24 |
ConstraintBase(int dim);
|
25 |
|
26 |
virtual void setDim(int dim);
|
27 |
bool isDimSet() {return init_ndim;}
|
28 |
|
29 |
int getConsType() { return consType;}
|
30 |
virtual double calcResidual(vector<double>& x) = 0;
|
31 |
virtual vector<double> calcConsGrad(vector<double>& x) = 0;
|
32 |
virtual SymMatrix calcConsHessian(vector<double>& x) = 0;
|
33 |
|
34 |
protected:
|
35 |
|
36 |
bool init_ndim;
|
37 |
int ndim;
|
38 |
|
39 |
double bound;
|
40 |
BoundType boundType;
|
41 |
ConsType consType;
|
42 |
|
43 |
};
|
44 |
|
45 |
#endif
|