1 : |
agomez |
1 |
#ifndef paraminsearch_h
|
2 : |
|
|
#define paraminsearch_h
|
3 : |
|
|
|
4 : |
|
|
#include "netcommunication.h" |
5 : |
|
|
#include "linesearch.h" |
6 : |
|
|
#include "armijo.h" |
7 : |
|
|
#include "paramin.h" |
8 : |
|
|
#include "netgradient.h" |
9 : |
|
|
#include "commandlineinfo.h" |
10 : |
|
|
#include "optinfo.h"
|
11 : |
|
|
|
12 : |
|
|
/**
|
13 : |
|
|
* \class ParaminSearch
|
14 : |
|
|
* \brief Base class for Paramin search algorithms
|
15 : |
|
|
*/
|
16 : |
|
|
// AJ. should chekc if need the upper, lower, x, f..
|
17 : |
|
|
// think so because used throughout the algos..
|
18 : |
|
|
// but better check is...
|
19 : |
|
|
class ParaminSearch : public OptInfo {
|
20 : |
|
|
protected:
|
21 : |
|
|
/**
|
22 : |
|
|
* \brief Used for parallell computations
|
23 : |
|
|
*/
|
24 : |
|
|
NetInterface* net; // Used for parallell computations
|
25 : |
|
|
/**
|
26 : |
|
|
* \brief The lowerbound for the variables
|
27 : |
|
|
*/
|
28 : |
|
|
DoubleVector lowerbound;
|
29 : |
|
|
/**
|
30 : |
|
|
* \brief The upperbound for the variables
|
31 : |
|
|
*/
|
32 : |
|
|
DoubleVector upperbound;
|
33 : |
|
|
/**
|
34 : |
|
|
* \brief maximum number of iterations for one minimization
|
35 : |
|
|
*/
|
36 : |
|
|
int maxiterations; // maximum number of iterations for one minimization
|
37 : |
|
|
/**
|
38 : |
|
|
* \brief number of variables.
|
39 : |
|
|
*/
|
40 : |
|
|
int numvar; // number of variables.
|
41 : |
|
|
// Must be carefule as x is also used in bfgs, should change to new name
|
42 : |
|
|
/**
|
43 : |
|
|
* \brief best point found so far..
|
44 : |
|
|
*/
|
45 : |
|
|
DoubleVector bestx; // x which gives best point???
|
46 : |
|
|
/**
|
47 : |
|
|
* \brief The optimal value of the function, found so far
|
48 : |
|
|
*/
|
49 : |
|
|
// AJ this is in optinfo?????
|
50 : |
|
|
double bestf; // best point found so far..
|
51 : |
|
|
// The optimal value of the function, found so far
|
52 : |
|
|
// but where in the algo. Always or just at end..
|
53 : |
|
|
// int converged;
|
54 : |
|
|
public:
|
55 : |
|
|
/**
|
56 : |
|
|
* \brief The default constructor
|
57 : |
|
|
*/
|
58 : |
|
|
ParaminSearch();
|
59 : |
|
|
/**
|
60 : |
|
|
* \brief
|
61 : |
|
|
* \param
|
62 : |
|
|
*/
|
63 : |
|
|
ParaminSearch(NetInterface* netInt);
|
64 : |
|
|
/**
|
65 : |
|
|
* \brief default destructor
|
66 : |
|
|
*/
|
67 : |
|
|
virtual ~ParaminSearch();
|
68 : |
|
|
/**
|
69 : |
|
|
* \brief Does a search, implemented in descending classes
|
70 : |
|
|
* \param startx is the starting point of the BFGS
|
71 : |
|
|
* \param startf is the f-value at startx
|
72 : |
|
|
*/
|
73 : |
|
|
//virtual void doSearch(const DoubleVector& startx, double startf) = 0;
|
74 : |
|
|
// don't need the startx, startf, as they are in netInterface...
|
75 : |
|
|
virtual void OptimiseLikelihood() = 0;
|
76 : |
|
|
/**
|
77 : |
|
|
* \brief The file reader
|
78 : |
|
|
* \param infile is the CommentStream to read the optimisation parameters from
|
79 : |
|
|
* \param text is the latest entry from infile
|
80 : |
|
|
*/
|
81 : |
|
|
virtual void read(CommentStream& infile, char* text) = 0;
|
82 : |
|
|
/**
|
83 : |
|
|
* \brief This function randomizes the order of varibles of vec
|
84 : |
|
|
* \param vec is an int* of size numvar
|
85 : |
|
|
*/
|
86 : |
|
|
void randomOrder(IntVector& vec);
|
87 : |
|
|
/**
|
88 : |
|
|
* \brief This function returns the best point, bestx
|
89 : |
|
|
*/
|
90 : |
|
|
const DoubleVector& getBestX();
|
91 : |
|
|
/**
|
92 : |
|
|
* \brief This function returns the best f-value, bestf (corresponds to bestx)
|
93 : |
|
|
*/
|
94 : |
|
|
double getBestF();
|
95 : |
|
|
/**
|
96 : |
|
|
* \brief This function calculates exp(x)
|
97 : |
|
|
* \param x
|
98 : |
|
|
*/
|
99 : |
|
|
double expRep(double x);
|
100 : |
|
|
/**
|
101 : |
|
|
* \brief Returns a randomNumber coming from an even distribution on the interval 0 to 1
|
102 : |
|
|
*/
|
103 : |
|
|
double randomNumber();
|
104 : |
|
|
int GetConverged() { return converge;};
|
105 : |
|
|
virtual void Print(ofstream& outfile, int prec) = 0;
|
106 : |
|
|
void printX(const DoubleVector& vec);
|
107 : |
|
|
void printX(ofstream& output, const DoubleVector& vec);
|
108 : |
|
|
};
|
109 : |
|
|
|
110 : |
|
|
#endif
|