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

This is the class used to control the model simulation. More...

#include <ecosystem.h>

Collaboration diagram for Ecosystem:
Collaboration graph

Public Member Functions

 Ecosystem ()
 This is the default Ecosystem constructor. More...
 
 Ecosystem (const MainInfo &main)
 This is the Ecosystem constructor specifying details about the model. More...
 
 ~Ecosystem ()
 This is the default Ecosystem destructor. More...
 
void readMain (CommentStream &infile, const MainInfo &main)
 This function will read the model data from the main input file. More...
 
void readLikelihood (CommentStream &infile)
 This function will read the likelihood data from the input file. More...
 
void readPrinters (CommentStream &infile)
 This function will read the printer data from the input file. More...
 
void readFleet (CommentStream &infile)
 This function will read the fleet data from the input file. More...
 
void readTagging (CommentStream &infile)
 This function will read the tagging data from the input file. More...
 
void readOtherFood (CommentStream &infile)
 This function will read the otherfood data from the input file. More...
 
void readStock (CommentStream &infile)
 This function will read the stock data from the input file. More...
 
void readOptimisation (CommentStream &infile)
 This function will read in the optimisation parameters from the input file. More...
 
void writeStatus (const char *filename) const
 This function will write the current model status to file. More...
 
void writeInitialInformation (const char *const filename)
 This function will write header information about the model parameters to file. More...
 
void writeValues ()
 This function will write current information about the model parameters to file. More...
 
void writeParams (const char *const filename, int prec) const
 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 writeOptValues ()
 This function will display information about the optimised values of the parameters. More...
 
void Optimise ()
 This is the function that will optimise the likelihood score. More...
 
void Initialise ()
 This function will initialise the Ecosystem parameters. More...
 
void Update (const StochasticData *const Stochastic) const
 This function will update the Ecosystem parameters with new values from StochasticData. More...
 
void Reset ()
 This function will reset the Ecosystem information. 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 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...
 
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 checkBounds () const
 This function will check that the values of the parameters are within the specified bounds. 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 Simulate (int print)
 This function will simulate the population in the model. More...
 
void updatePredationOneArea (int area=0)
 This function will calculate the predation, and update the population, on an area. More...
 
void updatePopulationOneArea (int area=0)
 This function will update the population numbers on an area. More...
 
void updateAgesOneArea (int area=0)
 This function will update the ages of the population on an area. More...
 
double SimulateAndUpdate (const DoubleVector &x)
 This function will update the model parameters, run the model and calculate a likelihood score. More...
 
double getLikelihood () const
 This function will return the likelihood score from the current simulation. More...
 
int getFuncEval () const
 This function will return the total number of iterations completed. More...
 
int getCurrentTime () const
 This function will return the current time in the simulation. More...
 
int getCurrentYear () const
 This function will return the current year in the simulation. More...
 
int getCurrentStep () const
 This function will return the current step in the simulation. More...
 
int numTotalSteps () const
 This function will return the total number of timestep in the simulation. More...
 
LikelihoodPtrVectorgetModelLikelihoodVector ()
 This function will return the likelihood components used in the simulation. More...
 
PrinterPtrVectorgetModelPrinterVector ()
 This function will return the printer components used in the simulation. More...
 
FleetPtrVectorgetModelFleetVector ()
 This function will return the fleets used in the simulation. More...
 
StockPtrVectorgetModelStockVector ()
 This function will return the stocks used in the simulation. More...
 

Public Attributes

volatile int interrupted
 This is the flag used to denote whether the user has interrupted the current model run. More...
 

Protected Attributes

double likelihood
 This is the value of the likelihood score for the current simulation. More...
 
int funceval
 This is the current iteration. More...
 
BaseClassPtrVector basevec
 This is the BaseClassPtrVector of the stocks, fleets and otherfood classes for the current model. More...
 
LikelihoodPtrVector likevec
 This is the LikelihoodPtrVector of the likelihood components for the current model. More...
 
