Gadget
ecosystem.h
Go to the documentation of this file.
1 #ifndef ecosystem_h
2 #define ecosystem_h
3 
4 #include "areatime.h"
5 #include "keeper.h"
6 #include "errorhandler.h"
7 #include "tagptrvector.h"
8 #include "baseclassptrvector.h"
9 #include "stockptrvector.h"
10 #include "fleetptrvector.h"
11 #include "otherfoodptrvector.h"
12 #include "printerptrvector.h"
13 #include "likelihoodptrvector.h"
14 #include "optinfoptrvector.h"
15 #include "stock.h"
16 #include "fleet.h"
17 #include "otherfood.h"
18 #include "printer.h"
19 #include "maininfo.h"
20 #include "printinfo.h"
21 #include "optinfo.h"
22 #include "gadget.h"
23 
30 class Ecosystem {
31 public:
35  Ecosystem() {};
40  Ecosystem(const MainInfo& main);
44  ~Ecosystem();
50  void readMain(CommentStream& infile, const MainInfo& main);
55  void readLikelihood(CommentStream& infile);
60  void readPrinters(CommentStream& infile);
65  void readFleet(CommentStream& infile);
70  void readTagging(CommentStream& infile);
75  void readOtherFood(CommentStream& infile);
80  void readStock(CommentStream& infile);
85  void readOptimisation(CommentStream& infile);
90  void writeStatus(const char* filename) const;
95  void writeInitialInformation(const char* const filename);
99  void writeValues();
105  void writeParams(const char* const filename, int prec) const;
113  void writeOptValues();
117  void Optimise();
121  void Initialise();
126  void Update(const StochasticData* const Stochastic) const {keeper->Update(Stochastic); };
130  void Reset();
136  void storeVariables(double likvalue, const DoubleVector& point) { keeper->storeVariables(likvalue, point); };
168  void checkBounds() const { keeper->checkBounds(likevec); };
173  int numVariables() const { return keeper->numVariables(); };
178  int numOptVariables() const { return keeper->numOptVariables(); };
184  void Simulate(int print);
190  void updatePredationOneArea(int area = 0);
196  void updatePopulationOneArea(int area = 0);
202  void updateAgesOneArea(int area = 0);
209  double SimulateAndUpdate(const DoubleVector& x);
214  double getLikelihood() const { return likelihood; };
219  int getFuncEval() const { return funceval; };
224  int getCurrentTime() const { return TimeInfo->getTime(); };
229  int getCurrentYear() const { return TimeInfo->getYear(); };
234  int getCurrentStep() const { return TimeInfo->getStep(); };
239  int numTotalSteps() const { return TimeInfo->numTotalSteps(); };
263  volatile int interrupted;
264 protected:
268  double likelihood;
272  int funceval;
340 };
341 
342 #endif
This is the class used to store information about the areas used for the current model.
Definition: areatime.h:18
This class implements a dynamic vector of BaseClass values.
Definition: baseclassptrvector.h:10
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 double values.
Definition: doublevector.h:11
This is the class used to control the model simulation.
Definition: ecosystem.h:30
TimeClass * TimeInfo
This is the TimeClass for the current model.
Definition: ecosystem.h:292
OptInfoPtrVector optvec
This is the OptInfoPtrVector of the optimisation algorithms for the current model.
Definition: ecosystem.h:288
void writeValues()
This function will write current information about the model parameters to file.
Definition: ecosystem.cc:166
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 (whi...
Definition: ecosystem.cc:170
void getOptInitialValues(DoubleVector &val) const
This function will return a copy of the initial value of the variables to be optimised.
Definition: ecosystem.h:149
void getOptScaledValues(DoubleVector &val) const
This function will return a copy of the scaled value of the variables to be optimised.
Definition: ecosystem.h:154
void writeInitialInformation(const char *const filename)
This function will write header information about the model parameters to file.
Definition: ecosystem.cc:161
double SimulateAndUpdate(const DoubleVector &x)
This function will update the model parameters, run the model and calculate a likelihood score.
Definition: ecosystem.cc:109
StockPtrVector & getModelStockVector()
This function will return the stocks used in the simulation.
Definition: ecosystem.h:259
DoubleVector initialval
This is the DoubleVector used to store the initial values of the parameters.
Definition: ecosystem.h:329
void updatePredationOneArea(int area=0)
This function will calculate the predation, and update the population, on an area.
Definition: simulation.cc:7
PrinterPtrVector & getModelPrinterVector()
This function will return the printer components used in the simulation.
Definition: ecosystem.h:249
~Ecosystem()
This is the default Ecosystem destructor.
Definition: ecosystem.cc:52
void Reset()
This function will reset the Ecosystem information.
Definition: ecosystem.cc:92
DoubleVector currentval
This is the DoubleVector used to store the current values of the parameters.
Definition: ecosystem.h:334
int numOptVariables() const
This function will return the number of variables to be optimised.
Definition: ecosystem.h:178
BaseClassPtrVector basevec
This is the BaseClassPtrVector of the stocks, fleets and otherfood classes for the current model.
Definition: ecosystem.h:276
void getOptUpperBounds(DoubleVector &ubs) const
This function will return a copy of the upper bounds of the variables to be optimised.
Definition: ecosystem.h:164
PrintInfo printinfo
This is the PrintInfo specifying the parameter output from the current model.
Definition: ecosystem.h:320
void readOtherFood(CommentStream &infile)
This function will read the otherfood data from the input file.
Definition: readmain.cc:87
LikelihoodPtrVector likevec
This is the LikelihoodPtrVector of the likelihood components for the current model.
Definition: ecosystem.h:280
void writeBestValues()
This function will display information about the best values of the parameters found so far during an...
Definition: ecosystem.h:109
void readStock(CommentStream &infile)
This function will read the stock data from the input file.
Definition: readmain.cc:106
int getCurrentYear() const
This function will return the current year in the simulation.
Definition: ecosystem.h:229
TagPtrVector tagvec
This is the TagPtrVector of the tagging experiments for the current model.
Definition: ecosystem.h:308
void Simulate(int print)
This function will simulate the population in the model.
Definition: simulation.cc:64
void checkBounds() const
This function will check that the values of the parameters are within the specified bounds.
Definition: ecosystem.h:168
void getOptLowerBounds(DoubleVector &lbs) const
This function will return a copy of the lower bounds of the variables to be optimised.
Definition: ecosystem.h:159
StockPtrVector stockvec
This is the StockPtrVector of the stocks for the current model.
Definition: ecosystem.h:304
LikelihoodPtrVector & getModelLikelihoodVector()
This function will return the likelihood components used in the simulation.
Definition: ecosystem.h:244
void Initialise()
This function will initialise the Ecosystem parameters.
Definition: initialize.cc:37
void readOptimisation(CommentStream &infile)
This function will read in the optimisation parameters from the input file.
Definition: readmain.cc:286
void readTagging(CommentStream &infile)
This function will read the tagging data from the input file.
Definition: readmain.cc:69
Keeper * keeper
This is the Keeper for the current model.
Definition: ecosystem.h:300
void updateAgesOneArea(int area=0)
This function will update the ages of the population on an area.
Definition: simulation.cc:50
int funceval
This is the current iteration.
Definition: ecosystem.h:272
void readLikelihood(CommentStream &infile)
This function will read the likelihood data from the input file.
Definition: readmain.cc:183
double likelihood
This is the value of the likelihood score for the current simulation.
Definition: ecosystem.h:268
PrinterPtrVector printvec
This is the PrinterPtrVector of the printer classes for the current model.
Definition: ecosystem.h:284
void readFleet(CommentStream &infile)
This function will read the fleet data from the input file.
Definition: readmain.cc:35
int numTotalSteps() const
This function will return the total number of timestep in the simulation.
Definition: ecosystem.h:239
void writeOptValues()
This function will display information about the optimised values of the parameters.
Definition: ecosystem.cc:145
void writeStatus(const char *filename) const
This function will write the current model status to file.
Definition: ecosystem.cc:70
Ecosystem()
This is the default Ecosystem constructor.
Definition: ecosystem.h:35
FleetPtrVector fleetvec
This is the FleetPtrVector of the fleets for the current model.
Definition: ecosystem.h:316
volatile int interrupted
This is the flag used to denote whether the user has interrupted the current model run.
Definition: ecosystem.h:259
void updatePopulationOneArea(int area=0)
This function will update the population numbers on an area.
Definition: simulation.cc:27
double getLikelihood() const
This function will return the likelihood score from the current simulation.
Definition: ecosystem.h:214
int printcount
This is the counter for the printing interval for the -o output from the simualtion.
Definition: ecosystem.h:324
OtherFoodPtrVector otherfoodvec
This is the OtherFoodPtrVector of the otherfood for the current model.
Definition: ecosystem.h:312
void Update(const StochasticData *const Stochastic) const
This function will update the Ecosystem parameters with new values from StochasticData.
Definition: ecosystem.h:126
void readPrinters(CommentStream &infile)
This function will read the printer data from the input file.
Definition: readmain.cc:118
void readMain(CommentStream &infile, const MainInfo &main)
This function will read the model data from the main input file.
Definition: readmain.cc:334
int getCurrentTime() const
This function will return the current time in the simulation.
Definition: ecosystem.h:224
int numVariables() const
This function will return the number of variables.
Definition: ecosystem.h:173
AreaClass * Area
This is the AreaClass for the current model.
Definition: ecosystem.h:296
void Optimise()
This is the function that will optimise the likelihood score.
Definition: ecosystem.cc:101
int getCurrentStep() const
This function will return the current step in the simulation.
Definition: ecosystem.h:234
void scaleVariables()
This function will scale the variables to be optimised, for the Hooke & Jeeves and BFGS optimisation ...
Definition: ecosystem.h:144
IntVector optflag
This is the IntVector used to store information about whether the parameters are to be optimised.
Definition: ecosystem.h:339
FleetPtrVector & getModelFleetVector()
This function will return the fleets used in the simulation.
Definition: ecosystem.h:254
void storeVariables(double likvalue, const DoubleVector &point)
This function will store the current value of the variables from the optimisation process.
Definition: ecosystem.h:136
int getFuncEval() const
This function will return the total number of iterations completed.
Definition: ecosystem.h:219
void resetVariables()
This function will reset the variables that have been scaled, to be optimised using the Simulated Ann...
Definition: ecosystem.h:140
This class implements a dynamic vector of Fleet values.
Definition: fleetptrvector.h:10
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
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 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
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 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 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
int numVariables() const
This function will return the number of variables.
Definition: keeper.cc:129
void Update(int pos, double &value)
This function will update one Keeper variable with a new value.
Definition: keeper.cc:222
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
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
This class implements a dynamic vector of Likelihood values.
Definition: likelihoodptrvector.h:10
This is the class used to store information for the current model given from the command-line.
Definition: maininfo.h:12
This class implements a dynamic vector of OptInfo values.
Definition: optinfoptrvector.h:10
This class implements a dynamic vector of OtherFood values.
Definition: otherfoodptrvector.h:12
This is the class used to store information about what format the model parameters should be written ...
Definition: printinfo.h:10
This class implements a dynamic vector of Printer values.
Definition: printerptrvector.h:10
This is the class used to get values for the variables used in the model simulation....
Definition: stochasticdata.h:22
This class implements a dynamic vector of Stock values.
Definition: stockptrvector.h:10
This class implements a dynamic vector of Tags values.
Definition: tagptrvector.h:12
This is the class used to store information about the timesteps used for the current model.
Definition: areatime.h:87
int getTime() const
This will return the total number of timesteps that have taken place in the simulation from the start...
Definition: areatime.h:118
int getYear() const
This will return the current year of the model simulation.
Definition: areatime.h:113
int getStep() const
This will return the current step of the model simulation.
Definition: areatime.h:108
int numTotalSteps() const
This will return the total number of timesteps in the model simulation.
Definition: areatime.h:161
int main(int aNumber, char *const aVector[])
Definition: gadget.cc:13