1 : |
agomez |
1 |
#ifndef armijo_h
|
2 : |
|
|
#define armijo_h
|
3 : |
|
|
|
4 : |
|
|
#include "linesearch.h" |
5 : |
|
|
|
6 : |
|
|
/**
|
7 : |
|
|
* \class Armijo
|
8 : |
|
|
* \brief This class performs a linestearch along a given line without using derivatives. The method works as follows, a sequence of alpha_n = beta^n*s is generated and if f(x)-f(x+alpha_n*s) >= - sigma * alpha_n * grad(f,x)'*s otherwise the method continues
|
9 : |
|
|
*/
|
10 : |
|
|
class Armijo : public LineSearch {
|
11 : |
|
|
public:
|
12 : |
|
|
/**
|
13 : |
|
|
* \brief This is the default Armijo constructor
|
14 : |
|
|
*/
|
15 : |
|
|
Armijo();
|
16 : |
|
|
/**
|
17 : |
|
|
* \brief This is the default Armijo destructor
|
18 : |
|
|
*/
|
19 : |
|
|
virtual ~Armijo();
|
20 : |
|
|
/**
|
21 : |
|
|
* \brief This function will return the best value for alpha obtained by the search
|
22 : |
|
|
* \return alpha
|
23 : |
|
|
*/
|
24 : |
|
|
double getAlpha();
|
25 : |
|
|
/**
|
26 : |
|
|
* \brief Returns 1 if the Armijo condition is satisfied 0 otherwise
|
27 : |
|
|
* \param y is the functionvalue
|
28 : |
|
|
*/
|
29 : |
|
|
int conditionSatisfied(double y);
|
30 : |
|
|
/**
|
31 : |
|
|
* \brief doArmijo does the Armijo linesearch
|
32 : |
|
|
* \param v1 is the inital starting point
|
33 : |
|
|
* \param fx is the f-value at v1
|
34 : |
|
|
* \param dery is the dot product of the gradient and search direction
|
35 : |
|
|
* \param h
|
36 : |
|
|
* \param netI
|
37 : |
|
|
* \param s is the starting alpha value
|
38 : |
|
|
*/
|
39 : |
|
|
void doArmijo(const DoubleVector& v1, double fx, double dery, const DoubleVector& h, NetInterface* netI, double s);
|
40 : |
|
|
/**
|
41 : |
|
|
* \brief Prepares the linesearch by setting the first f-value as initalf (corresponds to alpha = 0)
|
42 : |
|
|
*/
|
43 : |
|
|
void prepareNewLineSearch();
|
44 : |
|
|
/**
|
45 : |
|
|
* \brief Starts "number of available hosts" function evaluations
|
46 : |
|
|
*/
|
47 : |
|
|
void initiateAlphas();
|
48 : |
|
|
/**
|
49 : |
|
|
* \brief Keeps the nodes busy by sending the next alpha value
|
50 : |
|
|
*/
|
51 : |
|
|
int setData();
|
52 : |
|
|
/**
|
53 : |
|
|
* \param s is the new value for sigma
|
54 : |
|
|
*/
|
55 : |
|
|
void setSigma(double s);
|
56 : |
|
|
/**
|
57 : |
|
|
* \param b is the new value for beta
|
58 : |
|
|
*/
|
59 : |
|
|
void setBeta(double b);
|
60 : |
|
|
/**
|
61 : |
|
|
* \brief Returns beta
|
62 : |
|
|
*/
|
63 : |
|
|
double getBeta();
|
64 : |
|
|
/**
|
65 : |
|
|
* \brief Returns n in alpha = beta^n * s
|
66 : |
|
|
*/
|
67 : |
|
|
int getPower();
|
68 : |
|
|
/**
|
69 : |
|
|
* \brief Returns the number of function evaluations that has not been finished
|
70 : |
|
|
*/
|
71 : |
|
|
int outstandingRequests();
|
72 : |
|
|
/**
|
73 : |
|
|
* \brief Computes the conditionfunction and supplies nodes new jobs
|
74 : |
|
|
*/
|
75 : |
|
|
int computeConditionFunction();
|
76 : |
|
|
private:
|
77 : |
|
|
/**
|
78 : |
|
|
* \brief Linesearch done from initialx
|
79 : |
|
|
*/
|
80 : |
|
|
DoubleVector initialx;
|
81 : |
|
|
/**
|
82 : |
|
|
* \brief The function value at initialx.
|
83 : |
|
|
*/
|
84 : |
|
|
double initialf;
|
85 : |
|
|
/**
|
86 : |
|
|
* \brief The derivative of g(alpha)=f(x + alpha * h).
|
87 : |
|
|
*/
|
88 : |
|
|
double df;
|
89 : |
|
|
DoubleVector hvec;
|
90 : |
|
|
double s;
|
91 : |
|
|
double sigma;
|
92 : |
|
|
NetInterface* net;
|
93 : |
|
|
Condition* cond;
|
94 : |
|
|
int numVar;
|
95 : |
|
|
double alpha;
|
96 : |
|
|
int power;
|
97 : |
|
|
double beta;
|
98 : |
|
|
};
|
99 : |
|
|
|
100 : |
|
|
#endif
|