Gadget
predator.h
Go to the documentation of this file.
1 #ifndef predator_h
2 #define predator_h
3 
4 #include "areatime.h"
5 #include "lengthgroup.h"
6 #include "commentstream.h"
7 #include "preyptrvector.h"
8 #include "hasname.h"
9 #include "livesonareas.h"
10 #include "suits.h"
11 #include "keeper.h"
12 #include "prey.h"
13 
16 
25 class Predator : public HasName, public LivesOnAreas {
26 public:
32  Predator(const char* givenname, const IntVector& Areas);
36  virtual ~Predator();
44  virtual void Eat(int area, const AreaClass* const Area, const TimeClass* const TimeInfo) = 0;
50  void setPrey(PreyPtrVector& preyvec, Keeper* const keeper);
56  int doesEat(const char* preyname) const;
63  virtual void adjustConsumption(int area, const TimeClass* const TimeInfo) = 0;
68  virtual void Print(ofstream& outfile) const;
73  virtual void Reset(const TimeClass* const TimeInfo) { suitable->Reset(this, TimeInfo); };
80  virtual const DoubleMatrix& getConsumption(int area, const char* preyname) const = 0;
86  virtual int hasOverConsumption(int area) const = 0;
92  virtual const DoubleVector& getOverConsumption(int area) const = 0;
98  virtual double getTotalOverConsumption(int area) const = 0;
105  virtual double getConsumptionBiomass(int prey, int area) const = 0;
113  virtual double getConsumptionRatio(int area, int prey, int len) const = 0;
120  virtual const PopInfoVector& getConsumptionPopInfo(int area, const char* preyname) const = 0;
125  virtual const LengthGroupDivision* getLengthGroupDiv() const = 0;
129  virtual void setTimeMultiplier(const TimeClass* const TimeInfo, int quotastep,double value){};
137  virtual void Initialise() { suitable->Initialise(this); };
138 
139  int numPreys() const { return preys.Size(); };
145  Prey* getPrey(int i) const { return preys[i]; };
151  const char* getPreyName(int i) const { return suitable->getPreyName(i); };
158  int didChange(int i, const TimeClass* const TimeInfo) { return suitable->didChange(i, TimeInfo); };
164  const DoubleMatrix& getSuitability(int i) const { return suitable->getSuitability(i); };
170  double getPreference(int i) const { return preference[i]; };
175  PredatorType getType() const { return type; };
176 protected:
183  void readSuitability(CommentStream& infile, const TimeClass* const TimeInfo, Keeper* const keeper);
192 private:
196  PreyPtrVector preys;
200  Suits* suitable;
201 };
202 
203 #endif
This is the class used to store information about the areas used for the current model.
Definition: areatime.h:18
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 Formula values.
Definition: formulavector.h:10
This is the base class for any object that has a name.
Definition: hasname.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
This is the class used to store information about the length groups of the modelled stock population.
Definition: lengthgroup.h:10
This is the class used to store information about the areas an object is defined on for the current m...
Definition: livesonareas.h:10
This class implements a dynamic vector of PopInfo values.
Definition: popinfovector.h:11
This is the base class used to model the consumption by a predator.
Definition: predator.h:25
virtual const PopInfoVector & getConsumptionPopInfo(int area, const char *preyname) const =0
This will return the amount of a given prey on a given area prior to any consumption by the predator.
PredatorType getType() const
This will return the type of predator class.
Definition: predator.h:175
double getPreference(int i) const
This will return the preference for a given prey.
Definition: predator.h:170
Predator(const char *givenname, const IntVector &Areas)
This is the Predator constructor.
Definition: predator.cc:10
virtual void Reset(const TimeClass *const TimeInfo)
This will reset the predation information for the current model run.
Definition: predator.h:73
int didChange(int i, const TimeClass *const TimeInfo)
This function will check to see if the suitability parameters for a given prey have changed on the cu...
Definition: predator.h:158
virtual double getConsumptionRatio(int area, int prey, int len) const =0
This will return the ratio used to split the predation between the areas and length groups.
int doesEat(const char *preyname) const
This function will check to see if the predator will consume a specified prey.
Definition: predator.cc:63
virtual void setTimeMultiplier(const TimeClass *const TimeInfo, int quotastep, double value)
This is a multiplier set in lengthpredator.
Definition: predator.h:129
virtual double getTotalOverConsumption(int area) const =0
This will return the total amount the predator overconsumes on a given area.
virtual const DoubleMatrix & getConsumption(int area, const char *preyname) const =0
This will return the amount the predator consumes of a given prey on a given area.
virtual void Eat(int area, const AreaClass *const Area, const TimeClass *const TimeInfo)=0
This will calculate the amount the predator consumes on a given area.
void readSuitability(CommentStream &infile, const TimeClass *const TimeInfo, Keeper *const keeper)
This function will read the suitability data from the input file.
Definition: predator.cc:88
PredatorType type
This denotes what type of predator class has been created.
Definition: predator.h:191
virtual const LengthGroupDivision * getLengthGroupDiv() const =0
This will return the length group information for the predator.
FormulaVector preference
This is the FormulaVector used to store the prey preference parameters.
Definition: predator.h:187
void setPrey(PreyPtrVector &preyvec, Keeper *const keeper)
This will select the preys that will be consumed by the predator.
Definition: predator.cc:19
virtual const DoubleVector & getOverConsumption(int area) const =0
This will return the amount the predator overconsumes on a given area.
virtual ~Predator()
This is the default Predator destructor.
Definition: predator.cc:14
virtual int hasOverConsumption(int area) const =0
This will return the flag that denotes if the predator has overconsumed on a given area.
virtual void adjustConsumption(int area, const TimeClass *const TimeInfo)=0
This will adjust the amount the predator consumes on a given area to take any overconsumption into ac...
int numPreys() const
Definition: predator.h:139
virtual double getConsumptionBiomass(int prey, int area) const =0
This will return the biomass the predator consumes of a given prey on a given area.
Prey * getPrey(int i) const
This will return a given prey.
Definition: predator.h:145
virtual void Initialise()
This will return the number of prey stocks that the predator will consume.
Definition: predator.h:137
virtual void Print(ofstream &outfile) const
This function will print the predation data.
Definition: predator.cc:71
const DoubleMatrix & getSuitability(int i) const
This will return the suitability values for a given prey.
Definition: predator.h:164
const char * getPreyName(int i) const
This will return the name of a given prey.
Definition: predator.h:151
This class implements a dynamic vector of Prey values.
Definition: preyptrvector.h:10
int Size() const
This will return the size of the vector.
Definition: preyptrvector.h:46
This is the base class used to model the consumption of a prey.
Definition: prey.h:27
This is the class used to calculate and store the suitability values for all the preys of a single pr...
Definition: suits.h:15
void Reset(const Predator *const pred, const TimeClass *const TimeInfo)
This function will reset the suitability information for a given predator.
Definition: suits.cc:37
const DoubleMatrix & getSuitability(int i) const
This function will return the calculated suitability values for a given prey.
Definition: suits.h:65
int didChange(int i, const TimeClass *const TimeInfo)
This function will check to see if the suitability parameters for a given prey have changed on the cu...
Definition: suits.h:59
void Initialise(const Predator *const pred)
This will initialise the preys that will be consumed by the predator.
Definition: suits.cc:31
const char * getPreyName(int i) const
This function will return the name of a given prey.
Definition: suits.h:42
This is the class used to store information about the timesteps used for the current model.
Definition: areatime.h:87
PredatorType
Definition: predator.h:14
@ NUMBERPREDATOR
Definition: predator.h:14
@ STOCKPREDATOR
Definition: predator.h:14
@ QUOTAPREDATOR
Definition: predator.h:15
@ TOTALPREDATOR
Definition: predator.h:14
@ EFFORTPREDATOR
Definition: predator.h:15
@ LINEARPREDATOR
Definition: predator.h:14