1 |
tim |
987 |
#ifndef _CONSTRAINT_H_
|
2 |
|
|
#define _CONSTRAINT_H_
|
3 |
|
|
|
4 |
tim |
1010 |
#include <iostream>
|
5 |
tim |
987 |
#include <vector>
|
6 |
|
|
|
7 |
tim |
1010 |
#include "SymMatrix.hpp"
|
8 |
tim |
987 |
|
9 |
|
|
#define ERROR_CONSTRAINT 10
|
10 |
|
|
|
11 |
|
|
using namespace std;
|
12 |
|
|
|
13 |
tim |
1010 |
typedef enum {simpleBound = 1, linearEqu = 2, linearInequ = 4,
|
14 |
|
|
nonlinearEqu = 8, nonlinearInequ =16} ConsType;
|
15 |
tim |
987 |
|
16 |
tim |
1010 |
typedef enum {btUpper, btLower, btEqu} BoundType;
|
17 |
tim |
987 |
|
18 |
tim |
995 |
/**
|
19 |
|
|
* Abstract class of constraint for nonlinear optimization problem
|
20 |
|
|
*/
|
21 |
tim |
987 |
class ConstraintBase{
|
22 |
|
|
public:
|
23 |
|
|
ConstraintBase();
|
24 |
|
|
ConstraintBase(int dim);
|
25 |
|
|
|
26 |
|
|
virtual void setDim(int dim);
|
27 |
|
|
bool isDimSet();
|
28 |
|
|
|
29 |
tim |
1010 |
int getConsType() { return consType;}
|
30 |
tim |
987 |
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
|