PrinterPtrVector printvec
 This is the PrinterPtrVector of the printer classes for the current model. More...
 
OptInfoPtrVector optvec
 This is the OptInfoPtrVector of the optimisation algorithms for the current model. More...
 
TimeClassTimeInfo
 This is the TimeClass for the current model. More...
 
AreaClassArea
 This is the AreaClass for the current model. More...
 
Keeperkeeper
 This is the Keeper for the current model. More...
 
StockPtrVector stockvec
 This is the StockPtrVector of the stocks for the current model. More...
 
TagPtrVector tagvec
 This is the TagPtrVector of the tagging experiments for the current model. More...
 
OtherFoodPtrVector otherfoodvec
 This is the OtherFoodPtrVector of the otherfood for the current model. More...
 
FleetPtrVector fleetvec
 This is the FleetPtrVector of the fleets for the current model. More...
 
PrintInfo printinfo
 This is the PrintInfo specifying the parameter output from the current model. More...
 
int printcount
 This is the counter for the printing interval for the -o output from the simualtion. More...
 
DoubleVector initialval
 This is the DoubleVector used to store the initial values of the parameters. More...
 
DoubleVector currentval
 This is the DoubleVector used to store the current values of the parameters. More...
 
IntVector optflag
 This is the IntVector used to store information about whether the parameters are to be optimised. More...
 

Detailed Description

This is the class used to control the model simulation.

This is the main class for the model simulation. This class contains pointers to all the objects that are to be used in the model simulation - the stocks and fleets, the model variables, any printer classes used to output the modelled population and any likelihood classes used to compare the modelled population to data. This class controls the model simulation, from the reading of the input files, simulating the modelled population on each timestep and printing the results, and finally calculating an overall likelihood score. This class is also used during an optimising run to update the variables to new values from the optimisation algorithm and calculating a new likelihood score based on these new values.

Constructor & Destructor Documentation

◆ Ecosystem() [1/2]

Ecosystem::Ecosystem ( )
inline

This is the default Ecosystem constructor.

◆ Ecosystem() [2/2]

Ecosystem::Ecosystem ( const MainInfo main)

This is the Ecosystem constructor specifying details about the model.

Parameters
mainis the MainInfo specifying the command line options for the model run

◆ ~Ecosystem()

Ecosystem::~Ecosystem ( )

This is the default Ecosystem destructor.

Member Function Documentation

◆ checkBounds()

void Ecosystem::checkBounds ( ) const
inline

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

◆ getCurrentStep()

int Ecosystem::getCurrentStep ( ) const
inline

This function will return the current step in the simulation.

Returns
current step

◆ getCurrentTime()

int Ecosystem::getCurrentTime ( ) const
inline

This function will return the current time in the simulation.

Returns
current time

◆ getCurrentYear()

int Ecosystem::getCurrentYear ( ) const
inline

This function will return the current year in the simulation.

Returns
current year

◆ getFuncEval()

int Ecosystem::getFuncEval ( ) const
inline

This function will return the total number of iterations completed.

Returns
number of iterations

◆ getLikelihood()

double Ecosystem::getLikelihood ( ) const
inline

This function will return the likelihood score from the current simulation.

Returns
likelihood score

◆ getModelFleetVector()

FleetPtrVector& Ecosystem::getModelFleetVector ( )
inline

This function will return the fleets used in the simulation.

Returns
FleetPtrVector containing all the fleets used in the simulation

◆ getModelLikelihoodVector()

LikelihoodPtrVector& Ecosystem::getModelLikelihoodVector ( )
inline

This function will return the likelihood components used in the simulation.

Returns
LikelihoodPtrVector containing all the likelihood components used in the simulation

◆ getModelPrinterVector()

PrinterPtrVector& Ecosystem::getModelPrinterVector ( )
inline

This function will return the printer components used in the simulation.

Returns
PrinterPtrVector containing all the printer components used in the simulation

◆ getModelStockVector()

StockPtrVector& Ecosystem::getModelStockVector ( )
inline

This function will return the stocks used in the simulation.

