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

Annotation of /trunk/gadget/maturity.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef maturity_h
2 :     #define maturity_h
3 :    
4 :     #include "keeper.h"
5 :     #include "agebandmatrix.h"
6 :     #include "livesonareas.h"
7 :     #include "conversionindexptrvector.h"
8 :     #include "charptrvector.h"
9 :     #include "commentstream.h"
10 :     #include "agebandmatrixptrvector.h"
11 :     #include "agebandmatrixratioptrvector.h"
12 :     #include "modelvariablevector.h"
13 :    
14 :     /**
15 :     * \class Maturity
16 :     * \brief This is the base class used to calculate the maturity of a stock within the model
17 :     *
18 :     * This class moves fish from an immature stock to matures stocks within the model. The proportion of those fish in the immature stock that mature is calulated according to the different maturity functions of the derived classes, and then that propotion is moved into the mature stocks. The length and age groups of the mature stocks are checked, and any fish that haven't yet reached the minimum length or age of the mature stock remain in the immature stock.
19 :     *
20 :     * \note This will always be overridden by the derived classes that actually calculate the maturity
21 :     */
22 :     class Maturity: public HasName, protected LivesOnAreas {
23 :     public:
24 :     /**
25 :     * \brief This is the default Maturity constructor
26 :     */
27 :     Maturity();
28 :     /**
29 :     * \brief This is the Maturity constructor
30 :     * \param areas is the IntVector of areas that the maturity calculation can take place on
31 :     * \param minage is the minimum age of the stock that can mature
32 :     * \param numage is the number of age groups for the stock that can mature
33 :     * \param LgrpDiv is the LengthGroupDivision for the stock
34 :     * \param givenname is the name of the stock for this Maturity class
35 :     */
36 :     Maturity(const IntVector& areas, int minage, int numage,
37 :     const LengthGroupDivision* const LgrpDiv, const char* givenname);
38 :     /**
39 :     * \brief This is the default Maturity destructor
40 :     */
41 :     virtual ~Maturity();
42 :     /**
43 :     * \brief This will select the stocks required for the maturation process
44 :     * \param stockvec is the StockPtrVector of all the available stocks
45 :     */
46 :     virtual void setStock(StockPtrVector& stockvec);
47 :     /**
48 :     * \brief This function will print the maturation information
49 :     * \param outfile is the ofstream that all the model information gets sent to
50 :     */
51 :     virtual void Print(ofstream& outfile) const;
52 :     /**
53 :     * \brief This will reset the maturation information for the current model run
54 :     * \param TimeInfo is the TimeClass for the current model
55 :     */
56 :     virtual void Reset(const TimeClass* const TimeInfo);
57 :     /**
58 :     * \brief This will check if the maturation process will take place on the current timestep
59 :     * \param TimeInfo is the TimeClass for the current model
60 :     * \return 0 (will be overridden in derived classes)
61 :     */
62 :     virtual int isMaturationStep(const TimeClass* const TimeInfo) = 0;
63 :     /**
64 :     * \brief This will calculate the probability of maturation for a given age and length of the immature stock
65 :     * \param age is the age of the age-length cell that the maturation is being calculated on
66 :     * \param length is the length of the age-length cell that the maturation is being calculated on
67 :     * \param growth is the length of the age-length cell that the mature stock will grow into
68 :     * \param weight is the weight of the fish of the age-length cell that are maturing
69 :     * \return 0 (will be overridden in derived classes)
70 :     */
71 :     virtual double calcMaturation(int age, int length, int growth, double weight) = 0;
72 :     /**
73 :     * \brief This will store the calculated mature stock
74 :     * \param area is the area that the maturation is being calculated on
75 :     * \param age is the age of the calculated mature stock
76 :     * \param length is the length of the calculated mature stock
77 :     * \param number is the number of the calculated mature stock
78 :     * \param weight is the weight of the calculated mature stock
79 :     */
80 :     void storeMatureStock(int area, int age, int length, double number, double weight);
81 :     /**
82 :     * \brief This will store the calculated mature tagged stock
83 :     * \param area is the area that the maturation is being calculated on
84 :     * \param age is the age of the calculated mature stock
85 :     * \param length is the length of the calculated mature stock
86 :     * \param number is the number of the calculated mature stock
87 :     * \param id is the tagging identifier of the mature stock
88 :     */
89 :     void storeMatureTagStock(int area, int age, int length, double number, int id);
90 :     /**
91 :     * \brief This will move the calculated mature stock into the mature stock age-length cells
92 :     * \param area is the area that the maturation is being calculated on
93 :     * \param TimeInfo is the TimeClass for the current model
94 :     */
95 :     void Move(int area, const TimeClass* const TimeInfo);
96 :     /**
97 :     * \brief This will calculate the mature stocks the immature stock can mature into
98 :     * \return mature stocks
99 :     */
100 :     const StockPtrVector& getMatureStocks();
101 :     /**
102 :     * \brief This function will initialise the tagging experiments for the maturation calculations
103 :     */
104 :     void setTagged();
105 :     /**
106 :     * \brief This will add a tagging experiment to the maturation calculations
107 :     * \param tagname is the name of the tagging experiment
108 :     */
109 :     void addMaturityTag(const char* tagname);
110 :     /**
111 :     * \brief This will remove a tagging experiment from the maturation calculations
112 :     * \param tagname is the name of the tagging experiment
113 :     */
114 :     void deleteMaturityTag(const char* tagname);
115 :     protected:
116 :     /**
117 :     * \brief This is used to temporarily store the maturation ratio
118 :     */
119 :     double tmpratio;
120 :     /**
121 :     * \brief This is the StockPtrVector of the mature stocks
122 :     */
123 :     StockPtrVector matureStocks;
124 :     /**
125 :     * \brief This is the CharPtrVector of the names of the mature stocks
126 :     */
127 :     CharPtrVector matureStockNames;
128 :     /**
129 :     * \brief This is the FormulaVector of the ratio of the immature stock to mature into each mature stock
130 :     */
131 :     FormulaVector matureRatio;
132 :     /**
133 :     * \brief This is used to scale the ratios to ensure that they will always sum to 1
134 :     */
135 :     double ratioscale;
136 :     /**
137 :     * \brief This is the IntVector used as an index for the ratio vector
138 :     */
139 :     IntVector ratioindex;
140 :     /**
141 :     * \brief This is the ConversionIndexPtrVector used to convert from the immature stock lengths to the mature stock lengths
142 :     */
143 :     ConversionIndexPtrVector CI;
144 :     /**
145 :     * \brief This is the LengthGroupDivision of the stock
146 :     */
147 :     LengthGroupDivision* LgrpDiv;
148 :     private:
149 :     /**
150 :     * \brief This is the AgeBandMatrixPtrVector used to store the calculated mature stocks
151 :     */
152 :     AgeBandMatrixPtrVector Storage;
153 :     /**
154 :     * \brief This is the AgeBandMatrixRatioPtrVector used to store the calculated mature tagged stocks
155 :     */
156 :     AgeBandMatrixRatioPtrVector tagStorage;
157 :     /**
158 :     * \brief This is the flag used to denote whether the stock has been included in a tagging experiment or not
159 :     */
160 :     int istagged;
161 :     };
162 :    
163 :     /**
164 :     * \class MaturityA
165 :     * \brief This is the class used to calculate the maturity based on the 'continuous' maturity function
166 :     */
167 :     class MaturityA : public Maturity {
168 :     public:
169 :     /**
170 :     * \brief This is the MaturityA constructor
171 :     * \param infile is the CommentStream to read the maturation parameters from
172 :     * \param TimeInfo is the TimeClass for the current model
173 :     * \param keeper is the Keeper for the current model
174 :     * \param minage is the minimum age of the stock that can mature
175 :     * \param numage is the number of age groups for the stock that can mature
176 :     * \param areas is the IntVector of areas that the maturity calculation can take place on
177 :     * \param givenname is the name of the stock for this MaturityA class
178 :     * \param LgrpDiv is the LengthGroupDivision for the stock
179 :     */
180 :     MaturityA(CommentStream& infile, const TimeClass* const TimeInfo,
181 :     Keeper* const keeper, int minage, int numage, const IntVector& areas,
182 :     const char* givenname, const LengthGroupDivision* const LgrpDiv);
183 :     /**
184 :     * \brief This is the default MaturityA destructor
185 :     */
186 :     virtual ~MaturityA() {};
187 :     /**
188 :     * \brief This will select the stocks required for the maturation process
189 :     * \param stockvec is the StockPtrVector of all the available stocks
190 :     */
191 :     virtual void setStock(StockPtrVector& stockvec);
192 :     /**
193 :     * \brief This will reset the maturation information for the current model run
194 :     * \param TimeInfo is the TimeClass for the current model
195 :     */
196 :     virtual void Reset(const TimeClass* const TimeInfo);
197 :     /**
198 :     * \brief This will check if the maturation process will take place on the current timestep
199 :     * \param TimeInfo is the TimeClass for the current model
200 :     * \return 1 if the maturation process will take place, 0 otherwise
201 :     */
202 :     virtual int isMaturationStep(const TimeClass* const TimeInfo);
203 :     /**
204 :     * \brief This will calculate the probability of maturation for a given age and length of the immature stock
205 :     * \param age is the age of the age-length cell that the maturation is being calculated on
206 :     * \param length is the length of the age-length cell that the maturation is being calculated on
207 :     * \param growth is the length of the age-length cell that the mature stock will grow into
208 :     * \param weight is the weight of the fish of the age-length cell that are maturing
209 :     * \return maturation probability
210 :     */
211 :     virtual double calcMaturation(int age, int length, int growth, double weight);
212 :     /**
213 :     * \brief This function will print the maturation information
214 :     * \param outfile is the ofstream that all the model information gets sent to
215 :     */
216 :     virtual void Print(ofstream& outfile) const;
217 :     protected:
218 :     /**
219 :     * \brief This is the DoubleMatrix of maturation parameters
220 :     */
221 :     DoubleMatrix preCalcMaturation;
222 :     /**
223 :     * \brief This is the ModelVariableVector of maturation parameters
224 :     */
225 :     ModelVariableVector maturityParameters;
226 :     /**
227 :     * \brief This is the minimum age of the maturing stock, used as an index for preCalcMaturation
228 :     */
229 :     int minStockAge;
230 :     /**
231 :     * \brief This is the minimum age when maturation will take place
232 :     */
233 :     int minMatureAge;
234 :     /**
235 :     * \brief This is the minimum length group division when maturation will take place
236 :     */
237 :     int minMatureLength;
238 :     /**
239 :     * \brief This is the length of the current timestep
240 :     */
241 :     double timesteplength;
242 :     };
243 :    
244 :     /**
245 :     * \class MaturityB
246 :     * \brief This is the class used to calculate the maturity based on the 'fixedlength' maturity function
247 :     */
248 :     class MaturityB : public Maturity {
249 :     public:
250 :     /**
251 :     * \brief This is the MaturityB constructor
252 :     * \param infile is the CommentStream to read the maturation parameters from
253 :     * \param TimeInfo is the TimeClass for the current model
254 :     * \param keeper is the Keeper for the current model
255 :     * \param minage is the minimum age of the stock that can mature
256 :     * \param numage is the number of age groups for the stock that can mature
257 :     * \param areas is the IntVector of areas that the maturity calculation can take place on
258 :     * \param givenname is the name of the stock for this MaturityB class
259 :     * \param LgrpDiv is the LengthGroupDivision for the stock
260 :     */
261 :     MaturityB(CommentStream& infile, const TimeClass* const TimeInfo,
262 :     Keeper* const keeper, int minage, int numage, const IntVector& areas,
263 :     const char* givenname, const LengthGroupDivision* const LgrpDiv);
264 :     /**
265 :     * \brief This is the default MaturityB destructor
266 :     */
267 :     virtual ~MaturityB() {};
268 :     /**
269 :     * \brief This will select the stocks required for the maturation process
270 :     * \param stockvec is the StockPtrVector of all the available stocks
271 :     */
272 :     virtual void setStock(StockPtrVector& stockvec);
273 :     /**
274 :     * \brief This will reset the maturation information for the current model run
275 :     * \param TimeInfo is the TimeClass for the current model
276 :     */
277 :     virtual void Reset(const TimeClass* const TimeInfo);
278 :     /**
279 :     * \brief This will check if the maturation process will take place on the current timestep
280 :     * \param TimeInfo is the TimeClass for the current model
281 :     * \return 1 if the maturation process will take place, 0 otherwise
282 :     */
283 :     virtual int isMaturationStep(const TimeClass* const TimeInfo);
284 :     /**
285 :     * \brief This will calculate the probability of maturation for a given age and length of the immature stock
286 :     * \param age is the age of the age-length cell that the maturation is being calculated on
287 :     * \param length is the length of the age-length cell that the maturation is being calculated on
288 :     * \param growth is the length of the age-length cell that the mature stock will grow into
289 :     * \param weight is the weight of the fish of the age-length cell that are maturing
290 :     * \return maturation probability
291 :     */
292 :     virtual double calcMaturation(int age, int length, int growth, double weight);
293 :     /**
294 :     * \brief This function will print the maturation information
295 :     * \param outfile is the ofstream that all the model information gets sent to
296 :     */
297 :     virtual void Print(ofstream& outfile) const;
298 :     protected:
299 :     /**
300 :     * \brief This is the current time step for the maturation process within the model simulation
301 :     */
302 :     int currentmaturitystep;
303 :     /**
304 :     * \brief This is the IntVector of timesteps when maturation will take place
305 :     */
306 :     IntVector maturitystep;
307 :     /**
308 :     * \brief This is the ModelVariableVector of lengths when maturation will take place
309 :     */
310 :     ModelVariableVector maturitylength;
311 :     };
312 :    
313 :     /**
314 :     * \class MaturityC
315 :     * \brief This is the class used to calculate the maturity based on the 'constant' maturity function
316 :     */
317 :     class MaturityC : public Maturity {
318 :     public:
319 :     /**
320 :     * \brief This is the MaturityC constructor
321 :     * \param infile is the CommentStream to read the maturation parameters from
322 :     * \param TimeInfo is the TimeClass for the current model
323 :     * \param keeper is the Keeper for the current model
324 :     * \param minage is the minimum age of the stock that can mature
325 :     * \param numage is the number of age groups for the stock that can mature
326 :     * \param areas is the IntVector of areas that the maturity calculation can take place on
327 :     * \param givenname is the name of the stock for this MaturityC class
328 :     * \param LgrpDiv is the LengthGroupDivision for the stock
329 :     * \param numMatConst is the number of maturation parameters (4)
330 :     */
331 :     MaturityC(CommentStream& infile, const TimeClass* const TimeInfo,
332 :     Keeper* const keeper, int minage, int numage, const IntVector& areas,
333 :     const char* givenname, const LengthGroupDivision* const LgrpDiv, int numMatConst);
334 :     /**
335 :     * \brief This is the default MaturityC destructor
336 :     */
337 :     virtual ~MaturityC() {};
338 :     /**
339 :     * \brief This will select the stocks required for the maturation process
340 :     * \param stockvec is the StockPtrVector of all the available stocks
341 :     */
342 :     virtual void setStock(StockPtrVector& stockvec);
343 :     /**
344 :     * \brief This will reset the maturation information for the current model run
345 :     * \param TimeInfo is the TimeClass for the current model
346 :     */
347 :     virtual void Reset(const TimeClass* const TimeInfo);
348 :     /**
349 :     * \brief This will check if the maturation process will take place on the current timestep
350 :     * \param TimeInfo is the TimeClass for the current model
351 :     * \return 1 if the maturation process will take place, 0 otherwise
352 :     */
353 :     virtual int isMaturationStep(const TimeClass* const TimeInfo);
354 :     /**
355 :     * \brief This will calculate the probability of maturation for a given age and length of the immature stock
356 :     * \param age is the age of the age-length cell that the maturation is being calculated on
357 :     * \param length is the length of the age-length cell that the maturation is being calculated on
358 :     * \param growth is the length of the age-length cell that the mature stock will grow into
359 :     * \param weight is the weight of the fish of the age-length cell that are maturing
360 :     * \return maturation probability
361 :     */
362 :     virtual double calcMaturation(int age, int length, int growth, double weight);
363 :     /**
364 :     * \brief This function will print the maturation information
365 :     * \param outfile is the ofstream that all the model information gets sent to
366 :     */
367 :     virtual void Print(ofstream& outfile) const;
368 :     protected:
369 :     /**
370 :     * \brief This is the DoubleMatrix of maturation parameters
371 :     */
372 :     DoubleMatrix preCalcMaturation;
373 :     /**
374 :     * \brief This is the ModelVariableVector of maturation parameters
375 :     */
376 :     ModelVariableVector maturityParameters;
377 :     /**
378 :     * \brief This is the minimum age of the maturing stock, used as an index for preCalcMaturation
379 :     */
380 :     int minStockAge;
381 :     /**
382 :     * \brief This is the minimum age when maturation will take place
383 :     */
384 :     int minMatureAge;
385 :     /**
386 :     * \brief This is the minimum length group division when maturation will take place
387 :     */
388 :     int minMatureLength;
389 :     /**
390 :     * \brief This is the IntVector of timesteps when maturation will take place
391 :     */
392 :     IntVector maturitystep;
393 :     };
394 :    
395 :     /**
396 :     * \class MaturityD
397 :     * \brief This is the class used to calculate the maturity based on the 'constantweight' maturity function
398 :     */
399 :     class MaturityD : public MaturityC {
400 :     public:
401 :     /**
402 :     * \brief This is the MaturityD constructor
403 :     * \param infile is the CommentStream to read the maturation parameters from
404 :     * \param TimeInfo is the TimeClass for the current model
405 :     * \param keeper is the Keeper for the current model
406 :     * \param minage is the minimum age of the stock that can mature
407 :     * \param numage is the number of age groups for the stock that can mature
408 :     * \param areas is the IntVector of areas that the maturity calculation can take place on
409 :     * \param givenname is the name of the stock for this MaturityD class
410 :     * \param LgrpDiv is the LengthGroupDivision for the stock
411 :     * \param numMatConst is the number of maturation parameters (6)
412 :     * \param refWeightFile is the name of the file to read the reference weight information from
413 :     */
414 :     MaturityD(CommentStream& infile, const TimeClass* const TimeInfo,
415 :     Keeper* const keeper, int minage, int numage, const IntVector& areas,
416 :     const char* givenname, const LengthGroupDivision* const LgrpDiv, int numMatConst, const char* refWeightFile);
417 :     /**
418 :     * \brief This is the default MaturityD destructor
419 :     */
420 :     virtual ~MaturityD() {};
421 :     /**
422 :     * \brief This will select the stocks required for the maturation process
423 :     * \param stockvec is the StockPtrVector of all the available stocks
424 :     */
425 :     virtual void setStock(StockPtrVector& stockvec);
426 :     /**
427 :     * \brief This will reset the maturation information for the current model run
428 :     * \param TimeInfo is the TimeClass for the current model
429 :     */
430 :     virtual void Reset(const TimeClass* const TimeInfo);
431 :     /**
432 :     * \brief This will check if the maturation process will take place on the current timestep
433 :     * \param TimeInfo is the TimeClass for the current model
434 :     * \return 1 if the maturation process will take place, 0 otherwise
435 :     */
436 :     virtual int isMaturationStep(const TimeClass* const TimeInfo);
437 :     /**
438 :     * \brief This will calculate the probability of maturation for a given age and length of the immature stock
439 :     * \param age is the age of the age-length cell that the maturation is being calculated on
440 :     * \param length is the length of the age-length cell that the maturation is being calculated on
441 :     * \param growth is the length of the age-length cell that the mature stock will grow into
442 :     * \param weight is the weight of the fish of the age-length cell that are maturing
443 :     * \return maturation probability
444 :     */
445 :     virtual double calcMaturation(int age, int length, int growth, double weight);
446 :     /**
447 :     * \brief This function will print the maturation information
448 :     * \param outfile is the ofstream that all the model information gets sent to
449 :     */
450 :     virtual void Print(ofstream& outfile) const;
451 :     protected:
452 :     /**
453 :     * \brief This is the DoubleVector of reference weight information
454 :     */
455 :     DoubleVector refWeight;
456 :     };
457 :    
458 :     #endif

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

Powered By FusionForge