Gadget
Public Member Functions | Protected Attributes | List of all members
Keeper Class Reference

This is the class used to store information about the variables that are used in model simulation. More...

#include <keeper.h>

Collaboration diagram for Keeper:
Collaboration graph

Public Member Functions

 Keeper ()
 This is the default Keeper constructor. More...
 
 ~Keeper ()
 This is the default Keeper destructor. More...
 
void keepVariable (double &value, Parameter &attr)
 This function will register a variable in the internal list, along with an initial value. More...
 
void deleteParameter (const double &var)
 This function will delete a variable from the internal list. More...
 
void changeVariable (const double &pre, double &post)
 This function will replace the value of a variable with a new value. More...
 
void setString (const char *str)
 This function will set the text string that is used to describe a variable. More...
 
void addString (const char *str)
 This function will add a text string that is used to describe a variable. More...
 
void addString (const string str)
 This function will add a text string that is used to describe a variable. More...
 
void clearLast ()
 This function will remove the last text string from the list used to describe variables. More...
 
void clearAll ()
 This function will remove all of the text strings from the list used to describe variables. More...
 
void storeVariables (double likvalue, const DoubleVector &point)
 This function will store the current value of the variables from the optimisation process. More...
 
void resetVariables ()
 This function will reset the variables that have been scaled, to be optimised using the Simulated Annealing optimisation algorithm. More...
 
void scaleVariables ()
 This function will scale the variables to be optimised, for the Hooke & Jeeves and BFGS optimisation algorithms. More...
 
void getOptFlags (IntVector &opt) const
 This function will return a copy of the flags to denote which variables will be optimsised. More...
 
void getSwitches (ParameterVector &sw) const
 This function will return a copy of the names of the variables. More...
 
void getLowerBounds (DoubleVector &lbs) const
 This function will return a copy of the lower bounds of the variables. More...
 
void getUpperBounds (DoubleVector &ubs) const
 This function will return a copy of the upper bounds of the variables. More...
 
void getInitialValues (DoubleVector &val) const
 This function will return a copy of the initial value of the variables. More...
 
void getScaledValues (DoubleVector &val) const
 This function will return a copy of the scaled value of the variables. More...
 
void getCurrentValues (DoubleVector &val) const
 This function will return a copy of the current value of the variables. More...
 
void getOptLowerBounds (DoubleVector &lbs) const
 This function will return a copy of the lower bounds of the variables to be optimised. More...
 
void getOptUpperBounds (DoubleVector &ubs) const
 This function will return a copy of the upper bounds of the variables to be optimised. More...
 
void getOptInitialValues (DoubleVector &val) const
 This function will return a copy of the initial value of the variables to be optimised. More...
 
void getOptScaledValues (DoubleVector &val) const
 This function will return a copy of the scaled value of the variables to be optimised. More...
 
int numVariables () const
 This function will return the number of variables. More...
 
int numOptVariables () const
 This function will return the number of variables to be optimised. More...
 
void Update (int pos, double &value)
 This function will update one Keeper variable with a new value. More...
 
void Update (const DoubleVector &val)
 This function will update the Keeper variables with new values from a vector. More...
 
void Update (const StochasticData *const Stoch)
 This function will update the Keeper variables with new values from StochasticData. More...
 
void openPrintFile (const char *const filename)
 This function will open the output file and write header information. More...
 
void writeInitialInformation (const LikelihoodPtrVector &likevec)
 This function will write header information about the model parameters to file. More...
 
void writeValues (const LikelihoodPtrVector &likevec, int prec)
 This function will write current information about the model parameters to file. More...
 
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 (which can then be used as the starting point for a subsequent model run) More...
 
void writeBestValues ()
 This function will display information about the best values of the parameters found so far during an optimisation run. More...
 
void checkBounds (const LikelihoodPtrVector &likevec) const
 This function will check that the values of the parameters are within the bounds specified in the input file. More...
 
int boundsGiven () const
 This function will return the flag used to denote whether the bounds of the parameters have been specified or not. More...
 
double getBestLikelihoodScore () const
 This function will return the best likelihood score found so far by the optimisation process. More...
 

Protected Attributes

AddressKeeperMatrix address
 This is the AddressKeeperMatrix used to store information about the value and name of the parameters. More...
 
DoubleVector initialvalues
 This is the DoubleVector used to store the initial values of the parameters. More...
 
DoubleVector scaledvalues
 This is the DoubleVector used to store the scaled values of the parameters. More...
 
DoubleVector values
 This is the DoubleVector used to store the values of the parameters. More...
 
DoubleVector bestvalues
 This is the DoubleVector used to store the best values of the parameters that the optimisation process has found so far. More...
 
IntVector opt
 This is the IntVector used to store information about whether the parameters are to be optimised. More...
 
StrStackstack
 This is the StrStack used to store information about the use of the parameters. More...
 
ParameterVector switches
 This is the ParameterVector used to store information about the names of the parameters. More...
 
DoubleVector lowerbds
 This is the DoubleVector used to store information about the lower bounds of the parameters. More...
 