Returns
StockPtrVector containing all the stocks used in the simulation

◆ getOptInitialValues()

void Ecosystem::getOptInitialValues ( DoubleVector val) const
inline

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 Ecosystem::getOptLowerBounds ( DoubleVector lbs) const
inline

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 Ecosystem::getOptScaledValues ( DoubleVector val) const
inline

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 Ecosystem::getOptUpperBounds ( DoubleVector ubs) const
inline

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

◆ Initialise()

void Ecosystem::Initialise ( )

This function will initialise the Ecosystem parameters.

◆ numOptVariables()

int Ecosystem::numOptVariables ( ) const
inline

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

Returns
number of variables to be optimised

◆ numTotalSteps()

int Ecosystem::numTotalSteps ( ) const
inline

This function will return the total number of timestep in the simulation.

Returns
number of timesteps

◆ numVariables()

int Ecosystem::numVariables ( ) const
inline

This function will return the number of variables.

Returns
number of variables

◆ Optimise()

void Ecosystem::Optimise ( )

This is the function that will optimise the likelihood score.

◆ readFleet()

void Ecosystem::readFleet ( CommentStream infile)

This function will read the fleet data from the input file.

Parameters
infileis the CommentStream to read the fleet data from

◆ readLikelihood()

void Ecosystem::readLikelihood ( CommentStream infile)

This function will read the likelihood data from the input file.

Parameters
infileis the CommentStream to read the likelihood data from

◆ readMain()

void Ecosystem::readMain ( CommentStream infile,
const MainInfo main 
)

This function will read the model data from the main input file.

Parameters
infileis the CommentStream to read the likelihood data from
mainis the MainInfo specifying the command line options for the model run

◆ readOptimisation()

void Ecosystem::readOptimisation ( CommentStream infile)

This function will read in the optimisation parameters from the input file.

Parameters
infileis the CommentStream to read the optimisation parameters from

◆ readOtherFood()

void Ecosystem::readOtherFood ( CommentStream infile)

This function will read the otherfood data from the input file.

Parameters
infileis the CommentStream to read the otherfood data from

◆ readPrinters()

void Ecosystem::readPrinters ( CommentStream infile)

This function will read the printer data from the input file.

Parameters
infileis the CommentStream to read the printer data from

◆ readStock()

void Ecosystem::readStock ( CommentStream infile)

This function will read the stock data from the input file.

Parameters
infileis the CommentStream to read the stock data from

◆ readTagging()

void Ecosystem::readTagging ( CommentStream infile)

This function will read the tagging data from the input file.

Parameters
infileis the CommentStream to read the tagging data from

◆ Reset()

void Ecosystem::Reset ( )

This function will reset the Ecosystem information.

◆ resetVariables()

void Ecosystem::resetVariables ( )
inline

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

◆ scaleVariables()

void Ecosystem::scaleVariables ( )
inline

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

◆ Simulate()

void Ecosystem::Simulate ( int  print)

This function will simulate the population in the model.

Parameters
printis the flag to denote whether the model output should be printed or not
Note
This function covers a single running of the model, calculating the population structure and also calculating the likelihood score obtained from comparing the modelled population to the data specified in the likelihood components

◆ SimulateAndUpdate()

double Ecosystem::SimulateAndUpdate ( const DoubleVector x)

This function will update the model parameters, run the model and calculate a likelihood score.

Parameters
xis the DoubleVector containing the updated values for the parameters
Returns
likelihood score
Note
This function gets updated values for the model parameters from the optimisation algorithm and performs a model run based on these new values, calculating a new likelihood score that is then returned to the optimisation algorithm

◆ storeVariables()

void Ecosystem::storeVariables ( double  likvalue,
const DoubleVector point 
)
inline

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()

void Ecosystem::Update ( const StochasticData *const  Stochastic) const
inline

This function will update the Ecosystem parameters with new values from StochasticData.

Parameters
Stochasticis the StochasticData containing the new values of the parameters

◆ updateAgesOneArea()

void Ecosystem::updateAgesOneArea ( int  area = 0)

This function will update the ages of the population on an area.

Parameters
areais the area to update the population on (default value 0)
Note
This function covers the increase in age and the simple 'doesmove' option for movement between stocks

◆ updatePopulationOneArea()

void Ecosystem::updatePopulationOneArea ( int  area = 0)

This function will update the population numbers on an area.

Parameters
areais the area to update the population on (default value 0)
Note
This function covers the growth, various movements between stocks due to maturity and straying, spawning, and adding new recruits into the model

◆ updatePredationOneArea()

void Ecosystem::updatePredationOneArea ( int  area = 0)

This function will calculate the predation, and update the population, on an area.

Parameters
areais the area to calculate the predation on (default value 0)
Note
This function covers the predation of the preys by the predators, and consequent population changes, for a sub-step within a timestep of the model

◆ writeBestValues()

void Ecosystem::writeBestValues ( )
inline

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

◆ writeInitialInformation()

void Ecosystem::writeInitialInformation ( const char *const  filename)

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

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

◆ writeOptValues()

void Ecosystem::writeOptValues ( )

This function will display information about the optimised values of the parameters.

◆ writeParams()

void Ecosystem::writeParams ( const char *const  filename,
int  prec 
) const

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
filenameis the name of the file to write the model information to
precis the precision to use in the output file

◆ writeStatus()

void Ecosystem::writeStatus ( const char *  filename) const

This function will write the current model status to file.

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

◆ writeValues()

void Ecosystem::writeValues ( )

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

Member Data Documentation

◆ Area

AreaClass* Ecosystem::Area
protected

This is the AreaClass for the current model.

◆ basevec

BaseClassPtrVector Ecosystem::basevec
protected

This is the BaseClassPtrVector of the stocks, fleets and otherfood classes for the current model.

◆ currentval

DoubleVector Ecosystem::currentval
protected

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

Note
This vector is only used to temporarily store values during an optimising run

◆ fleetvec

FleetPtrVector Ecosystem::fleetvec
protected

This is the FleetPtrVector of the fleets for the current model.

◆ funceval

int Ecosystem::funceval
protected

This is the current iteration.

◆ initialval

DoubleVector Ecosystem::initialval
protected

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

Note
This vector is only used to temporarily store values during an optimising run

◆ interrupted

volatile int Ecosystem::interrupted

This is the flag used to denote whether the user has interrupted the current model run.

◆ keeper

Keeper* Ecosystem::keeper
protected

This is the Keeper for the current model.

◆ likelihood

double Ecosystem::likelihood
protected

This is the value of the likelihood score for the current simulation.

◆ likevec

LikelihoodPtrVector Ecosystem::likevec
protected

This is the LikelihoodPtrVector of the likelihood components for the current model.

◆ optflag

IntVector Ecosystem::optflag
protected

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

Note
This vector is only used to temporarily store values during an optimising run

◆ optvec

OptInfoPtrVector Ecosystem::optvec
protected

This is the OptInfoPtrVector of the optimisation algorithms for the current model.

◆ otherfoodvec

OtherFoodPtrVector Ecosystem::otherfoodvec
protected

This is the OtherFoodPtrVector of the otherfood for the current model.

◆ printcount

int Ecosystem::printcount
protected

This is the counter for the printing interval for the -o output from the simualtion.

◆ printinfo

PrintInfo Ecosystem::printinfo
protected

This is the PrintInfo specifying the parameter output from the current model.

◆ printvec

PrinterPtrVector Ecosystem::printvec
protected

This is the PrinterPtrVector of the printer classes for the current model.

◆ stockvec

StockPtrVector Ecosystem::stockvec
protected

This is the StockPtrVector of the stocks for the current model.

◆ tagvec

TagPtrVector Ecosystem::tagvec
protected

This is the TagPtrVector of the tagging experiments for the current model.

◆ TimeInfo

TimeClass* Ecosystem::TimeInfo
protected

This is the TimeClass for the current model.


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