Gadget
keeper.h
Go to the documentation of this file.
1 #ifndef keeper_h
2 #define keeper_h
3 
4 #include "likelihood.h"
5 #include "likelihoodptrvector.h"
6 #include "optinfoptrvector.h"
7 #include "stochasticdata.h"
8 #include "addresskeepermatrix.h"
9 #include "strstack.h"
10 
17 class Keeper {
18 public:
22  Keeper();
26  ~Keeper();
32  void keepVariable(double& value, Parameter& attr);
37  void deleteParameter(const double& var);
43  void changeVariable(const double& pre, double& post);
48  void setString(const char* str);
53  void addString(const char* str);
58  void addString(const string str);
62  void clearLast();
66  void clearAll();
72  void storeVariables(double likvalue, const DoubleVector& point);
76  void resetVariables();
80  void scaleVariables();
85  void getOptFlags(IntVector& opt) const;
90  void getSwitches(ParameterVector& sw) const;
95  void getLowerBounds(DoubleVector& lbs) const;
100  void getUpperBounds(DoubleVector& ubs) const;
105  void getInitialValues(DoubleVector& val) const;
110  void getScaledValues(DoubleVector& val) const;
115  void getCurrentValues(DoubleVector& val) const;
120  void getOptLowerBounds(DoubleVector& lbs) const;
125  void getOptUpperBounds(DoubleVector& ubs) const;
130  void getOptInitialValues(DoubleVector& val) const;
135  void getOptScaledValues(DoubleVector& val) const;
140  int numVariables() const;
145  int numOptVariables() const { return numoptvar; };
151  void Update(int pos, double& value);
156  void Update(const DoubleVector& val);
161  void Update(const StochasticData* const Stoch);
166  void openPrintFile(const char* const filename);
171  void writeInitialInformation(const LikelihoodPtrVector& likevec);
177  void writeValues(const LikelihoodPtrVector& likevec, int prec);
185  void writeParams(const OptInfoPtrVector& optvec, const char* const filename, int prec, int interrupt);
189  void writeBestValues();
194  void checkBounds(const LikelihoodPtrVector& likevec) const;
199  int boundsGiven() const { return boundsgiven; };
204  double getBestLikelihoodScore() const { return bestlikelihood; };
205 protected:
262  int fileopen;
266  ofstream outfile;
267 };
268 
269 #endif
This class implements a dynamic vector of AddressKeeperVector values.
Definition: addresskeepermatrix.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 to store information about the variables that are used in model simulation.
Definition: keeper.h:17
double getBestLikelihoodScore() const
This function will return the best likelihood score found so far by the optimisation process.
Definition: keeper.h:204
void storeVariables(double likvalue, const DoubleVector &point)
This function will store the current value of the variables from the optimisation process.
Definition: keeper.cc:524
void clearAll()
This function will remove all of the text strings from the list used to describe variables.
Definition: keeper.cc:112
void checkBounds(const LikelihoodPtrVector &likevec) const
This function will check that the values of the parameters are within the bounds specified in the inp...
Definition: keeper.cc:497
ofstream outfile
This ofstream is the file that all the parameter information gets sent to.
Definition: keeper.h:266
int numoptvar
This is the number of parameters to be optimised.
Definition: keeper.h:250
DoubleVector bestvalues
This is the DoubleVector used to store the best values of the parameters that the optimisation proces...
Definition: keeper.h:225
void getOptInitialValues(DoubleVector &val) const
This function will return a copy of the initial value of the variables to be optimised.
Definition: keeper.cc:164
void setString(const char *str)
This function will set the text string that is used to describe a variable.
Definition: keeper.cc:116
void writeValues(const LikelihoodPtrVector &likevec, int prec)
This function will write current information about the model parameters to file.
Definition: keeper.cc:283
~Keeper()
This is the default Keeper destructor.
Definition: keeper.cc:56
void getCurrentValues(DoubleVector &val) const
This function will return a copy of the current value of the variables.
Definition: keeper.cc:133
void deleteParameter(const double &var)
This function will delete a variable from the internal list.
Definition: keeper.cc:65
void getOptLowerBounds(DoubleVector &lbs) const
This function will return a copy of the lower bounds of the variables to be optimised.
Definition: keeper.cc:471
int numOptVariables() const
This function will return the number of variables to be optimised.
Definition: keeper.h:145
void addString(const char *str)
This function will add a text string that is used to describe a variable.
Definition: keeper.cc:121
DoubleVector lowerbds
This is the DoubleVector used to store information about the lower bounds of the parameters.
Definition: keeper.h:242
Keeper()
This is the default Keeper constructor.
Definition: keeper.cc:10
void keepVariable(double &value, Parameter &attr)
This function will register a variable in the internal list, along with an initial value.
Definition: keeper.cc:18
void openPrintFile(const char *const filename)
This function will open the output file and write header information.
Definition: keeper.cc:252
double bestlikelihood
This is the best likelihood score found so far by the optimisation process.
Definition: keeper.h:258
DoubleVector initialvalues
This is the DoubleVector used to store the initial values of the parameters.
Definition: keeper.h:213
void clearLast()
This function will remove the last text string from the list used to describe variables.
Definition: keeper.cc:108
StrStack * stack
This is the StrStack used to store information about the use of the parameters.
Definition: keeper.h:234
void getInitialValues(DoubleVector &val) const
This function will return a copy of the initial value of the variables.
Definition: keeper.cc:139
ParameterVector switches
This is the ParameterVector used to store information about the names of the parameters.
Definition: keeper.h:238
AddressKeeperMatrix address
This is the AddressKeeperMatrix used to store information about the value and name of the parameters.
Definition: keeper.h:204
void scaleVariables()
This function will scale the variables to be optimised, for the Hooke & Jeeves and BFGS optimisation ...
Definition: keeper.cc:185
void resetVariables()
This function will reset the variables that have been scaled, to be optimised using the Simulated Ann...
Definition: keeper.cc:177
void changeVariable(const double &pre, double &post)
This function will replace the value of a variable with a new value.
Definition: keeper.cc:93
void writeInitialInformation(const LikelihoodPtrVector &likevec)
This function will write header information about the model parameters to file.
Definition: keeper.cc:263
IntVector opt
This is the IntVector used to store information about whether the parameters are to be optimised.
Definition: keeper.h:230
void getOptFlags(IntVector &opt) const
This function will return a copy of the flags to denote which variables will be optimsised.
Definition: keeper.cc:386
int fileopen
This is the flag used to denote whether an output file has been specified or not.
Definition: keeper.h:262
void getUpperBounds(DoubleVector &ubs) const
This function will return a copy of the upper bounds of the variables.
Definition: keeper.cc:465
int numVariables() const
This function will return the number of variables.
Definition: keeper.cc:129
int boundsgiven
This is the flag used to denote whether the bounds of the parameters have been specified or not.
Definition: keeper.h:254
void getScaledValues(DoubleVector &val) const
This function will return a copy of the scaled value of the variables.
Definition: keeper.cc:145
DoubleVector upperbds
This is the DoubleVector used to store information about the upper bounds of the parameters.
Definition: keeper.h:246
int boundsGiven() const
This function will return the flag used to denote whether the bounds of the parameters have been spec...
Definition: keeper.h:199
void getSwitches(ParameterVector &sw) const
This function will return a copy of the names of the variables.
Definition: keeper.cc:392
void Update(int pos, double &value)
This function will update one Keeper variable with a new value.
Definition: keeper.cc:222
void getLowerBounds(DoubleVector &lbs) const
This function will return a copy of the lower bounds of the variables.
Definition: keeper.cc:459
void getOptUpperBounds(DoubleVector &ubs) const
This function will return a copy of the upper bounds of the variables to be optimised.
Definition: keeper.cc:484
void writeBestValues()
This function will display information about the best values of the parameters found so far during an...
Definition: keeper.cc:240
DoubleVector values
This is the DoubleVector used to store the values of the parameters.
Definition: keeper.h:221
void writeParams(const OptInfoPtrVector &optvec, const char *const filename, int prec, int interrupt)
This function will write final information about the model parameters to file in a column format (whi...
Definition: keeper.cc:398
void getOptScaledValues(DoubleVector &val) const
This function will return a copy of the scaled value of the variables to be optimised.
Definition: keeper.cc:151
DoubleVector scaledvalues
This is the DoubleVector used to store the scaled values of the parameters.
Definition: keeper.h:217
This class implements a dynamic vector of Likelihood values.
Definition: likelihoodptrvector.h:10
This class implements a dynamic vector of OptInfo values.
Definition: optinfoptrvector.h:10
This class implements a dynamic vector of Parameter values.
Definition: parametervector.h:12
This is the class used to store the name of a variable used in the model simulation.
Definition: parameter.h:11
This is the class used to get values for the variables used in the model simulation....
Definition: stochasticdata.h:22
This class implements a simple stack of string objects.
Definition: strstack.h:10