Gadget
optinfo.h
Go to the documentation of this file.
1 #ifndef optinfo_h
2 #define optinfo_h
3 
4 #include "maininfo.h"
5 #include "doublematrix.h"
6 #include "doublevector.h"
7 #include "intvector.h"
8 
10 
17 class OptInfo {
18 public:
22  OptInfo() { converge = 0; iters = 0; score = 0.0; };
26  virtual ~OptInfo() {};
32  virtual void read(CommentStream& infile, char* text) {};
38  virtual void Print(ofstream& outfile, int prec) {};
42  virtual void OptimiseLikelihood() {};
47  OptType getType() const { return type; };
48 protected:
52  int converge;
56  int iters;
60  double score;
65 };
66 
76 class OptInfoHooke : public OptInfo {
77 public:
81  OptInfoHooke();
85  virtual ~OptInfoHooke() {};
91  virtual void read(CommentStream& infile, char* text);
97  virtual void Print(ofstream& outfile, int prec);
101  virtual void OptimiseLikelihood();
102 private:
111  double bestNearby(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param);
115  int hookeiter;
119  double rho;
123  double lambda;
127  double hookeeps;
131  double bndcheck;
132 };
133 
142 class OptInfoSimann : public OptInfo {
143 public:
147  OptInfoSimann();
151  virtual ~OptInfoSimann() {};
157  virtual void read(CommentStream& infile, char* text);
163  virtual void Print(ofstream& outfile, int prec);
167  virtual void OptimiseLikelihood();
168 private:
172  double rt;
176  double simanneps;
180  int ns;
184  int nt;
188  double t;
192  double cs;
196  double vminit;
200  int simanniter;
204  double uratio;
208  double lratio;
212  int tempcheck;
216  int scale;
217 };
218 
227 class OptInfoBFGS : public OptInfo {
228 public:
232  OptInfoBFGS();
236  virtual ~OptInfoBFGS() {};
242  virtual void read(CommentStream& infile, char* text);
248  virtual void Print(ofstream& outfile, int prec);
252  virtual void OptimiseLikelihood();
253 private:
260  void gradient(DoubleVector& point, double pointvalue, DoubleVector& newgrad);
266  double getSmallestEigenValue(DoubleMatrix M);
270  int bfgsiter;
274  double bfgseps;
278  double beta;
282  double sigma;
286  double step;
290  double gradacc;
294  double gradstep;
298  double gradeps;
299 };
300 
301 #endif
This is the class used to strip comments (and whitespace) from any input stream.
Definition: commentstream.h:40
This class implements a dynamic vector of DoubleVector values.
Definition: doublematrix.h:11
This class implements a dynamic vector of double values.
Definition: doublevector.h:11
This class implements a dynamic vector of int values.
Definition: intvector.h:11
This is the class used for the BFGS optimisation.
Definition: optinfo.h:227
virtual void OptimiseLikelihood()
This is the function that will calculate the likelihood score using the BFGS optimiser.
Definition: bfgs.cc:107
OptInfoBFGS()
This is the default OptInfoBFGS constructor.
Definition: optinfobfgs.cc:6
virtual ~OptInfoBFGS()
This is the default OptInfoBFGS destructor.
Definition: optinfo.h:236
virtual void read(CommentStream &infile, char *text)
This is the function used to read in the BFGS parameters.
Definition: optinfobfgs.cc:13
virtual void Print(ofstream &outfile, int prec)
This function will print information from the optimisation algorithm.
Definition: optinfobfgs.cc:98
This is the class used for the Hooke & Jeeves optimisation.
Definition: optinfo.h:76
OptInfoHooke()
This is the default OptInfoHooke constructor.
Definition: optinfohooke.cc:6
virtual void OptimiseLikelihood()
This is the function that will calculate the likelihood score using the Hooke & Jeeves optimiser.
Definition: hooke.cc:174
virtual ~OptInfoHooke()
This is the default OptInfoHooke destructor.
Definition: optinfo.h:85
virtual void Print(ofstream &outfile, int prec)
This function will print information from the optimisation algorithm.
Definition: optinfohooke.cc:73
virtual void read(CommentStream &infile, char *text)
This is the function used to read in the Hooke & Jeeves parameters.
Definition: optinfohooke.cc:12
This is the class used for the Simualted Annealing optimisation.
Definition: optinfo.h:142
OptInfoSimann()
This is the default OptInfoSimann constructor.
Definition: optinfosimann.cc:6
virtual void read(CommentStream &infile, char *text)
This is the function used to read in the Simulated Annealing parameters.
Definition: optinfosimann.cc:13
virtual void OptimiseLikelihood()
This is the function that will calculate the likelihood score using the Simulated Annealing optimiser...
Definition: simann.cc:184
virtual void Print(ofstream &outfile, int prec)
This function will print information from the optimisation algorithm.
Definition: optinfosimann.cc:130
virtual ~OptInfoSimann()
This is the default OptInfoSimann destructor.
Definition: optinfo.h:151
This is the base class used to perform the optimisation calculation for the model.
Definition: optinfo.h:17
int converge
This is the flag used to denote whether the optimisation converged or not.
Definition: optinfo.h:47
OptInfo()
This is the default OptInfo constructor.
Definition: optinfo.h:22
int iters
This is the number of iterations that took place during the optimisation.
Definition: optinfo.h:56
double score
This is the value of the best likelihood score from the optimisation.
Definition: optinfo.h:60
virtual ~OptInfo()
This is the default OptInfo destructor.
Definition: optinfo.h:26
virtual void OptimiseLikelihood()
This is the function used to call the optimisation algorithms.
Definition: optinfo.h:42
virtual void read(CommentStream &infile, char *text)
This is the function used to read in the optimisation parameters.
Definition: optinfo.h:32
OptType getType() const
This will return the type of optimisation class.
Definition: optinfo.h:47
virtual void Print(ofstream &outfile, int prec)
This function will print information from the optimisation algorithm.
Definition: optinfo.h:38
OptType type
This denotes what type of optimisation class has been created.
Definition: optinfo.h:64
OptType
Definition: optinfo.h:9
@ OPTHOOKE
Definition: optinfo.h:9
@ OPTSIMANN
Definition: optinfo.h:9
@ OPTBFGS
Definition: optinfo.h:9