Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/predator.h
[mareframe] / trunk / gadget / predator.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/predator.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 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 :    
14 :     enum PredatorType { STOCKPREDATOR = 1, TOTALPREDATOR, LINEARPREDATOR, NUMBERPREDATOR,
15 :     EFFORTPREDATOR, QUOTAPREDATOR };
16 :    
17 :     /**
18 :     * \class Predator
19 :     * \brief This is the base class used to model the consumption by a predator
20 :     *
21 :     * This class is used to calculate the predation of prey species by a predator, either by a fleet or by a modelled stock in the simulation. The amount of the various prey species that the predator wants to consume is calculated, based on the suitability functions defined for each prey. This ''target consumption'' is then checked to ensure that no more than 95% of each the prey species is to be consumed (by all the predators of that prey), and the consumption is adjusted if this is the case. The population of the prey species is then reduced by the total amount that the predators consume.
22 :     *
23 :     * \note This will be overridden by the derived classes that actually calculate the consumption
24 :     */
25 :     class Predator : public HasName, public LivesOnAreas {
26 :     public:
27 :     /**
28 :     * \brief This is the Predator constructor
29 :     * \param givenname is the name of the predator
30 :     * \param Areas is the IntVector of areas that the predator lives on
31 :     */
32 :     Predator(const char* givenname, const IntVector& Areas);
33 :     /**
34 :     * \brief This is the default Predator destructor
35 :     */
36 :     virtual ~Predator();
37 :     /**
38 :     * \brief This will calculate the amount the predator consumes on a given area
39 :     * \param area is the area that the prey consumption is being calculated on
40 :     * \param Area is the AreaClass for the current model
41 :     * \param TimeInfo is the TimeClass for the current model
42 :     * \note This will be overridden by the derived classes that actually calculate the consumption
43 :     */
44 :     virtual void Eat(int area, const AreaClass* const Area, const TimeClass* const TimeInfo) = 0;
45 :     /**
46 :     * \brief This will select the preys that will be consumed by the predator
47 :     * \param preyvec is the PreyPtrVector of all the available preys
48 :     * \param keeper is the Keeper for the current model
49 :     */
50 :     void setPrey(PreyPtrVector& preyvec, Keeper* const keeper);
51 :     /**
52 :     * \brief This function will check to see if the predator will consume a specified prey
53 :     * \param preyname is the name of the prey
54 :     * \return 1 if the predator does consume the prey, 0 otherwise
55 :     */
56 :     int doesEat(const char* preyname) const;
57 :     /**
58 :     * \brief This will adjust the amount the predator consumes on a given area to take any overconsumption into account
59 :     * \param area is the area that the prey consumption is being calculated on
60 :     * \param TimeInfo is the TimeClass for the current model
61 :     * \note This will be overridden by the derived classes that actually calculate the consumption
62 :     */
63 :     virtual void adjustConsumption(int area, const TimeClass* const TimeInfo) = 0;
64 :     /**
65 :     * \brief This function will print the predation data
66 :     * \param outfile is the ofstream that all the model information gets sent to
67 :     */
68 :     virtual void Print(ofstream& outfile) const;
69 :     /**
70 :     * \brief This will reset the predation information for the current model run
71 :     * \param TimeInfo is the TimeClass for the current model
72 :     */
73 :     virtual void Reset(const TimeClass* const TimeInfo) { suitable->Reset(this, TimeInfo); };
74 :     /**
75 :     * \brief This will return the amount the predator consumes of a given prey on a given area
76 :     * \param area is the area that the consumption is being calculated on
77 :     * \param preyname is the name of the prey that is being consumed
78 :     * \return 0 (will be overridden by the derived classes)
79 :     */
80 :     virtual const DoubleMatrix& getConsumption(int area, const char* preyname) const = 0;
81 :     /**
82 :     * \brief This will return the flag that denotes if the predator has overconsumed on a given area
83 :     * \param area is the area that the consumption is being calculated on
84 :     * \return 0 (will be overridden by the derived classes)
85 :     */
86 :     virtual int hasOverConsumption(int area) const = 0;
87 :     /**
88 :     * \brief This will return the amount the predator overconsumes on a given area
89 :     * \param area is the area that the consumption is being calculated on
90 :     * \return 0 (will be overridden by the derived classes)
91 :     */
92 :     virtual const DoubleVector& getOverConsumption(int area) const = 0;
93 :     /**
94 :     * \brief This will return the total amount the predator overconsumes on a given area
95 :     * \param area is the area that the consumption is being calculated on
96 :     * \return 0 (will be overridden by the derived classes)
97 :     */
98 :     virtual double getTotalOverConsumption(int area) const = 0;
99 :     /**
100 :     * \brief This will return the biomass the predator consumes of a given prey on a given area
101 :     * \param prey is the index for the prey
102 :     * \param area is the area that the consumption is being calculated on
103 :     * \return 0 (will be overridden by the derived classes)
104 :     */
105 :     virtual double getConsumptionBiomass(int prey, int area) const = 0;
106 :     /**
107 :     * \brief This will return the ratio used to split the predation between the areas and length groups
108 :     * \param area is the area that the consumption is being calculated on
109 :     * \param prey is the index for the prey
110 :     * \param len is the length group of the predator
111 :     * \return 0 (will be overridden by the derived classes)
112 :     */
113 :     virtual double getConsumptionRatio(int area, int prey, int len) const = 0;
114 :     /**
115 :     * \brief This will return the amount of a given prey on a given area prior to any consumption by the predator
116 :     * \param area is the area that the consumption is being calculated on
117 :     * \param preyname is the name of the prey that is being consumed
118 :     * \return 0 (will be overridden by the derived classes)
119 :     */
120 :     virtual const PopInfoVector& getConsumptionPopInfo(int area, const char* preyname) const = 0;
121 :     /**
122 :     * \brief This will return the length group information for the predator
123 :     * \return 0 (will be overridden by the derived classes)
124 :     */
125 :     virtual const LengthGroupDivision* getLengthGroupDiv() const = 0;
126 :     /**
127 :     * \brief This will initialise the preys that will be consumed by the predator
128 :     */
129 :     virtual void Initialise() { suitable->Initialise(this); };
130 :     /**
131 :     * \brief This will return the number of prey stocks that the predator will consume
132 :     * \return number of preys
133 :     */
134 :     int numPreys() const { return preys.Size(); };
135 :     /**
136 :     * \brief This will return a given prey
137 :     * \param i is the index of the prey
138 :     * \return prey
139 :     */
140 :     Prey* getPrey(int i) const { return preys[i]; };
141 :     /**
142 :     * \brief This will return the name of a given prey
143 :     * \param i is the index of the prey
144 :     * \return name of the prey
145 :     */
146 :     const char* getPreyName(int i) const { return suitable->getPreyName(i); };
147 :     /**
148 :     * \brief This function will check to see if the suitability parameters for a given prey have changed on the current timestep
149 :     * \param i is the index of the prey
150 :     * \param TimeInfo is the TimeClass for the current model
151 :     * \return 1 if the values have changed, 0 otherwise
152 :     */
153 :     int didChange(int i, const TimeClass* const TimeInfo) { return suitable->didChange(i, TimeInfo); };
154 :     /**
155 :     * \brief This will return the suitability values for a given prey
156 :     * \param i is the index of the prey
157 :     * \return suitability matrix for the prey
158 :     */
159 :     const DoubleMatrix& getSuitability(int i) const { return suitable->getSuitability(i); };
160 :     /**
161 :     * \brief This will return the preference for a given prey
162 :     * \param i is the index of the prey
163 :     * \return preference
164 :     */
165 :     double getPreference(int i) const { return preference[i]; };
166 :     /**
167 :     * \brief This will return the type of predator class
168 :     * \return type
169 :     */
170 :     PredatorType getType() const { return type; };
171 :     protected:
172 :     /**
173 :     * \brief This function will read the suitability data from the input file
174 :     * \param infile is the CommentStream to read the suitabiltiy data from
175 :     * \param TimeInfo is the TimeClass for the current model
176 :     * \param keeper is the Keeper for the current model
177 :     */
178 :     void readSuitability(CommentStream& infile, const TimeClass* const TimeInfo, Keeper* const keeper);
179 :     /**
180 :     * \brief This is the FormulaVector used to store the prey preference parameters
181 :     */
182 :     FormulaVector preference;
183 :     /**
184 :     * \brief This denotes what type of predator class has been created
185 :     */
186 :     PredatorType type;
187 :     private:
188 :     /**
189 :     * \brief This is the PreyPtrVector of the preys that will be consumed by the predator
190 :     */
191 :     PreyPtrVector preys;
192 :     /**
193 :     * \brief This is the Suits of the suitability values for the preys that will be consumed by the predator
194 :     */
195 :     Suits* suitable;
196 :     };
197 :    
198 :     #endif

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge