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/prey.h
[mareframe] / trunk / gadget / prey.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/prey.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef prey_h
2 :     #define prey_h
3 :    
4 :     #include "popinfovector.h"
5 :     #include "conversionindex.h"
6 :     #include "commentstream.h"
7 :     #include "charptrvector.h"
8 :     #include "hasname.h"
9 :     #include "livesonareas.h"
10 :     #include "doublematrix.h"
11 :     #include "areatime.h"
12 :     #include "agebandmatrix.h"
13 :     #include "keeper.h"
14 :     #include "gadget.h"
15 :     #include "modelvariable.h"
16 :    
17 :     enum PreyType { STOCKPREY = 1, LENGTHPREY };
18 :    
19 :     /**
20 :     * \class Prey
21 :     * \brief This is the base class used to model the consumption of a prey
22 :     *
23 :     * This class is used to remove fish from the model due to predation, either by a fleet or through consumption by another stock. The proportion of the fish that are to be removed is calculated, based on the required consumption by all the various predators that will consume the prey. This ''target consumption'' is then checked to ensure that no more than 95% of the prey species is to be consumed, 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 various predators consume.
24 :     *
25 :     * \note This will be overridden by the derived classes that actually calculate the consumption
26 :     */
27 :     class Prey : public HasName, public LivesOnAreas {
28 :     public:
29 :     /**
30 :     * \brief This is the Prey constructor to create a prey by reading data from a file
31 :     * \param infile is the CommentStream to read the Prey data from
32 :     * \param areas is the IntVector of areas that the prey lives on
33 :     * \param givenname is the name of the prey
34 :     * \param TimeInfo is the TimeClass for the current model
35 :     * \param keeper is the Keeper for the current model
36 :     * \note This constructor is used when creating dynamic prey (ie. StockPrey class)
37 :     */
38 :     Prey(CommentStream& infile, const IntVector& areas, const char* givenname,
39 :     const TimeClass* const TimeInfo, Keeper* const keeper);
40 :     /**
41 :     * \brief This is the Prey constructor for a prey with a given length group
42 :     * \param infile is the CommentStream to read the Prey data from
43 :     * \param givenname is the name of the prey
44 :     * \param areas is the IntVector of areas that the prey lives on
45 :     * \param TimeInfo is the TimeClass for the current model
46 :     * \param keeper is the Keeper for the current model
47 :     * \note This constructor is used when creating non-dynamic prey (ie. OtherFood class)
48 :     */
49 :     Prey(CommentStream& infile, const char* givenname, const IntVector& areas,
50 :     const TimeClass* const TimeInfo, Keeper* const keeper);
51 :     /**
52 :     * \brief This is the default Prey destructor
53 :     */
54 :     virtual ~Prey() = 0;
55 :     /**
56 :     * \brief This will calculate the amount of prey that is consumed for a given area and timestep
57 :     * \param Alkeys is the AgeBandMatrix giving the amount of prey in the area
58 :     * \param area is the area that the prey consumption is being calculated on
59 :     * \note This will be overridden by the derived classes that actually calculate the consumption
60 :     */
61 :     virtual void Sum(const AgeBandMatrix& Alkeys, int area) {};
62 :     /**
63 :     * \brief This will calculate the amount of prey that is consumed for a given area and timestep
64 :     * \param NumberInArea is the PopInfoVector giving the amount of prey in the area
65 :     * \param area is the area that the prey consumption is being calculated on
66 :     * \note This will be overridden by the derived classes that actually calculate the consumption
67 :     */
68 :     virtual void Sum(const PopInfoVector& NumberInArea, int area) {};
69 :     /**
70 :     * \brief This will reset the consumption 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);
74 :     /**
75 :     * \brief This function will print the consumption data
76 :     * \param outfile is the ofstream that all the model information gets sent to
77 :     */
78 :     virtual void Print(ofstream& outfile) const;
79 :     /**
80 :     * \brief This will set the ConversionIndex required for to calculate the consumption
81 :     * \param GivenLDiv is the LengthGroupDivision for the stock
82 :     */
83 :     virtual void setCI(const LengthGroupDivision* const GivenLDiv);
84 :     /**
85 :     * \brief This function will subtract the prey that is consumed from the stock
86 :     * \param Alkeys is the AgeBandMatrix containing the population of the stock
87 :     * \param area is the area that the consumption is being calculated on
88 :     */
89 :     virtual void Subtract(AgeBandMatrix& Alkeys, int area);
90 :     /**
91 :     * \brief This function will add predation (by biomass) to the amount of the prey that is consumed
92 :     * \param area is the area that the consumption is being calculated on
93 :     * \param predcons is the DoubleVector containing the predation data
94 :     */
95 :     void addBiomassConsumption(int area, const DoubleVector& predcons);
96 :     /**
97 :     * \brief This function will add predation (by numbers) to the amount of the prey that is consumed
98 :     * \param area is the area that the consumption is being calculated on
99 :     * \param predcons is the DoubleVector containing the predation data
100 :     */
101 :     void addNumbersConsumption(int area, const DoubleVector& predcons);
102 :     /**
103 :     * \brief This function will check for overconsumption of the prey
104 :     * \param area is the area that the consumption is being calculated on
105 :     * \param TimeInfo is the TimeClass for the current model
106 :     */
107 :     virtual void checkConsumption(int area, const TimeClass* const TimeInfo);
108 :     /**
109 :     * \brief This will return the biomass of prey that is available for consumption by predators
110 :     * \param area is the area that the consumption is being calculated on
111 :     * \param length is the length group of the prey
112 :     * \return biomass
113 :     */
114 :     double getBiomass(int area, int length) const { return biomass[this->areaNum(area)][length]; };
115 :     /**
116 :     * \brief This will return the number of prey that is available for consumption by predators
117 :     * \param area is the area that the consumption is being calculated on
118 :     * \param length is the length group of the prey
119 :     * \return number
120 :     */
121 :     double getNumber(int area, int length) const { return preynumber[this->areaNum(area)][length].N; };
122 :     /**
123 :     * \brief This will return the total biomass of prey that is available for consumption
124 :     * \param area is the area that the consumption is being calculated on
125 :     * \return total biomass
126 :     */
127 :     double getTotalBiomass(int area) const { return total[this->areaNum(area)]; };
128 :     /**
129 :     * \brief This will return the flag that denotes if the prey has been overconsumed on a given area
130 :     * \param area is the area that the consumption is being calculated on
131 :     * \return 1 if the prey has been overconsumed, 0 otherwise
132 :     */
133 :     int isOverConsumption(int area);
134 :     /**
135 :     * \brief This will return the ratio of the prey that has been consumed on a given area
136 :     * \param area is the area that the consumption is being calculated on
137 :     * \return ratio, a DoubleVector containing the ratio of the prey that is consumed
138 :     */
139 :     const DoubleVector& getRatio(int area) const { return ratio[this->areaNum(area)]; };
140 :     /**
141 :     * \brief This will return the ratio of the prey that has been consumed on a given area
142 :     * \param area is the area that the consumption is being calculated on
143 :     * \return ratio, a DoubleVector containing the ratio of the prey that is consumed
144 :     */
145 :     const DoubleVector& getUseRatio(int area) const { return useratio[this->areaNum(area)]; };
146 :     /**
147 :     * \brief This will return the amount of the prey that has been consumed on a given area
148 :     * \param area is the area that the consumption is being calculated on
149 :     * \return consumption, a DoubleVector containing the consumption of the prey
150 :     */
151 :     const DoubleVector& getConsumption(int area) const { return consumption[this->areaNum(area)]; };
152 :     /**
153 :     * \brief This will return the amount of the prey that has been overconsumed on a given area
154 :     * \param area is the area that the consumption is being calculated on
155 :     * \return overconsumption, a DoubleVector containing the overconsumption of the prey
156 :     */
157 :     const DoubleVector& getOverConsumption(int area) const { return overconsumption[this->areaNum(area)]; };
158 :     /**
159 :     * \brief This will return the total amount of the prey that has been overconsumed on a given area
160 :     * \param area is the area that the consumption is being calculated on
161 :     * \return total overconsumption of the prey
162 :     */
163 :     double getTotalOverConsumption(int area) const;
164 :     /**
165 :     * \brief This will return the length group information for the prey
166 :     * \return LgrpDiv
167 :     */
168 :     const LengthGroupDivision* getLengthGroupDiv() const { return LgrpDiv; };
169 :     /**
170 :     * \brief This will return the amount of prey on a given area prior to any consumption by the predators
171 :     * \param area is the area that the consumption is being calculated on
172 :     * \return preynumber, a PopInfoVector containing information about the prey population
173 :     */
174 :     const PopInfoVector& getConsumptionPopInfo(int area) const { return preynumber[this->areaNum(area)]; };
175 :     /**
176 :     * \brief This will return the energy content of the prey
177 :     * \return energy
178 :     */
179 :     double getEnergy() const { return energy; };
180 :     /**
181 :     * \brief This will check if there is any prey to consume on a given area
182 :     * \param area is the area that the prey will be consumed on
183 :     * \return 1 if there is prey to consume, 0 otherwise
184 :     */
185 :     int isPreyArea(int area);
186 :     /**
187 :     * \brief This will return the type of prey class
188 :     * \return type
189 :     */
190 :     PreyType getType() const { return type; };
191 :     protected:
192 :     /**
193 :     * \brief This is the ConversionIndex used to convert from the stock LengthGroupDivision to the LengthGroupDivision used for the consumption calculation
194 :     */
195 :     ConversionIndex* CI;
196 :     /**
197 :     * \brief This is the LengthGroupDivision used to store length information
198 :     */
199 :     LengthGroupDivision* LgrpDiv;
200 :     /**
201 :     * \brief This is the PopInfoMatrix used to store information on the number of preys for the current timestep
202 :     * \note The indices for this object are [area][prey length]
203 :     */
204 :     PopInfoMatrix preynumber;
205 :     /**
206 :     * \brief This is the ModelVariable used to store the energy content of the prey (in kilojoules per kilogramme)
207 :     */
208 :     ModelVariable energy;
209 :     /**
210 :     * \brief This is the DoubleMatrix used to store information on the biomass of the prey that is available for the predators to consume on the current timestep
211 :     * \note The indices for this object are [area][prey length]
212 :     */
213 :     DoubleMatrix biomass;
214 :     /**
215 :     * \brief This is the DoubleVector used to store information on the total biomass of the prey that is available for the predators to consume on the current timestep
216 :     */
217 :     DoubleVector total;
218 :     /**
219 :     * \brief This is the DoubleMatrix used to store information on the ratio of the available biomass of the prey that is available for the predators to consume has been consumed on the current timestep
220 :     * \note The indices for this object are [area][prey length]
221 :     */
222 :     DoubleMatrix ratio;
223 :     /**
224 :     * \brief This is the DoubleMatrix used to store information on the ratio of the available biomass of the prey that is available for the predators to consume has been consumed on the current timestep, adjusted to MaxRatio whenever overconsumption has occured
225 :     * \note The indices for this object are [area][prey length]
226 :     */
227 :     DoubleMatrix useratio;
228 :     /**
229 :     * \brief This is the DoubleMatrix used to store information on the consumption of the prey on the current timestep
230 :     * \note The indices for this object are [area][prey length]
231 :     */
232 :     DoubleMatrix consumption;
233 :     /**
234 :     * \brief This is the DoubleMatrix used to store information on the consumption of the prey on the current substep of the current timestep
235 :     * \note The indices for this object are [area][prey length]
236 :     */
237 :     DoubleMatrix cons;
238 :     /**
239 :     * \brief This is the DoubleMatrix used to store information on the overconsumption of the prey on the current timestep
240 :     * \note The indices for this object are [area][prey length]
241 :     */
242 :     DoubleMatrix overconsumption;
243 :     /**
244 :     * \brief This is the IntVector used to store information on whether any overconsumption has occured on the current timestep
245 :     */
246 :     IntVector isoverconsumption;
247 :     /**
248 :     * \brief This is the DoubleMatrix used to store information on the ratio of the prey to subtract on the current timestep
249 :     * \note The indices for this object are [area][prey length]
250 :     */
251 :     DoubleMatrix consratio;
252 :     /**
253 :     * \brief This denotes what type of prey class has been created
254 :     */
255 :     PreyType type;
256 :     };
257 :    
258 :     #endif

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

Powered By FusionForge