DoubleVector upperbds
 This is the DoubleVector used to store information about the upper bounds of the parameters. More...
 
int numoptvar
 This is the number of parameters to be optimised. More...
 
int boundsgiven
 This is the flag used to denote whether the bounds of the parameters have been specified or not. More...
 
double bestlikelihood
 This is the best likelihood score found so far by the optimisation process. More...
 
int fileopen
 This is the flag used to denote whether an output file has been specified or not. More...
 
ofstream outfile
 This ofstream is the file that all the parameter information gets sent to. More...
 

Detailed Description

This is the class used to store information about the variables that are used in model simulation.

This class stores all the information about the variables that are used in the model simulation. This includes the current value, the initial value and best value found so far by any optimisation routines, the upper and lower bounds for the variables and a flag to denote whether the variable is to be optimised or not. This class also updates the model parameters with new values for the variables, either as a result of the optimisation routines or when new values for the parameters are received from the network if the simulation is part of a parallel optimisation, using paramin.

Constructor & Destructor Documentation

◆ Keeper()

Keeper::Keeper ( )

This is the default Keeper constructor.

◆ ~Keeper()

Keeper::~Keeper ( )

This is the default Keeper destructor.

Member Function Documentation

◆ addString() [1/2]

void Keeper::addString ( const char *  str)

This function will add a text string that is used to describe a variable.

Parameters
stris the text string to be stored

◆ addString() [2/2]

void Keeper::addString ( const string  str)

This function will add a text string that is used to describe a variable.

Parameters
stris the text string to be stored

◆ boundsGiven()

int Keeper::boundsGiven ( ) const
inline

This function will return the flag used to denote whether the bounds of the parameters have been specified or not.

Returns
flag to denote whether the bounds have been given or not

◆ changeVariable()

void Keeper::changeVariable ( const double &  pre,
double &  post 
)

This function will replace the value of a variable with a new value.

Parameters
preis the old value for the variable
postis the new value for the variable

◆ checkBounds()

void Keeper::checkBounds ( const LikelihoodPtrVector likevec) const

This function will check that the values of the parameters are within the bounds specified in the input file.

Parameters
likevecis the LikelihoodPtrVector containing the likelihood components for the current model

◆ clearAll()

void Keeper::clearAll ( )

This function will remove all of the text strings from the list used to describe variables.

◆ clearLast()

void Keeper::clearLast ( )

This function will remove the last text string from the list used to describe variables.

◆ deleteParameter()

void Keeper::deleteParameter ( const double &  var)

This function will delete a variable from the internal list.

Parameters
varis the value for the variable

◆ getBestLikelihoodScore()

double Keeper::getBestLikelihoodScore ( ) const
inline

This function will return the best likelihood score found so far by the optimisation process.

Returns
bestlikelihood

◆ getCurrentValues()

void Keeper::getCurrentValues ( DoubleVector val) const

This function will return a copy of the current value of the variables.

Parameters
valis the DoubleVector that will contain a copy of the current values

◆ getInitialValues()

void Keeper::getInitialValues ( DoubleVector val) const

This function will return a copy of the initial value of the variables.

Parameters
valis the DoubleVector that will contain a copy of the initial values

◆ getLowerBounds()

void Keeper::getLowerBounds ( DoubleVector lbs) const

This function will return a copy of the lower bounds of the variables.

Parameters
lbsis the DoubleVector that will contain a copy of the lower bounds

◆ getOptFlags()

void Keeper::getOptFlags ( IntVector opt) const

This function will return a copy of the flags to denote which variables will be optimsised.

Parameters
optis the IntVector that will contain a copy of the flags

◆ getOptInitialValues()

void Keeper::getOptInitialValues ( DoubleVector val) const

This function will return a copy of the initial value of the variables to be optimised.

Parameters
valis the DoubleVector that will contain a copy of the initial values

◆ getOptLowerBounds()

void Keeper::getOptLowerBounds ( DoubleVector lbs) const

This function will return a copy of the lower bounds of the variables to be optimised.

Parameters
lbsis the DoubleVector that will contain a copy of the lower bounds

◆ getOptScaledValues()

void Keeper::getOptScaledValues ( DoubleVector val) const

This function will return a copy of the scaled value of the variables to be optimised.

Parameters
valis the DoubleVector that will contain a copy of the scaled values

◆ getOptUpperBounds()

void Keeper::getOptUpperBounds ( DoubleVector ubs) const

This function will return a copy of the upper bounds of the variables to be optimised.

Parameters
ubsis the DoubleVector that will contain a copy of the upper bounds

◆ getScaledValues()

void Keeper::getScaledValues ( DoubleVector val) const

This function will return a copy of the scaled value of the variables.

Parameters
valis the DoubleVector that will contain a copy of the scaled values

◆ getSwitches()

void Keeper::getSwitches ( ParameterVector sw) const

This function will return a copy of the names of the variables.

Parameters
swis the ParameterVector that will contain a copy of the names

◆ getUpperBounds()

void Keeper::getUpperBounds ( DoubleVector ubs) const

This function will return a copy of the upper bounds of the variables.

Parameters
ubsis the DoubleVector that will contain a copy of the upper bounds

◆ keepVariable()

void Keeper::keepVariable ( double &  value,
Parameter attr 
)

This function will register a variable in the internal list, along with an initial value.

Parameters
valueis the value for the variable
attris the name of the Parameter for the variable

◆ numOptVariables()

int Keeper::numOptVariables ( ) const
inline

This function will return the number of variables to be optimised.

Returns
number of variables to be optimised

◆ numVariables()

int Keeper::numVariables ( ) const

This function will return the number of variables.

Returns
number of variables

◆ openPrintFile()

void Keeper::openPrintFile ( const char *const  filename)

This function will open the output file and write header information.

Parameters
filenameis the name of the file to write the model information to

◆ resetVariables()

void Keeper::resetVariables ( )

This function will reset the variables that have been scaled, to be optimised using the Simulated Annealing optimisation algorithm.

◆ scaleVariables()

void Keeper::scaleVariables ( )

This function will scale the variables to be optimised, for the Hooke & Jeeves and BFGS optimisation algorithms.

◆ setString()

void Keeper::setString ( const char *  str)

This function will set the text string that is used to describe a variable.

Parameters
stris the text string to be stored

◆ storeVariables()

void Keeper::storeVariables ( double  likvalue,
const DoubleVector point 
)

This function will store the current value of the variables from the optimisation process.

Parameters
likvalueis the current likelihood value
pointis the DoubleVector of the current parameter values

◆ Update() [1/3]

void Keeper::Update ( const DoubleVector val)

This function will update the Keeper variables with new values from a vector.

Parameters
valis the DoubleVector containing the new values of the variables

◆ Update() [2/3]

void Keeper::Update ( const StochasticData *const  Stoch)

This function will update the Keeper variables with new values from StochasticData.

Parameters
Stochis the StochasticData containing the new values of the variables

◆ Update() [3/3]

void Keeper::Update ( int  pos,
double &  value 
)

This function will update one Keeper variable with a new value.

Parameters
posis the identifier of the variable to update
valueis the new value of the variable

◆ writeBestValues()

void Keeper::writeBestValues ( )

This function will display information about the best values of the parameters found so far during an optimisation run.

◆ writeInitialInformation()

void Keeper::writeInitialInformation ( const LikelihoodPtrVector likevec)

This function will write header information about the model parameters to file.

Parameters
likevecis the LikelihoodPtrVector containing the likelihood components for the current model

◆ writeParams()

void Keeper::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 (which can then be used as the starting point for a subsequent model run)

Parameters
optvecis the OptInfoPtrVector containing the optimisation algorithms used for the current model
filenameis the name of the file to write the model information to
precis the precision to use in the output file
interruptis the flag to denote whether the current run was interrupted by the user or not

◆ writeValues()

void Keeper::writeValues ( const LikelihoodPtrVector likevec,
int  prec 
)

This function will write current information about the model parameters to file.

Parameters
likevecis the LikelihoodPtrVector containing the likelihood components for the current model
precis the precision to use in the output file

Member Data Documentation

◆ address

AddressKeeperMatrix Keeper::address
protected

This is the AddressKeeperMatrix used to store information about the value and name of the parameters.

◆ bestlikelihood

double Keeper::bestlikelihood
protected

This is the best likelihood score found so far by the optimisation process.

◆ bestvalues

DoubleVector Keeper::bestvalues
protected

This is the DoubleVector used to store the best values of the parameters that the optimisation process has found so far.

◆ boundsgiven

int Keeper::boundsgiven
protected

This is the flag used to denote whether the bounds of the parameters have been specified or not.

◆ fileopen

int Keeper::fileopen
protected

This is the flag used to denote whether an output file has been specified or not.

◆ initialvalues

DoubleVector Keeper::initialvalues
protected

This is the DoubleVector used to store the initial values of the parameters.

◆ lowerbds

DoubleVector Keeper::lowerbds
protected

This is the DoubleVector used to store information about the lower bounds of the parameters.

◆ numoptvar

int Keeper::numoptvar
protected

This is the number of parameters to be optimised.

◆ opt

IntVector Keeper::opt
protected

This is the IntVector used to store information about whether the parameters are to be optimised.

Note
If opt[i] is 1 then parameter i is to be optimised, else if opt[i] is 0 then parameter i is not to be optimised and its value is fixed throughout the optimisation process

◆ outfile

ofstream Keeper::outfile
protected

This ofstream is the file that all the parameter information gets sent to.

◆ scaledvalues

DoubleVector Keeper::scaledvalues
protected

This is the DoubleVector used to store the scaled values of the parameters.

◆ stack

StrStack* Keeper::stack
protected

This is the StrStack used to store information about the use of the parameters.

◆ switches

ParameterVector Keeper::switches
protected

This is the ParameterVector used to store information about the names of the parameters.

◆ upperbds

DoubleVector Keeper::upperbds
protected

This is the DoubleVector used to store information about the upper bounds of the parameters.

◆ values

DoubleVector Keeper::values
protected

This is the DoubleVector used to store the values of the parameters.


The documentation for this class was generated from the following files: