1 : |
agomez |
1 |
#ifndef netgradient_h
|
2 : |
|
|
#define netgradient_h
|
3 : |
|
|
|
4 : |
|
|
#include "netinterface.h" |
5 : |
|
|
#include "paramin.h" |
6 : |
|
|
|
7 : |
|
|
/**
|
8 : |
|
|
* \class Gradient
|
9 : |
|
|
* \brief class Gradient is an abstract class containing only pure virtual functions except for the destructor.
|
10 : |
|
|
*/
|
11 : |
|
|
|
12 : |
|
|
class Gradient {
|
13 : |
|
|
public:
|
14 : |
|
|
virtual ~Gradient();
|
15 : |
|
|
virtual void setXVectors(const DoubleVector& x, double fx, NetInterface* netInt) = 0;
|
16 : |
|
|
virtual int computeGradient(NetInterface* net, const DoubleVector& x, double fx, int linesprob) = 0;
|
17 : |
|
|
virtual const DoubleVector& getDiagonalHessian() = 0;
|
18 : |
|
|
virtual double getNormGrad() = 0;
|
19 : |
|
|
virtual const DoubleVector& getGradient() = 0;
|
20 : |
|
|
virtual int getDifficultGrad() = 0;
|
21 : |
|
|
virtual double getBaseFX() = 0;
|
22 : |
|
|
virtual void initializeDiagonalHessian() = 0;
|
23 : |
|
|
};
|
24 : |
|
|
|
25 : |
|
|
/**
|
26 : |
|
|
* \class NetGradient
|
27 : |
|
|
* \brief class NetGradient is a derived class of Gradient and implements gradient computation which uses net communication to send/receive data.
|
28 : |
|
|
*/
|
29 : |
|
|
|
30 : |
|
|
class NetGradient : public Gradient {
|
31 : |
|
|
private:
|
32 : |
|
|
int numVar;
|
33 : |
|
|
/**
|
34 : |
|
|
* \brief Upper bound on percentage h in f(x+h).
|
35 : |
|
|
*/
|
36 : |
|
|
double delta0;
|
37 : |
|
|
/**
|
38 : |
|
|
* \brief Lower bound on percentage h in f(x+h)
|
39 : |
|
|
*/
|
40 : |
|
|
double delta1;
|
41 : |
|
|
/**
|
42 : |
|
|
* \brief AJ - NEW PARAMTER
|
43 : |
|
|
*/
|
44 : |
|
|
double delta2;
|
45 : |
|
|
/**
|
46 : |
|
|
* \brief Central values of percentage h and h.
|
47 : |
|
|
*/
|
48 : |
|
|
double delta;
|
49 : |
|
|
/**
|
50 : |
|
|
* \brief
|
51 : |
|
|
*/
|
52 : |
|
|
DoubleVector deltavec;
|
53 : |
|
|
/**
|
54 : |
|
|
* \brief 0 if linear approx, 1 if symmetric approx, and >=2 if approx. using four points
|
55 : |
|
|
*/
|
56 : |
|
|
int difficultgrad;
|
57 : |
|
|
/**
|
58 : |
|
|
* \brief 1 if values around x are all bigger, 0 else.
|
59 : |
|
|
*/
|
60 : |
|
|
int difficult;
|
61 : |
|
|
DoubleVector diagHess;
|
62 : |
|
|
double normgrad;
|
63 : |
|
|
DoubleVector grad;
|
64 : |
|
|
/**
|
65 : |
|
|
* \brief f(x0) where x0 is the base data vector
|
66 : |
|
|
*/
|
67 : |
|
|
double fx0;
|
68 : |
|
|
public:
|
69 : |
|
|
NetGradient(int numVars);
|
70 : |
|
|
virtual ~NetGradient();
|
71 : |
|
|
void setXVectors(const DoubleVector& x, double fx, NetInterface* netInt);
|
72 : |
|
|
int computeGradient(NetInterface* net, const DoubleVector& x, double fx, int symgrad);
|
73 : |
|
|
const DoubleVector& getDiagonalHessian();
|
74 : |
|
|
double getNormGrad();
|
75 : |
|
|
const DoubleVector& getGradient();
|
76 : |
|
|
int getDifficultGrad();
|
77 : |
|
|
double getBaseFX();
|
78 : |
|
|
void initializeDiagonalHessian();
|
79 : |
|
|
};
|
80 : |
|
|
|
81 : |
|
|
#endif
|